petroz Posted September 6, 2009 Share Posted September 6, 2009 Hi Guys, The below query prints my query results. I would like to incorporate tables for aesthetics. Any pointers on inserting these results into tables or anything else that might look better would be greatly appreciated. Thanks, P --- $account = sprintf("SELECT bus_id , nickname , description , email , phone , address , hours FROM businesses WHERE bus_id = '$username'", mysql_real_escape_string($nickname), mysql_real_escape_string($description), mysql_real_escape_string($email), mysql_real_escape_string($phone), mysql_real_escape_string($address), mysql_real_escape_string($hours), mysql_real_escape_string($username)); $details = mysql_query($account); if (!$details) { die("Invalid details query: " . mysql_error()); } while($row = mysql_fetch_array($details)) { $stringData = $row['bus_id']; print("Current Username :: " . $stringData . "\n"); echo "<br/>\n"; $stringData = $row['nickname']; print("Current Public Name :: " . $stringData . "\n"); echo "<br/>\n"; $stringData = $row['description']; print("Current Description :: " . $stringData . "\n"); echo "<br/>\n"; $stringData = $row['email']; print("Current Email :: " . $stringData . "\n"); echo "<br/>\n"; $stringData = $row['phone']; print("Current Phone :: " . $stringData . "\n"); echo "<br/>\n"; $stringData = $row['address']; print("Current Address :: " . $stringData . "\n"); echo "<br/>\n"; $stringData = $row['hours']; print("Current Hours of Opperation :: " . $stringData . "\n"); Link to comment https://forums.phpfreaks.com/topic/173291-printing-mysql-query-results-into-table/ Share on other sites More sharing options...
Jnerocorp Posted September 6, 2009 Share Posted September 6, 2009 Try this and let me know if thats what you are looking for: <?php mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("database_name") or die(mysql_error()); $result = mysql_query("SELECT bus_id , nickname , description , email , phone , address , hours FROM businesses WHERE bus_id = '$username'") or die(mysql_error()); echo "<table border='1'>"; echo "<tr> <th>Current Username:</th> <th>Current Public Name:</th> <th>Current Description:</th> <th>Current Email:</th> <th>Current Phone:</th> <th>Current Address:</th> <th>Current Hours of Opperation:</th> </tr>"; while($row = mysql_fetch_array( $result )) { echo "<tr><td>"; echo $row['bus_id']; echo "</td><td>"; echo $row['nickname']; echo "</td><td>"; echo $row['description']; echo "</td><td>"; echo $row['email']; echo "</td><td>"; echo $row['phone']; echo "</td><td>"; echo $row['address']; echo "</td></tr>"; } echo "</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/173291-printing-mysql-query-results-into-table/#findComment-913452 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.