Forum Moderators: coopster
Sorry for the looong message.
I am in need of some help here. I am tring to extract mysql data with php into tables. I need to input the data of the fields into html extactly as below.
<table>
<tr>
<TD ALIGN=left WIDTH="sizeofcontent" bgcolor="#ffffff"></td>
</tr>
<tr>
<td width=150 valign=top>
<img src="graphic.jpg">
</td>
<td>
<font face=verdana size=4>Title</font><br>
<font face=arial size=3>Description</font><br>
<font face=verdana size=3><b><u>Date</u>: </b>March 5th 2008</font>
<font face=verdana size=3><b><u>Code</u>: </b></font>
<font face=verdana size=3>thecode</b></font><br><br>
</td>
</tr>
</table>
With repeating the html within the <table> tags. So, that the Mysql can create as many 2 column tables needed for all of the mysql tables information.
HERE IS THE PHP CODE I AM TRYING THAT IS INSERTED AFTER MYSQL LOGIN INFO...
$columns = 2; //you can change this to 3, 4, 5 etc.
$imagelink = $row["imagelink"];
$link = $row["link"];
$title = $row["title"];
$description = $row["description"];
$date = $row["date"];
$code = $row["code"];
$data = mysql_query ("SELECT * FROM Table");
$num_rows = mysql_num_rows($data);
echo "<table>";
for($i = 0; $i < $num_rows; $i++) {
$row = mysql_fetch_array($data);
if($i % $columns == 0) {
echo "<tr>\n";
eecho "<TD ALIGN=left WIDTH=sizeofcontent bgcolor="#ffffff"></td>\n";
echo "</tr>\n";
}
echo "<tr>\n";
echo "<td width=150 valign=top>\n";
echo "<img src=".$row[0].">\n";
echo "</td>\n";
echo "<td>\n";
echo "<font face=verdana size=4><a href=".$row[1].">".$row[2]."</a></font><br>\n";
echo "<font face=arial size=3>".$row[3]."</font><br>\n";
echo "<font face=verdana size=3><b><u>Date</u>: </b>".$row[4]."</font> \n";
echo "<font face=verdana size=3><b><u>Code</u>: </b></font>\n";
echo "<font face=verdana size=3>".$row[5]."</b></font><br><br>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
if($row[5]!= "Null")
echo "<td><a href='$UploadAddress/$row[5]'><img src='$ThumbAddress/$row[4]' border='0' alt='$row[0]'></a></td>\n");
if(($i % $columns) == ($columns - 1) ¦¦ ($i + 1) ==
$num_rows) {
}}
echo "</table>\n";
?>
Any help would be appreciated.. Thanks.
eecho "<TD ALIGN=left WIDTH=sizeofcontent bgcolor="#ffffff"></td>\n";
eecho?
And you need to escape double quotes.
echo "<TD ALIGN=left WIDTH=sizeofcontent bgcolor=\"#ffffff\"></td>\n";
I would suggest you enable error reporting at the top of your page:
<?php
error_reporting(E_ALL);
?>
That may give you some clues.
dc
[edited by: dreamcatcher at 9:59 am (utc) on Mar. 7, 2008]