mike12255 Posted April 9, 2009 Share Posted April 9, 2009 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>"; ?> Quote Link to comment Share on other sites More sharing options...
ram4nd Posted April 9, 2009 Share Posted April 9, 2009 Thay are on the same line at the website, but linger line of images messes up the site. I don't see where is the problem. Quote Link to comment Share on other sites More sharing options...
mike12255 Posted April 9, 2009 Author Share Posted April 9, 2009 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++; } Quote Link to comment Share on other sites More sharing options...
BandonRandon Posted April 9, 2009 Share Posted April 9, 2009 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.