Table does not display any border when php outputs data from MySQL.

I'm trying to set the following styles for table:
border-width: thin
border-style: solid

Below is the snippet of code I'm having trouble with.
print( "<table border-width = thin border-style = solid cellpadding = 1 width = 1400px>" );


Problem code within context of output.
-------------------------------------------------

<?php
 for ($i=0; $i<$num_results; $i++)
 {
 $row = mysql_fetch_array($result);

 print( "<table border-width = thin border-style = solid cellpadding = 1 width = 1400px>" );

 print( "<tr>" );
 print( "<td>" ); echo htmlspecialchars( stripslashes   
 ($row["lname"]));
 print( "</td>" ); 

 print( "<td>" ); echo htmlspecialchars( stripslashes
 ($row["fname"]));
 print( "</td>" ); 
 
 print(" </tr>" );
 print(" </table>" );

 echo "<p>End of List ! </p>";
 ?>

-----------------------------------------------------------------


Any help would be appreciated.... I'm a newbie at Web Dev so I realize my code is rough.... just have to work thru one problem at a time in order to put all the pieces together.

Recommended Answers

All 3 Replies

its not a php problem. your html syntax is wrong.

Try this instead:

print ('<table style="border-width: thin; border-style: solid; cellpadding=1; border-width: 10px;">');

Don't know why you'd want a 1400 pixel border. I changed it to 10 pixels but you can modify it to whatever you really need.

Thanks Chrishea for the help..... I wasn't sure if it was my HTML syntax or how I wrapped it in PHP code.

Thanks again for everyone's help.
Great website and group of knowledgable people.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.