PHP $rows=mysql_fetch_array ($result) same id more then one time.?

Kelly H

New member
Hey everyone. I am having a problem with my php fetch() code.

I have it selecting from id that are stored in a db.
(note the id will always be different)

Here is what the db may look like ( 123,254,122,123,242,123, 254 )

as of now it will display 123 one time
and 254 one time
i need it to display 123 x 2 time (or how ever many are defined same with any other id that have been entered more then once.

Here is the code im working with.

Please help!!!


<?php

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name where id IN ($rest) ";
$result=mysql_query($sql);
echo "<table border=\"1\" height=\"25\" cellspacing=\"0\" cellpadding=\"0\">";
$i=1;
$a=1;
while($rows=mysql_fetch_array($result)){


echo "<tr>";
echo "<td width=\"75\">";
echo $i++;
echo "</td>";
echo "<td width=\"300\">";
echo $rows['Description2'];
echo "</td>";
echo "<td width=\"75\">";
echo $rows['id'];
echo "</td>";
echo "<td width=\"100\"><center>";
echo "$";
echo $rows['price'];
echo "</center></td>";
echo "<td width=\"100\">";
echo "<center><a href=\"remove.php?id=";
echo $rows['id'];
echo "\">";
echo "Remove</a></center>";
echo "</td>";
echo "<td width=\"150\">";
echo "$";
echo $rows['price'];
echo "</td>";
echo "</tr>";

}
echo "</table>";
mysql_close();
?>
 
Back
Top