Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL query result in a table problem

Status
Not open for further replies.

lardum

IS-IT--Management
Joined
Apr 26, 2000
Messages
462
Location
SE
> I'm having a little problem displaying the result of a SQL query in a
table.
> This is the PHP code i use:
>
> ----- PHP CODE -----
> $GBGet = "SELECT RegDate, RegTime, name, email, comment FROM guestbook";
> $GBResult = mysql_query($GBGet);
>
> print(&quot;<table border=1 cellpadding=2 cellspacing=2 bordercolor=000000>&quot;);
> print(&quot;<tr><td width=20><b>Date:</b></td><td width=20><b>Time:</b></td><td
> width=100><b>Name:</b></td><td width=100><b>E-mail:</b></td><td
> width=200><b>Comment:</b></td></tr>&quot;);
>
> while($rad = mysql_fetch_array($GBResult))
> {
> print(&quot;<tr><td>&quot;);
> print($rad[&quot;RegDate&quot;]);
> print(&quot;</td><td>&quot;);
> print($rad[&quot;RegTime&quot;]);
> print(&quot;</td><td>&quot;);
> print($rad[&quot;name&quot;]);
> print(&quot;</td><td>&quot;);
> print($rad[&quot;email&quot;]);
> print(&quot;</td><td>&quot;);
> print($rad[&quot;comment&quot;]);
> print(&quot;</td></tr&quot;);
> }
>
> mysql_free_result($GBResult);
> print(&quot;</table>&quot;);
>
> ---- END OF PHP CODE ----
>
> The result of this will be only one row in a table where the 4 first
columns
> are correct then it puts the second row in my table in the same row.
>
> Anyone have any ideas of why?
> FYI: I'm quite new to PHP and MySQL
>
>
>


 
Tried to change to mysql_fetch_assoc but still get the same result. I.e 2 columns called Name and E-mail.
Result is:

Name: E-mail:
John john@email.com Jane jane@email.com

I want it to be:
Name: E-mail:
John john@email.com
Jane jane@email.com

 
lardum,

Okay -I just noticed that your

Code:
</TR>

looks like this :

Code:
</TR

That's gonna cause confusion and is probably the reason why §;O)

Good Luck


Jakob
 
Hahaha

sorry. thanks. sometimes one really can be blind.

 
Heh! No prob! Nice with an extra pair of eyes, sometimes §;O)


Jakob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top