Clinton Posted April 17, 2008 Share Posted April 17, 2008 Not sure why my information is not parsing. I'm pretty sure it has something to do with the coded line below but I'm not sure what. Any help would be appreciated. Thanks. $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db("clintona_SLC",$dbhandle) or die("Can not open SLC Database"); $result = mysql_query("SELECT * FROM training ORDER BY lname"); ?> <html> <head> <title>Salt Lake City Training Report</title> </head> <body bgcolor="#FFFFFF"> <table border="1"> <tr> <td><b><u>Name:</b></u></td> <td><b><u>Date of Birth:</b></u></td> <td><b><u>License Expiration:</b></u></td> <? while ($row = mysql_fetch_array($result)) { ?> <td><? (".$row{'lname'}.' '.$row{'fname'}.' '.$row{'mname'}."); ?></td> <? } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted April 17, 2008 Share Posted April 17, 2008 1.) there's no need to enter and exit out of PHP like that. 2.) You're not echoing the variables. Try: <?php while ($row = mysql_fetch_array($result)) { echo '<td>'.$row['lname'].' '.$row['fname'].' '.$row['mname'].'</td>'; } ?> When you post, can you place all your code in the tags please? It makes it much easier to read. Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 17, 2008 Share Posted April 17, 2008 Another option: <?php while ($row = mysql_fetch_assoc($result)) { extract($row); echo "<td>$lname $fname $mname</td>"; } ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted April 17, 2008 Share Posted April 17, 2008 Also, you dont have any TRs to break up your rows and you are not using TDs correctly to put the data to match your headers. Quote Link to comment Share on other sites More sharing options...
Clinton Posted April 17, 2008 Author Share Posted April 17, 2008 Thanks grace about the extract row. That's a useful tool I wish I would have known about a while ago! :-) What do you mean revraz? Here's what I got, how is that not being utilized correctly? <html> <head> <title>Salt Lake City Training Report</title> </head> <body bgcolor="#FFFFFF"> <font size="2"> <table border="1"> <tr> <td>Name:</td> <td>Date of Birth:</td> <td>CDL License Expire:</td> </tr> <?php while ($row=mysql_fetch_assoc($result)){ extract($row); echo"<tr> <td>$lname $fname $mname</td> </tr>"; } ?> </table> </font> </body> </html> Quote Link to comment Share on other sites More sharing options...
revraz Posted April 17, 2008 Share Posted April 17, 2008 Well that is different than your first post, so at least you have TRs in there now, but your Data fields don't match. You have 3 header data fields <td>Name:</td> <td>Date of Birth:</td> <td>CDL License Expire:</td> But only 1 data field for your echo echo"<tr> <td>$lname $fname $mname</td> </tr>"; Or are you adding DOB and CDL later? Quote Link to comment Share on other sites More sharing options...
Clinton Posted April 17, 2008 Author Share Posted April 17, 2008 I was adding to them. I posted another post because I'm having a trouble with the format. It's not kicking over. I've dissected the thing 14 different times and I can't figure it out. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.