I need a little help with some coding. I have a page named index.php and a picture.php.
index.php
$pid = 0;
for($ctr = 1; $ctr <= 2; $ctr++)
{
echo '<tr>';
$pid++;
echo '<td>';
echo '<a id="various3" href="picture.php" title="try" idno="5"><img src="picture.php" width="150" height="210">';
//echo '<br>'.$pagenm;
echo '</td>';
echo '</td>';
echo '</tr>';
}
After $pid++ is executed, I want its value to be sent to picture.php, so that it can be used for a retrieving query.
picture.php
$host = 'localhost';
$user = 'root';
$pw = '';
$db = 'thepillar';
mysql_connect($host, $user, $pw);
mysql_select_db($db);
$sql = "select pics, ext from infopics where id='5'";
// mysql_real_escape_string($sql, mysql_connect);
$result = mysql_query($sql) or die('Bad query at 12!' . mysql_error());
while ( $row = mysql_fetch_array($result, MYSQL_ASSOC) ) {
$db_img = $row['pics'];
$type = $row['ext'];
}
$img = base64_decode($db_img); // print_r($db_img );
$img = imagecreatefromstring($img);
header("Content-Type: image/jpeg");
imagejpeg($img);
imagedestroy($img);
I have only assigned 5 as the id to be used to retrieve the image from the database. This is because I don't know how to fetch $pid from index.php and assign it to a variable which I can use in my SQL query.
Any help would be much appreciated. Thanks in advance.