Hi, I want to make a table (3 rows x 3 cols), I dont know how and to to take care of the <tr></tr> Right now i can only make a table with 1 row. totaly newbie here. echo '<table><tr><td>'; if($EntriesCount%3 == 0) { echo '</td><td>'; } echo '</td></tr></table>'; PHP: Please help. Thanks
If you have your html code for your table and simply want to echo it to be used in a php file, I suggest you go to http://www.quasarcr.com/html2php/ and put in your html, choose the echo option and use the result. The \n is also useful when you have javascript you want to convert to php code.
hey.. i dont know why but this code dint work when i run the same script.... i have run this script to fetch all data from mysql table through php..... please suggest me what to do.... thanks..
Here's a quick example: <?php $conn = mysql_connect("localhost", "mysql_user", "mysql_password"); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); exit; } if (!mysql_select_db("mydbname")) { echo "Unable to select mydbname: " . mysql_error(); exit; } $sql = "SELECT id as userid, fullname, userstatus FROM sometable WHERE userstatus = 1"; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } echo '<table><tbody>'; // <-- starting tags of table while ($row = mysql_fetch_assoc($result)) { echo '<tr>'; // <-- starting of row echo '<td>' . $row["userid"] . '</td>'; // column1 echo '<td>' . $row["fullname"] . '</td>'; // column2 echo '<td>' . $row["userstatus"] . '</td>'; // column3 echo '</tr>'; // <-- end of row } echo '</tbody></table>'; // <-- end tags of table mysql_free_result($result); ?> PHP: