php scripting tables and mysql problems?

  • Thread starter Thread starter Mr E
  • Start date Start date
M

Mr E

Guest
i have some code that is designed to populate a htmltable with data from a mysql table only it doesn't work, also when you click the images it displays the large version of the image, which does work.

if you can think of a better way to make this work please post or if you know whats wrong with this please tell me

the whole idea is that it is meant to display about 5 of my products (doors) and their image names in a horizontal line (in the html table on the webpage) and then move on to the next row and fill that up and so on until all the doors selected have been displayed.

this is my code.

<div id="MainContent">
<table class="homelist">
<tr>
<th>DoorName</th>
<th>Name</th>
<th>Column </th>
</tr>
<?php

$con = mysql_connect("localhost", "root", "")|| die;
mysql_select_db("protechpricer");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

// some code

// gathers the door name the final price and the thumbnail for all doors that have Arbury in their name
$result = mysql_query("SELECT DoorName, Thumbimage FROM tblpricelist WHERE DoorName like '%Arbury%'");

$rowCheck = mysql_num_rows($sql);
if ($rowCheck == 0) {
echo "Could not retrieve results";
die;
}
else {
while ($query = mysql_fetch_array($sql)) {
echo '<tr>';
$id = $query['DoorName'];
echo "<td>" . "<img src='./thumb/". $row['Thumbimage']."' onmousedown=\"this.src='./large/". $row['Thumbimage']."'\" onmouseup=\"this.src='./thumb/". "</td>";
echo "<td>".{$name['DoorName']}."</td>";
echo '</tr>';
}


?>
</table>
</div>

it just says theres an error on line 49 which is what is preventing it from working which is:

echo "<td>".{$name['DoorName']}."</td>";

but also it said there was an error right at the bottom of my webpage i was scripting it in which just had </html>

any suggestions on how to get this to do what i want or a better method on how to do it i'll be greatful
 
Try this code:
<?php

$con = mysql_connect("localhost", "root", "") or die('Could not connect: ' . mysql_error());;
mysql_select_db("protechpricer");

// gathers the door name the final price and the thumbnail for all doors that have Arbury in their name
$sql = mysql_query("SELECT DoorName, Thumbimage FROM tblpricelist WHERE DoorName like '%Arbury%'");

$rowCheck = mysql_num_rows($sql);
if ($rowCheck == 0) die("Could not retrieve results");
else
{
while ($row = mysql_fetch_array($sql))
{
echo '<tr>';
$id = $row['DoorName'];
echo "<td>" . "<img src='./thumb/". $row['Thumbimage']."' onmousedown=\"this.src='./large/". $row['Thumbimage']."'\" onmouseup=\"this.src='./thumb/". "</td>";
echo "<td>".{$row['DoorName']}."</td>";
echo '</tr>';
}
?>
 
Back
Top