Jump to content

table link


marquis

Recommended Posts

ok im trying to make a table in which every row is a link to a different pagehere is my code

mysql_select_db("realestate", $con);$result = mysql_query($SQL);echo "<table border='5'>  <tr>  <th>Picture</th>  <th>Address</th>  <th>Price</th>  <th>Baths</th>  <th>Bedrooms</th>  <th>State</th>  <th>City</th>  <th>Square Feet</th>  <th>County</th>  <th>Year Built</th>  <th>Buy or Lease</th>  </tr>";while($row = mysql_fetch_array($result))  {  $accountnum=$row['accountnum'];      echo '<a href="descrip.php?accountnum='.$accountnum.'">';   echo "<tr>";  echo '<td> <img src="images/'.$row['imagename'].'" width="75" height="75"> </td>';  echo "<td>" . $row['address'] . "</td>";  echo "<td>" . $row['price'] . "</td>";  echo "<td>" . $row['baths'] . "</td>";  echo "<td>" . $row['bedrooms'] . "</td>";  echo "<td>" . $row['state'] . "</td>";  echo "<td>" . $row['city'] . "</td>";  echo "<td>" . $row['squarefeet'] . "</td>";  echo "<td>" . $row['county'] . "</td>";  echo "<td>" . $row['yearbuilt'] . "</td>";  echo "<td>" . $row['buyorlease'] . "</td>";  echo "</tr>";    echo "</a>";  	  }echo "</table>";

Link to comment
Share on other sites

What is it doing or not doing and what did you expect it to be doing or not doing. Telling us it is not working is not quite enough information. Someone might be able to give you some code that will make the problem go away, but only if I know what the problem is...Do you have a link to a live page, maybe? And a description to what the problem is?Asking us to pursue hypothetical or imaginary problems is about as much of a waste of time as cross-posting in two or more Forums (http://w3schools.invisionzone.com/index.php?showtopic=10877&hl=)... Hint, Hint...

Link to comment
Share on other sites

You can't have a table-row inside an anchor/link:

echo '<a href="descrip.php?accountnum='.$accountnum.'">'; // WRONG  echo "<tr>";  echo '<td> <img src="images/'.$row['imagename'].'" width="75" height="75"> </td>';  echo "<td>" . $row['address'] . "</td>";  echo "<td>" . $row['price'] . "</td>";  echo "<td>" . $row['baths'] . "</td>";  echo "<td>" . $row['bedrooms'] . "</td>";  echo "<td>" . $row['state'] . "</td>";  echo "<td>" . $row['city'] . "</td>";  echo "<td>" . $row['squarefeet'] . "</td>";  echo "<td>" . $row['county'] . "</td>";  echo "<td>" . $row['yearbuilt'] . "</td>";  echo "<td>" . $row['buyorlease'] . "</td>";  echo "</tr>";    echo "</a>"; // WRONG

This is an example of how you could do it:

echo "<tr>";  echo '<td> <a href="descrip.php?accountnum='.$accountnum.'"><img src="images/'.$row['imagename'].'" width="75" height="75" /></a> </td>';  echo "<td>" . $row['address'] . "</td>";  echo "<td>" . $row['price'] . "</td>";  echo "<td>" . $row['baths'] . "</td>";  echo "<td>" . $row['bedrooms'] . "</td>";  echo "<td>" . $row['state'] . "</td>";  echo "<td>" . $row['city'] . "</td>";  echo "<td>" . $row['squarefeet'] . "</td>";  echo "<td>" . $row['county'] . "</td>";  echo "<td>" . $row['yearbuilt'] . "</td>";  echo "<td>" . $row['buyorlease'] . "</td>";  echo "</tr>";

Note:Always end "empty tags" (as br, img etc.) with an /: <img ... /> and <br />

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...