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

Display search results

Status
Not open for further replies.

thumbelina

Programmer
Jun 4, 2001
58
CA
I'm using a mysql database with php on the website to build a search engine for the company library. I can get the select qury to work that to work that brings back the results " select * from table were $field = $requested"
now i know i need to use the mysql_fetch_array command but i'm not quite sure on how it works when it brings back more than one field for each record. I also want to print them in a table sort of like this:
field1 field2 field3
field1 field2 field3

and i don't know how many rows will be returned
any thoughts?

Thanks Thumbelina
 
hi Thumbelina,

do something like this

echo &quot;<table>&quot; ;
while($row = mysql_fetch_array($result) ) {
$field1 = $row[&quot;field1&quot;] ;
$field2 = $row[&quot;field2&quot;] ;
$field3 = $row[&quot;field3&quot;] ;

echo &quot;<tr>&quot; ;
echo &quot;<td>$field1</td>&quot; ;
echo &quot;<td>$field2</td>&quot; ;
echo &quot;<td>$field3</td>&quot; ;
echo &quot;</tr>&quot; ;

}

echo &quot;</table>&quot; ;




hope that will help u

spookie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top