Jump to content

[SOLVED] Problem Table, puts html links at top...


Thundarfoot

Recommended Posts

I am a complete noob, but have managed to install (and after a few days get working) Apache, mysql, php, phpmyadmin, on a windows xp machine.

 

I have a mysql database and have created a table with 6 fields. (id, Name, Class, Grade, Comments, Pic).

 

All fields are simple text except the id and the last field "Pic" contains this html code, <a href="folder/picturex.jpg"><img src="folder/pictureicon.jpg" width="39" height="38" border="0" /></a>

 

My Problem is when I use my php script to display the contents of the table, in a table. The oupt places all HTML links at the top of the screen before the table, then procedes to make the table and fill it with the fields from the mysql table...(of note, any of the Pic field that does not contain HTML link, gets placed in the table proper).

 

I found this website today, and am currently reading the tutorials section in hopes of limiting the number of noob questions I have lol. Any help is most appreciated.

 

This is the script.

 

$result = mysql_query("SELECT * FROM Students")

or die(mysql_error()); 

 

echo "<table border='1'>";

echo "<tr> <th>Name</th> <th>Class</th> <th>Grade</th> <th>Comments</th> <th>Pic</th> </tr>";

 

// keeps getting the next row until there are no more to get

while($row = mysql_fetch_array( $result )) {

// Print out the contents of each row into a table

echo "<tr><td>";

echo $row['Name'];

echo "</td><td>";

echo $row['Class'];

echo "</td></tr>";

            echo $row['Grade'];

echo "</td></tr>";

            echo $row['Comments'];

echo "</td></tr>";

            echo $row['Pic'];

echo "</td></tr>";

}

 

echo "</table>";

?>

 

 

 

Link to comment
Share on other sites

Fix these three

 

echo $row['Class'];

  echo "</td></tr>";

            echo $row['Grade'];

  echo "</td></tr>";

            echo $row['Comments'];

  echo "</td></tr>";

            echo $row['Pic'];

 

You are ending the ROW 3 times and not starting a TD

Link to comment
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.