Select statement with Array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux