Jump to content

Urg! Almost ready to sell site but last fix "ruined site"


mike12255

Recommended Posts

So i was just adding one last feature to a website - light window (its forums are currently unavalible :( ) so anyway im triyng to make it so my code only displays X amount of pics per line which worked untill i added this lightbox crap. Any ideas on how to now make everything appear on the same line??

(error can be seen at: http://www.schoolworkanswers.com/pictures.php?p=1)

 

	    <?php
		if (isset ($_GET['p'])){
$page = $_GET['p'];
}else{
$page = 1;	
}
$itemPerPage = 12;
$offset = ($page - 1) * $itemPerPage;

          		$sql = "SELECT * FROM tbl_pic ORDER BY id DESC LIMIT $offset, 12";
			$sql2 = "SELECT * FROM tbl_pic";

	$result = mysql_query($sql) or die (mysql_error());
	$result2 = mysql_query($sql2) or die (mysql_error());
	$num = mysql_num_rows($result2);

		echo "<tr>";

$cols = 3; // number of columns here
$count = 1;
$rows = 0;
//lets show the images as we find them
while ($row = mysql_fetch_array($result)){
extract($row);


//when the remainder of count divided by cols is 0 do the following....
   if ($count % $cols == 0) {
      echo "</tr>"; // or close a tr and open a new one, etc..
  echo "<tr>";
   }

   $simg = str_replace("../","",$spath); 
    $img = str_replace("../","",$path); 
   echo "<a href=$img class=lightwindow title=ADD author=Kaon caption=$info><img src= $simg border =0></a>";
   
   $count++;
}
echo "</table>";

?>

Link to comment
Share on other sites

The problem is that the code below is suposed to stop them from all being on the same line:

 

 
         echo "<tr>";
   
   $cols = 3; // number of columns here
$count = 1;
$rows = 0;
//lets show the images as we find them
   while ($row = mysql_fetch_array($result)){
extract($row);


//when the remainder of count divided by cols is 0 do the following....
   if ($count % $cols == 0) {
      echo "</tr>"; // or close a tr and open a new one, etc..
     echo "<tr>";
   }

   $simg = str_replace("../","",$spath); 
    $img = str_replace("../","",$path); 
   echo "<a href=$img class=lightwindow title=ADD author=Kaon caption=$info><img src= $simg border =0></a>";
   
   $count++;
}

Link to comment
Share on other sites

First thing I would say is watch your quotes you have

<a href=images/Photo 101.jpg class=lightwindow title=ADD author=Kaon caption=asdfsdafsdafesd><img src= images/thumbs/Photo 101.jpg border =0></a> 

 

which should be

<a href="images/Photo 101.jpg" class="lightwindow" title="ADD" author="Kaon" caption="asdfsdafsdafesd"><img src= "images/thumbs/Photo 101.jpg" border ="0"></a> 

 

this should clean up quite a few of the errors.

 

Next you are outputting a table and you are making new <tr> instead of <td> for example you should have <tr><td>img</td></tr> to create a new row right now you are just echoing images out in <tr>img</tr> which doesn't really do anything.

 

I ran the site tough w3c validation you have 74 of them most of them can be corrected fairly easily.

http://validator.w3.org/check?uri=http%3A%2F%2Fwww.schoolworkanswers.com%2Fpictures.php%3Fp%3D1

 

brooke

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.