<?php
$objConnect = mysql_connect("localhost","","root") or die(mysql_error());
$objDB = mysql_select_db("mydb");
$pic2 = "SELECT * FROM thumbs";
if (!isset($_GET['Page'])) $_GET['Page']='0';
$pic1 = mysql_query($pic2);
$Num_Rows = mysql_num_rows($pic1);
$Per_Page = 16; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;}
$pic2 .=" order by thumbnailID ASC LIMIT $Page_Start , $Per_Page";
$pic1 = mysql_query($pic2);
$cell = 0;
$link1 = "SELECT * FROM thumbs";
$result_link1 = mysql_query($link1);
$link = mysql_fetch_array($result_link1);
$alt1 = "SELECT * FROM thumbs";
$alt = mysql_fetch_array(mysql_query($alt1));
$height1 = "SELECT * FROM thumbs";
$height = mysql_fetch_array(mysql_query($height1));
$width1 = "SELECT * FROM thumbs";
$width = mysql_fetch_array(mysql_query($width1));
$time1 = "SELECT * FROM thumbs";
$time = mysql_fetch_array(mysql_query($time1));
$folder1 = "SELECT * FROM thumbs";
$folder = mysql_fetch_array(mysql_query($folder1));
$filed1 = "SELECT * FROM thumbs";
$filed = mysql_fetch_array(mysql_query($filed1));
echo '
<div id="tablediv">
<table border="0" cellpadding="17" cellspacing="0" class="table">
<tr>';
while($pic = mysql_fetch_array($pic1))
{
if($cell % 4 == 0)
{
echo '</tr><tr>';
}
{
echo'
<td>
<a href="/' . $link["link"] . '">
<div class="image"><img src="' . $pic["pic"] . '"
alt="' . $alt["alt"] . '"
height="' . $height["height"] . '"
width="' . $width["width"] . '"
/>
</div>
</a>
<div class="timeago">
<abbr class="timeago" title="' . $time["time"] .'">
</abbr> in <a href="/' . $folder["folder"] . '">
<span class="filedat">' . $filed["filed"] . '</div></a>
</div>
</td>';
}
$cell++;
}
echo '</tr></table></div>';
?>
I’m a noobie, and I have no idea why this code is only picking up the first row in my mysql database. Here’s what I mean.
My phpmyadmin db looks like:
thumbnailID | link | pic | alt | time | height | width | folder | filed
1 blog random.png descrip 3:45 300 200 emm weewr
2 about etc.png desc 4:15 130 150 wer ewrre
3 misc er.png desc 2:30 324 435 sdf dcv
4 misc etc.png info 6:50 203 034 sdf qwd
5 about meh.png whoa 10:12 395 234 tb asd
So as you can see, there is five different rows. But for some reason, row 2,3,4, and 5, all have the same link, alt, time height, width, folder, and filed, as row 1. The only thing different is the pic.
For if this sounds confusing, but I don’t know how to put it in any other way.
You are issuing multiple
mysql_queryrequests, which always resets the pointer to the first row. Butmysql_fetch_arrayis to be used in a loop. It also queries for rows, not column-wise.Your problem is that you are using previous result arrays $link[], $pic[], $alt[], $width[], $height[] for your output code – where you should be using just
$row(or$picin your code).