Stipe Posted November 10, 2012 Share Posted November 10, 2012 Last time i posted here i wasnt clear enough or supplied enough info, so this time around i will supply more info hopefully enough! Firstly the problem: Simple, my table isn't working as it should, I've tried to compare it to others on other pages but clueless as to why it doesn't work, it displays this: The table should be 4 rows with Owner and Name in there already, all the views should be below one another on another row, here is the coding: $sql3 = "SELECT * FROM phonecompany ORDER by id"; $result3 = mysql_query($sql3); ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel=stylesheet href=includes/in.css type=text/css> </head> <body><br> <td bgcolor="#444444"><form name="form1" method="post" action=""> <br> <table width="700" border="0" align="center" cellpadding="3" cellspacing="1" class="data_table"> </tr> <tr align="left" class="head_cell"> <th class="header" colspan="6">• Phone Companies</th> </tr> <tr bgcolor="#555555"> <td height="8" colspan="6" valign="top"><img src="images/phone.png" name="img" width="700" height="100" border="0" id="img"></td> </tr> <tr align="left" class="head_cell"> <th class="header" width="25%">Owner</th> <th class="header" width="65%">Name</th> <th class="header" width="10%"> </th> </tr> <? while($phonecompany2 = mysql_fetch_object($result3)){ ?> <tr align="left" bgcolor="#555555"> <td bgcolor="#555555" align="left"><?php echo "$phonecompany2->Owner"; ?></td> <td bgcolor="#555555" align="left"><?php echo "$phonecompany2->Name"; ?></td> <td bgcolor="#555555" align="left"><a href="?view=<?php echo "$phonecompany2->id"; ?>">View</a></td> </tr> </table> <? } ?> <p> </p> </div> </div> </form> </body> </html> And here is how the database looks: If someone could fix my code for me i would greatly appriciate it Quote Link to comment https://forums.phpfreaks.com/topic/270529-table-not-working/ Share on other sites More sharing options...
Manixat Posted November 10, 2012 Share Posted November 10, 2012 I'm not sure if you're really aware of how tables work. You have a <td> tag before the opening <Table> tag ? If you're a beginner I suggest you avoid using TH because it is confusing. Simply use <tr> which opens a new row and <td> which opens a new column, and use a black border on a white background to actually see what is happening, that way it will be really easy for you to structure your table. If you're still having trouble check out this tutorial. Hope you'll manage! Quote Link to comment https://forums.phpfreaks.com/topic/270529-table-not-working/#findComment-1391471 Share on other sites More sharing options...
Barand Posted November 10, 2012 Share Posted November 10, 2012 Also you have </table> inside your while loop thereby closing the table after the first iteration. Move it to after the loop Quote Link to comment https://forums.phpfreaks.com/topic/270529-table-not-working/#findComment-1391481 Share on other sites More sharing options...
Stipe Posted November 10, 2012 Author Share Posted November 10, 2012 Thank you! The table now looks good, but I'm not sure still why the table isnt auto filling with the info needed, any help on this? Quote Link to comment https://forums.phpfreaks.com/topic/270529-table-not-working/#findComment-1391493 Share on other sites More sharing options...
jcbones Posted November 10, 2012 Share Posted November 10, 2012 Have you run the query in a database software like phpMyAdmin, or in the MySQL console? Have you checked the "view source" of the page? Quote Link to comment https://forums.phpfreaks.com/topic/270529-table-not-working/#findComment-1391507 Share on other sites More sharing options...
Stipe Posted November 10, 2012 Author Share Posted November 10, 2012 (edited) The query is run straight from the .php file not phpMyAdmin or MySQL console As for the source it as the page is: <tr align="left" bgcolor="#555555"> <td bgcolor="#555555" align="left"></td> <td bgcolor="#555555" align="left"></td> <td bgcolor="#555555" align="left"><a href="?view=24">View</a></td> </tr> When that should be: <tr align="left" bgcolor="#555555"> <td bgcolor="#555555" align="left">No Owner</td> <td bgcolor="#555555" align="left">System Phones</td> <td bgcolor="#555555" align="left"><a href="?view=24">View</a></td> </tr> Edited November 10, 2012 by Stipe Quote Link to comment https://forums.phpfreaks.com/topic/270529-table-not-working/#findComment-1391509 Share on other sites More sharing options...
PFMaBiSmAd Posted November 10, 2012 Share Posted November 10, 2012 You need to have php's error_reporting set to E_ALL and display_errors set to ON in your master php.ini on your development system so that php will help you by reporting and displaying all the errors it detects. Your database column names are not exactly Owner and Name, so $phonecompany2->Owner and $phonecompany2->Name would be producing undefined property errors to alert you to the mismatch between your actual column names and the names you are using in your code. Quote Link to comment https://forums.phpfreaks.com/topic/270529-table-not-working/#findComment-1391519 Share on other sites More sharing options...
Stipe Posted November 10, 2012 Author Share Posted November 10, 2012 Wow! I totally forgot about case sensitivity! Thank you so much though I'm a little embarrassed it was all due to that I'll probably have more problems on different parts of this page so watch this space! Lol! I'll edit my php.ini thanks Quote Link to comment https://forums.phpfreaks.com/topic/270529-table-not-working/#findComment-1391551 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.