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)..

3
  • Show us what have you tried. Commented Dec 16, 2013 at 10:14
  • How to create HTML tables from MySQL? Commented Dec 16, 2013 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 .= "<tr> <td valign=\"center\"> &nbsp;&nbsp; <input type=\"checkbox\" id=\"contact_id[]\" name=\"contact_id[]\" value=\"".$row['id']."\"/></td> </tr>\n" ; } } Commented Dec 16, 2013 at 10:44

1 Answer 1

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>
Sign up to request clarification or add additional context in comments.

3 Comments

Thank u ...Itz working .. but i made use of for loop.
Okay good its working then try to use the same codes with a for loop , another thing when the code works for you you upvote it
@Fred-ii- okay but I really get motivated from people like you who comes up and corect our mistakes thanks once again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.