Maybe I'm missing, maybe its not there. But for each image there is a caption, I am trying to pull the caption but I can't seem to figure out why I keep getting Resource id #8 or S instead of the caption. Here is my full php code.
<?php
//Get the numeration of the page
$num = $_GET['page'];
//if the numeration is empty
if(empty($num)){
//the numeration is 1
$num = 1;
};
//Sets the limit of results to display in each page, change if you want.
$limit = 8;
/*
The query will start selecting the numeration, for example 2, less 1, that would be 1
* the limits of results to show per page, 2 in this case so it would be 1*2 = 2, it will
start from 2 ;) if the limit would be 5 and the numeration would be 3 if would be (3-1)*5 = 10
*/
$start = ($num-1)*$limit;
//rounds the result
$start = round($start,0);
/*
This query will select the contrene FROM the start and with a limit of 2, in this case,
because the variable $limit is 2
You can add a WHERE something= '$something' for example, or delete the ORDER by `id`, or change it,
etc
*/
$sql = "SELECT imgid,imgtype,caption FROM tblimage ORDER BY imgid LIMIT $start, $limit";
//now it makes the query and names it as result2
$result2 = mysql_query($sql);
/*
While will repeat this query and mysql_fect_array allow me array the content
*/
while ($r = mysql_query($result2)){
echo "$r[title]<br>";
};
//Get the total number of results
$totalpages = mysql_num_rows(mysql_query("SELECT * from `tblimage`"));
/*
Total resutls/ the limit, in this example is 2, so if there are 10 total result and the limit is 2
there will be 5 pages.
*/
$totalpages = $totalpages / $limit;
$totalpages = ceil($totalpages);
//The variable c is 0
$c = 0;
//while c is < than the total pages
while($c<$totalpages){
//sets the variable $page as 0 + 1 = 1
$page = $c + 1;
//Gets the number of the page and if its the same that the page
if($_GET['num']==$page){
//its only echoes the page, not the url to this page
echo "[$page] ";
}else{
//it echoes the url to the page
echo "<a href=\"?page=$page\">[$page]</a> ";
}
$c = $c+1;
}
// We want three columns:
$display_columns = 4;
// We do the query, and find out how many items we'll need to list.
$result = mysql_query($sql);
$count = mysql_num_rows($result);
// We have enough to figure out how many empty spaces there'll be left at
// the bottom of the table.
$padding = ($display_columns-1)-(($count-1)%$display_columns);
// We also know enough to know how many rows there'll be, but I for one
// don't really care about that right now.
echo '<table border=0 cellpadding=1 cellspacing=1>';
// Let's begin our loop.
for($i=0; $i<$count; $i++)
{
// Whenever $i is a multiple of $display_columns (including 0),
// it's a sign that we're hitting the start of a new row.
if($i%$display_columns == 0)
echo '<tr>';
//Now for an item.
echo '<td>';
$imgid = mysql_result($result, $i, 0);
echo '<a href="post.php?imgid='.$imgid.'" target=_blank><img src="post.php?imgid='.$imgid.'" width=150 border=0></a><br />';
echo '</td>';
//Whenever $i is one less than a multiple of $display_columns,
// it's a sign that we're hitting the end of the current row.
if($i%$display_columns == $display_columns-1)
echo '</tr>';
}
// That's all the items done; now we just need to pad the table out and
// wrap up. We don't need to pad at all if $padding is zero.
if($padding!=0)
{ for($i=0;$i<$padding;$i++)
echo '<td></td>';
echo '</tr>';
}
echo '<tr><td valign=top width=100% colspan=4 align=left><a href=add.php>Add Screenshot</a></td></tr>';
echo '</table>';
?>
After the following line is where the caption is to be placed:
echo '<a href="post.php?imgid='.$imgid.'" target=_blank><img src="post.php?imgid='.$imgid.'" width=150 border=0></a><br />';
Any advice or suggestions much appreciated.