korbenmxli Posted March 21, 2010 Share Posted March 21, 2010 hi all im new to PHP & SQL i just wantr a simple way to give my query a grid format... i have this and works fine <?php // 1. Create a database connection $connection = mysql_connect("localhost","root","#######"); if (!$connection) { die("Database connection failed:" . mysql_error()); } // 2. Select a database to use $db_select = mysql_select_db("mb_tips" ,$connection); if (!$db_select) { die("Database selection failed: " . mysql_error()); } ?> <html> <head> <title>DISPLAY</title> </head> <body> <?php $result = mysql_query("SELECT * FROM tips", $connection); if (!$result) { die("Database query failed: " . mysql_error()); } while ($row = mysql_fetch_array($result)) { echo $row[1]." ".$row[2]."<br/>"; } ?> </body> </html> <?php mysql_close($connection); ?> how i make all my rows show like this ------------------------------------------------------ | Subject # | SUBJECT | Date | BLA | BLA | --------------------------------------------------------------- | 1 | bla bla | ccc ....................... .................... Link to comment https://forums.phpfreaks.com/topic/196059-just-a-simple-grid-no-more/ Share on other sites More sharing options...
proxim Posted March 22, 2010 Share Posted March 22, 2010 Something like this? <?php $result = mysql_query("SELECT * FROM tips", $connection); if (!$result) { die("Database query failed: " . mysql_error()); } $render = ' <table id="" border="0" cellpadding="0" cellspacing="0"> <tr> <td>Row 1</td> <td>Row 2</td> </tr> '; while ($row = mysql_fetch_array($result)) { $render .= ' <tr> <td>'.$row[1].'</td> <td>'.$row[2].'</td> </tr> '; } $render .= '</table>'; echo $render; ?> </body> </html> <?php mysql_close($connection); ?> Link to comment https://forums.phpfreaks.com/topic/196059-just-a-simple-grid-no-more/#findComment-1029813 Share on other sites More sharing options...
korbenmxli Posted March 23, 2010 Author Share Posted March 23, 2010 TNX thats what i need Link to comment https://forums.phpfreaks.com/topic/196059-just-a-simple-grid-no-more/#findComment-1030368 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.