Am si eu o mica-mare problema. Am cele doua portiuni de cod prima este index.php, si a doua este produs.php
Problema care este in momentul cand eu dau click pe un produs, imi afiseaza descrierea respectiva dar lista de produs contine doar produsul respectiv, celelalte produse dispar si nu inteleg de ce..
In pagina index.php toate produsele sunt afisate corect in partea stanga, dar in produs.php ramane doar un singur produs..
INDEX.PHP
Cod: Selectaţi tot
<?php
$lista_produse="";
$sql=mysqli_query($connection,"SELECT * FROM product ORDER BY price");
$count=mysqli_num_rows($sql);
if($count> 0){
while($row=mysqli_fetch_array($sql)){
$id=$row["id"];
$produs_nume=$row["product_name"];
$pret=$row["price"];
$lista_produse.= '<table width="274" border="0">
<tr>
<td width="154">
<a href="produs.php?id=' . $id . '"
<p>'.$produs_nume.'</p></a>
</td>
<td width="104" align="center" valign="top">$'.$pret.'<br/>
</td><hr>
</tr>
<hr>
</table>' ;
}
}else{
$lista_produse="Nu avem produse in stoc momentan";
}
mysqli_close($connection);
?>
<body>
<div align="center" id="mainWrapper">
<?php include_once('template_header.php');?>
<div align="center"id="pageContent">
<table width="998" border="1">
<tr>
<td width="279" height="430" valign="top">
<?php echo $lista_produse; ?>
</td>
<td width="703" valign="top"><img src="Untitled-1.jpg" width="707" height="430" /></td>
</tr>
</table>
PRODUS.php
<?php
if (isset($_GET['id'])) {
$id = preg_replace('#[^0-9]#i', '', $_GET['id']);
$sql=mysqli_query($connection,"SELECT * FROM product WHERE id='$id'");
$productCount = mysqli_num_rows($sql);
if ($productCount > 0) {
while($row = mysqli_fetch_array($sql)){
$id=$row["id"];
$produs_nume=$row["product_name"];
$pret=$row["price"];
$detalii=$row["details"];
$lista_produse.= '<table width="274" border="0">
<tr>
<td width="154">
<a href="produs.php?id=' . $id . '"
<p>'.$produs_nume.'</p></a>
</td>
<td width="104" align="center" valign="top">$'.$pret.'<br/>
</td><hr>
</tr>
<hr></table>' ;
}
}else{
echo "That item does not exist.";
exit();
}
}else{
echo "Data to render this page is missing.";
exit();
}
mysqli_close($connection);
?>
<body>
<div align="center" id="mainWrapper">
<?php include_once('template_header.php');?>
<div align="center"id="pageContent">
<table width="998" border="1">
<tr>
<td width="279" height="430" valign="top">
<?php echo $lista_produse; ?> </td>
<td width="703" valign="top">
<?php echo $produs_nume;?><br/>
<?php echo $detalii;?><br/>
</td>
</tr>
</table>
</html>