Jump to content

just a simple grid... no more


korbenmxli

Recommended Posts

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

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);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.