1

I want to create a table(in HTML) which will display rows and columns where i am calling from my query statement i.e.,

select id,name,city from contacts where enquiry_id=125

which will display 3 to 4 rows of data having enquiry_id=125.

The result will be displayed in HTML format for PHP.(or HTML)..

웃웃웃웃웃
  • 11,829
  • 15
  • 59
  • 91
Prakash N
  • 210
  • 2
  • 10
  • Show us what have you tried. – Zword Dec 16 '13 at 10:14
  • [How to create HTML tables from MySQL?](http://stackoverflow.com/questions/2690668/how-to-create-html-tables-from-mysql) – fiskolin Dec 16 '13 at 10:17
  • for($i=0;$i<$total;$i++) { $condition="id=".$id.""; $q1 = db_query('select *from '.PRE.$table.' where '.$condition); $id++; if($row = @db_fetch_array($q1)) { $content .= "    \n" ; } } – Prakash N Dec 16 '13 at 10:44

1 Answers1

1

You can try this and do not forget to connect to the database:

while ($record = mysql_fetch_array($result, MYSQL_ASSOC)) {
    ?>

<tr>
    <td><?=$record['id']; ?></td>
    <td><?=$record['name']; ?></td>
      <td><?=$record['city']; ?></td>
</tr>    
<?
}

mysql_free_result($result);
?>
</table>
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Humphrey
  • 2,659
  • 3
  • 28
  • 38