Select statement with Array
| From: | Mark | Date: | Fri, 18 Apr 2003 03:45:58 +0000 |
| Subject: | Select statement with Array | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-27153@lists.php.net to get a copy of this message | ||
I have the following code(minus the connection to the database):
$query = @mysql_query("SELECT
ID,lastname,frstname,address,city,state,zipcode,homephne,email,employ,occptn
,workphne,housetype,usher830 from database.talents WHERE ID=\"4\";");
while ($usher = mysql_fetch_array($query)) {
$lastname = htmlspecialchars($usher["lastname"]);
$frstname = htmlspecialchars($usher["frstname"]);
$address = htmlspecialchars($usher["address"]);
$usher830 = htmlspecialchars($usher["usher830"]);
print("<table border=\"2\"><tr>");
print("<td>$frstname $lastname</td>");
print("<td>$address</td>");
print("</tr>");
if ($usher830 == 1) {
print("<tr><td>$title[16]</td></tr>");
}
print("</table>");
}
I want to be able to connect to the table in the database and pull
information from each field and if it is equal to 1 (true, user selected
this) print out a certain phrase. This all works, the only problem is I
have over 100 fields and it would be a very large file do all of this like I
am currently doing. Is there a way to loop the top part with the
htmlspecialchars part and then also the if statement at the bottom? I cut
down the SELECT statement to show the necessary part, there is more to it.
Thanks.
Mark