Page 1 of 1

Php sql results question for the query

Posted: Thu May 07, 2009 9:50 am
by killingbegin
Hello.I have a $SESSION['card'];

with some values example 6,5,45,2,5 all that are id's of products
What i want is to echo the rest things that describes products ids like name descreption etc

Code: Select all

 
//the connection to database
include('includes/conn.inc.php');
 
//iBrake the string to an array
$pieces = explode(",", $_SESSION['card']);
 
 
$strquery = mysql_query("SELECT * FROM products WHERE prod_id=$pieces[0]");
 
while($row = mysql_fetch_array($strquery))
    {
        extract($row);
        echo    "<table>";
        echo    "<tr>";
        echo    "<td>";
        echo $row['prod_name'];
        echo    "</td>";
        echo    "</tr>";
        echo    "</table>";
        
    }
 
until here its working fine

but the query
$strquery = mysql_query("SELECT * FROM products WHERE prod_id=$pieces[0]");
in the spot prod_id i want it to take alla the id's from the array
thnx '

Re: Php sql results question for the query

Posted: Sat May 09, 2009 1:13 am
by jaoudestudios
Try mysql_fetch_assoc instead of mysql_fetch_array