i can't get multiple rows into array from mysql database? i have code but it is not working or not showing all rows when i echo into textbox?
<?php
if(is_array($_SESSION['pid']))
{
$pid = join(',',$_SESSION['pid']);
$result=mysql_query("SELECT id AS wid FROM mywishlist where pid='$pid'")
or die("Id Problem"."<br/><br/>".mysql_error());
$results= array();
$i=0; // add the new line
while($row=mysql_fetch_array($result)){
$results[$i] = $row['wid'];
$i++;
}
$results;
}
$max=count($results);
for($j=0; $j<$max; $j++)
{
?>
<input type="text" name="wid[]" value="<?php echo $results[$j]; ?>" />
<?php } ?>
The line join(',',$_SESSION['pid']) makes me think that you want to select multiple rows by their pid. Try to make use of IN operator:
SELECT id AS wid FROM mywishlist
WHERE pid IN ($pid)
your query is wrong, use this query
$result=mysql_query("SELECT id AS wid FROM mywishlist where pid IN($pid) ")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With