Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

1 SQL statement - Can you have 2 while statements?

Status
Not open for further replies.

TheDeaner

Technical User
Oct 13, 2004
11
US
I want to loop through results with a while statement without having to do another SQL statement. Here is my example.

----------------------------------
$sql_statement = "SELECT id, price, title, date, FROM table where date = \"2004/12/7\"";
$result = mysql_query($sql_statement) or die(mysql_error());

while($abc = mysql_fetch_array( $result ))

{
$id = $abcd[0];
$price = $abc[1];
$title = $abc[2];
$date = $abc2[3];

echo "$title";
}

// I want to run another while statement here

while($bob2 = mysql_fetch_array( $result ))

{
echo "Now I will list $id";
}

------------------------------------


Let's say I run a SQL statement to pull pictures and titles of movies from a data base. I want the pictures to cycle through first with a while statement. When all the pictures cycle through I want to list the titles with price or whatever afterward (IE: Now I will list $id from above). I don't want to have another SQL statement if possible. Does anyone know if this is possible and how it can be done?

Thanks
Dean
 
Doh. Good thinking. Sorry. Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top