Skip navigation links

MySQL Forums :: PHP :: Display column contents in html table with PHP


Advanced Search

Display column contents in html table with PHP
Posted by: Gabriel Cánepa ()
Date: August 21, 2012 07:11PM

I have the following PHP code embedded in a HTML file.
The PHP code is used to execute a query against a MySQL database/table whose contents are then used to create check boxes and assign to them each value contained in a specific column. That works just fine.
What I want know is how can I display that column's values in a html table with, let's say, 3 columns and the needed rows. So if I have 10 rows in the MySQL table, I want to display its values in a html table like this:
Value1 Value2 Value3
Value4 Value5 Value6
Value7 Value8 Value9
Value10
###############################################################################
<?php

mysql_connect('localhost', 'username', 'password');
mysql_select_db('mydatabase');

$sql = "SELECT categoria FROM categorias_tbl";
$result = mysql_query($sql);

//echo "<select name='categoria'>";
while ($row = mysql_fetch_array($result)) {
echo "<input type='checkbox' name="."categoria value=". $row['categoria']." />". $row['categoria']."<br />";
}
?>
###############################################################################
Any ideas and suggestions will be more than welcome!

Options: ReplyQuote


Subject Written By Posted
Display column contents in html table with PHP Gabriel Cánepa 08/21/2012 07:11PM
Re: Display column contents in html table with PHP Barry Galbraith 08/21/2012 07:40PM
Re: Display column contents in html table with PHP Gabriel Cánepa 08/22/2012 07:32AM
Re: Display column contents in html table with PHP Peter Brawley 08/22/2012 08:47AM
Re: Display column contents in html table with PHP Gabriel Cánepa 08/22/2012 09:10AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.