Hello,
I have following problem:
I try to retrieve images from mysql and show it.
I retrieve them in loop using getData.php.
getData.php uses session variable ($_SESSION['num']) to get image.
However $_SESSION['num'] seems to be always 0.
why?
//showAll.php
<?php
session_start();
$num=0;
session_register('num');
?>
<html>
<head><title>Show data from SQL Database</title></head>
<body>
<?php
MYSQL_CONNECT("localhost","root","pw");
mysql_select_db("database");
$sql = "SELECT count(id) FROM store;";
$result = MYSQL_QUERY($sql);
$count = MYSQL_RESULT($result,0,"count(id)");
//-------------------------------------------------------------------
//here is loop where $_SESSION['num'] is set and getData.php called
while($count >1) {
$_SESSION['num']=$count--;
echo $_SESSION['num'];
?>
<IMG SRC="getData.php">
<?php
}
//-------------------------------------------------------------------
?>
</body>
</html>
//-------------------------------------------------------------------
//getData.php
<?php
session_start();
if(isset($_SESSION['num'])) {
@MYSQL_CONNECT("localhost","root","pw");
@mysql_select_db("database");
$num=$_SESSION['num'];
$query = "select FileData,filetype from store where id=$num";
$result = @MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0,"FileData");
$type = @MYSQL_RESULT($result,0,"filetype");
Header( "Content-type: $type");
echo $data;
}
?>