We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,983 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Help with spacing of dynamically generated tables

This is a CSS/HTML issue, not php. Your php is suspect:

Line 15.

No need for all the tables? How about one table? Do you really need a table anyway? Why not use <h3> for name, <p> or <div> for content?

Any reason why you'r using mysql_result? This tends to shift the internal pointer when called. Perhaps mysql_fetch_array() would be a better option with a while loop.

Also using * in your sql is a bit wasteful, you should name the fields you want.

2
Contributors
1
Reply
13 Hours
Discussion Span
2 Years Ago
Last Updated
2
Views
Question
Answered
diafol
Keep Smiling
Moderator
10,651 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,510
Skill Endorsements: 57

Your loop is messy.
This code shows simple looping for showing data in tabular form.

<?php
 $username="root";
 $password="";
 $database="";

 mysql_connect('localhost',$username,$password);
 @mysql_select_db($database) or die( "Unable to select database");
 $query="SELECT * FROM jokes";
 $result=mysql_query($query);

 echo '<table width="900%" border="0">';
 while($sar = mysql_fetch_assoc($result))
 {
 	echo '<tr>
    <td>'.$sar['name'].'</td>
    <td>'.$sar['content'].'</td>
  </tr>';
 }
 echo '</table>';
 mysql_close();
 ?>
vibhaJ
Posting Shark
958 posts since Apr 2010
Reputation Points: 161
Solved Threads: 190
Skill Endorsements: 3
Question Answered as of 1 Year Ago by vibhaJ

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0592 seconds using 2.68MB