Jump to content

I need some help with this script, can't seem to find the problem.


Recommended Posts

I'm having trouble with my script. I'm getting pictures from the database and showing it in 3 columns and putting some information in each table location with the picture. But I made  a change and  now the table still works but I get a full blank page and have to scroll down to see the pictures.  Can anybody see where my problem exists, it was working fine but now it doesn't. Any help would be appreciated. Thanks in advance.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<title></title>
<head>
<link rel="stylesheet" href="./stylesheet/stylesheet1.css" media="screen">
<style type="text/css" media="screen">@import url("./stylesheet/stylesheet2.css");</style>

</head>
<body>
<center><table cellspacing="5" cellpadding="5" width="800" border="1">
<?php
include "connect.php";
$query = "SELECT * FROM promo_vet ORDER BY year";
$result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error());
if($result && mysql_num_rows($result) > 0)
{
    $i = 0;
    $max_columns = 3;
    while($row = mysql_fetch_array($result))
   {
       // make the variables easy to deal with
       extract($row);
       // open row if counter is zero
       if($i == 0)
         echo "<tr>";
       // make sure we have a valid product ALIGN='CENTER'
       if($year != "" && $year != null)
          echo "<td align='center'><a><img src=\"$picture\"></a><br>$testshot<FONT COLOR='red'><b>$year</b></FONT><br>$description <br> $boxno<br>$convertible<br>$coupe </td><BR>";
      // increment counter - if counter = max columns, reset counter and close row
       if(++$i == $max_columns)
       {
           echo "</tr>";
          $i=0;
           }  // end if
   } // end while
} // end if results
// clean up table - makes your code valid!
if($i < $max_columns)
{
    for($j=$i; $j<$max_columns;$j++)
        echo "<td> </td>";
}
?>
</tr>
</table></center>
</body>
</html>

I don't see anything here that could cause a big white space above your table. But than again I am not sure what you have in your  stylesheet what may very well say

table{margin-top:600px;} 

or something.

Do you maybe have it somewhere online so i can have a look. I think this is more a html css question than a php one. Also your using some bad tags (see my signature for a reference on that) and your pretty inconsistent with the use of <br> and <BR>

have you tried to run the output of your page through a w3c validator also?

echo "<td align='center'><a><img src=\"$picture\"></a><br>$testshot<FONT COLOR='red'><b>$year</b></FONT><br>$description <br> $boxno<br>$convertible<br>$coupe </td><BR>"; <-break rule outside of table columns

 

May help.

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.