Jump to content

Recommended Posts

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:

9ftz0z.png

 

 

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:

 

2i9niug.png

 

 

 

If someone could fix my code for me i would greatly appriciate it :)

Link to comment
https://forums.phpfreaks.com/topic/270529-table-not-working/
Share on other sites

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! :thumb-up:

Link to comment
https://forums.phpfreaks.com/topic/270529-table-not-working/#findComment-1391471
Share on other sites

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 by Stipe
Link to comment
https://forums.phpfreaks.com/topic/270529-table-not-working/#findComment-1391509
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/270529-table-not-working/#findComment-1391519
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.