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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple array question.

Status
Not open for further replies.

kpdvx

Programmer
Dec 1, 2001
87
US
$query = "SELECT definition as answer FROM verbum limit 4";
$result = mysql_query($query);

How do I echo the 4 listings?

Thanks!
 
You get them out one row at at time using mysql_fetch_array() ( mysql_fetch_assoc() ( mysql_fetch_row()( or mysql_fetch_object() (

The pages for mysql_fetch_assoc(), mysql_fetch_object(), and mysql_fetch_array() all have sample scripts for you to look at. Want the best answers? Ask the best questions: TANSTAAFL!
 
use a foreach function
like
foreach ($result as $var)
{
print &quot;$var<br>&quot;;
}

Sometimes, when my code just won't behave, I take it outside and make it listen to britney spears music, and when it comes back it's really well behaved. I wonder if it's suffering from post tramatic stress syndrome now..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top