GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 09-Feb-2004, 21:21
pellsweb2 pellsweb2 is offline
New Member
 
Join Date: Feb 2004
Posts: 2
pellsweb2 is on a distinguished road
Question

Php And Table Formatting


ELLO

i have just started using php and am having some difficulties with regard to getting the db results to view in a table the code being used ommitting passwords is:-

<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
$username = "pellsweb1";
$password = "******";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password)
or die("unable to connect to MYSQL") ;
print "Connected to mysql<br>";
$selected = mysql_select_db("pellsweb",$dbh)
or die("could not select phil".mysql_error());
$res = mysql_query("SELECT * FROM phil")
or die (mysql_error());
?>
<table width="530">
<tr>
<td width="136" height="90"><div align="center">id</div></td>
<td width="136"><div align="center">firstname</div></td>
<td width="136"><div align="center">surname</div></td>
<td width="136"><div align="center">addy</div></td>
</tr></table>
<?php



while ($row = mysql_fetch_array($res,MYSQL_ASSOC))
{
print "<tr><td>" . $row['id'] . "</td><td>" . $row['firstname'] . "</td><td>"
. $row['surname'] . "</td><td>" . $row['addy']."</td></tr><br>";
}
// you are going to do lots more here soon
mysql_close($dbh);
?>
</table>

</body>
</html>

and the web page showing the output is @ www.pellsweb.co.uk i know that some thing is wrong here but cant see what the hell it is, as you can see from the web page there is no error being reported so (holds hands up in despair).

any help would be greatly appreciated.

thanks in advance.
Last edited by dsmith : 09-Feb-2004 at 23:00.
  #2  
Old 09-Feb-2004, 23:01
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Hey, sorry if this doesn't help. I don't know a heck of alot about php right now, but i do know a little about html. It appears that you end your table definition before you add your records, try removing the end table that you have here:
HTML Code:
<td width="136"><div align="center">addy</div></td> </tr></table> <?php

so it looks like this:
HTML Code:
<td width="136"><div align="center">addy</div></td> </tr> <?php

Hope that helps
  #3  
Old 10-Feb-2004, 03:59
pellsweb2 pellsweb2 is offline
New Member
 
Join Date: Feb 2004
Posts: 2
pellsweb2 is on a distinguished road
Smile

php and table formatting


thanks mate did the trick i didnt realise that i ended the table 2 times well spotted
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP script to show last referrer url and top referrer to your site jrobbio MySQL / PHP Forum 6 22-May-2006 02:06
Textarea and PHP. Antinaris MySQL / PHP Forum 2 21-Nov-2003 10:09
Trying to retrieve selective results from a table. icsys MySQL / PHP Forum 9 18-Nov-2003 04:31
Automate a data change php form mjfmn MySQL / PHP Forum 4 20-Oct-2003 10:37
[Tutorial] MySQL Basics nniehoff MySQL / PHP Forum 15 23-Mar-2003 20:42

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:52.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.