Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML tables form with MySQL and PHP
    primarykey
    data
    text
    <p>I'm trying to create a <code>table form</code> that show all <code>database</code> from <code>MySQL</code> with <code>PHP</code>. It doesn't show up table, instead it prints out the first <code>job_order_number</code> in the <code>database</code> with the line "Cannot show columns <code>job_order_number</code>". At least it should show table form on the browser.</p> <p><strong>CSS</strong></p> <pre><code>&lt;style&gt; table.db-table { border-right:1px solid #ccc; border-bottom:1px solid #ccc; } table.db-table th { background:#eee; padding:5px; border-left:1px solid #ccc; border-top:1px solid #ccc; } table.db-table td { padding:5px; border-left:1px solid #ccc; border-top:1px solid #ccc; } &lt;/style&gt; </code></pre> <p><strong>PHP</strong></p> <pre><code>&lt;?php // connect to the MySQL database require("connect.php"); if(isset($_POST['submit'])){ $_POST['category_code'] = mysql_real_escape_string($_POST['category_code']); $sql = "SELECT * FROM CS_JOBS WHERE category_code =".$_POST['category_code']; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { $table = $row[0]; echo '&lt;h3&gt;'.$table.'&lt;/h3&gt;'; $result2 = mysql_query('SHOW COLUMNS FROM '.$table) or die('Cannot show columns from '.$table); if(mysql_num_rows($result2)) { echo '&lt;table cellpadding="0" cellspacing="0" class="db-table"&gt;'; echo '&lt;tr&gt;&lt;th&gt;Job Order Number&lt;/th&gt;&lt;th&gt;New Job&lt;/th&gt;&lt;th&gt;Job Title&lt;/th&gt;&lt;th&gt;Location&lt;/th&gt;&lt;th&gt;Close Date&lt;/th&gt;&lt;th&gt;Category_code&lt;/th&gt;&lt;/tr&gt;'; } while($row2 = my_sql_fetch_row($result2)) { echo '&lt;tr&gt;'; foreach($row2 as $key =&gt; $value) { echo '&lt;td&gt;'.$value.'&lt;/td&gt;'; } echo '&lt;/tr&gt;'; } echo '&lt;/table&gt;&lt;br /&gt;'; } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload