Forum Moderators: coopster
I have wrote a PHP script, with MYSQL, that reads a database based on users input. When the criteria only matches one result in the database, everythings fine. But when the data has two results I need to display, I only show one. Do I need to write some kind of loop?
jd
The sequence is something like this:
1. build a query to select the data you want to display:
$query = "SELECT * FROM dbtable WHERE fieldname = 'match'";
2. run the query
$result = @MYSQL_QUERY($query);
3. put the result in a useable array
$while ($row = mysql_fetch_array($result)) {
$match = $row[match] ;
4. display the match, still inside the while loop
$display .= "<li>$match</li>" ;
5. close the loop and display your matches
}
echo "$display";
This should give you an idea of the sequence, but it is not meant to teach you the syntax. As AndrewB pointed out, the manuals are really helpful and there are some great tutorials on the web:
php-mysql tutorials [google.com].
Mark