Html table listing Mysql Contnet

Hi, I begun a crash course in Php 2 days ago…and in need of serious help and present a project work.
I may get the terms wrong … i do hope to receive help.

I have an Html Table with 16 columns - I also have a mysql database table with 25 columns - I want the Html table to list only 16 out of the 25 columns in the html table I have created… … Any Help…

I really appreciate it

Thanks

Number of columns does not matter! :slight_smile:
But you need to know your database table field names what you want to display in certain columns of a html table. Here is the php code:
[php]<?php
// connecting to MySQL database
$mysqlink = mysql_connect(‘localhost’,‘UserName’,‘PaSSwoRd’) or die(mysql_error());
mysql_select_db(‘dbName’,$mysqlink);

// query records from table
$r = mysql_query(“select Field1, Field2, Field3 from myTable order by Field1”);
if(mysql_num_rows($r)){

echo '<table width="100%" border="1">';
echo '<tr>';
echo '<th>Column 1</th>';
echo '<th>Column 2</th>';
echo '</tr>';

// display table records in a loop
for($i=0;$i<mysql_num_rows($r);$i++){
  $f = mysql_fetch_array($r);
  echo '<tr>';
  echo '<td>'.htmlspecialchars($f['Field1']).'</td>';
  echo '<td>'.htmlspecialchars($f['Field2']).'</td>';
  echo '</tr>';
}

echo '</table>';

}

?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service