Php sql results question for the query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
killingbegin
Forum Newbie
Posts: 20
Joined: Sun Feb 08, 2009 5:07 am

Php sql results question for the query

Post 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 '
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Php sql results question for the query

Post by jaoudestudios »

Try mysql_fetch_assoc instead of mysql_fetch_array
Post Reply