Hi,
I'm using php4 and apache 2. I need to display additional information in a seperate window according to a fieldset that is selected from a table. I was thinking of using session variables(as below) but it either repeats one of the fieldsets repeatedly or shows the same info no matter what link image(which is the link to data.php) I click on.
I also had to paginate my results which is where I think the problems are coming in.
The 2 php pages (view.php and data.php) are below.
Any ideas?
**************************************************
VIEW.PHP
**************************************************
<?
session_start();
define(MAX_DISPLAY, 2);
$link = mysql_connect("localhost", "", ""
or die("Could not connect : " . mysql_error());
mysql_select_db("online"
or die("Could not select database"
;
printf("<br>Row Start: %d Next Row: %d<br><br>\n", $_GET[page], $_GET[page]+MAX_DISPLAY);
if(!$_GET[page]) {
printf("<a href='view.php?page=%s'>Prev Page</a> ", $prevpage);
printf("<a href='view.php?page=%s'>Next Page<br><br></a>", ($_GET[page] + MAX_DISPLAY));
$query = "select cat, sub, vname, vtel, vaddress, vote, specials, picture, pictureb from place limit ".MAX_DISPLAY."";
} else {
$query = "select cat, sub, vname, vtel, vaddress, vote, specials, picture, pictureb from place limit ".($_GET[page] - 1).",".MAX_DISPLAY."";
$prevpage = ($_GET[page] - MAX_DISPLAY);
$_GET[page] = ($_GET[page] + MAX_DISPLAY);
printf("<a href='view.php?page=%s'>Prev Page</a> ", $prevpage);
printf("<a href='view.php?page=%s'>Next Page</a><br><br>", $_GET[page]);
}
$result = mysql_query($query)
or die("Could not complete query : " . mysql_error());
if(!$result) {
printf("No entries found.\n"
;
exit;
}
print "<table border=1><tr><th>Picture</th>";
print "<th>Name</th><th>Category</th><th>sub</th><th>Specials</th><th>Address</th><th>Telephone</th><th>Vote Page</th></tr>";
// go through each row in the result set and display data
while ($newArray = mysql_fetch_array($result)) {
// give a name to the fields
$cat = $newArray['cat'];
$sub = $newArray['sub'];
$vname = $newArray['vname'];
$vtel = $newArray['vtel'];
$vaddress = $newArray['vaddress'];
$vote = $newArray['vote'];
$specials = $newArray['specials'];
$picture = $newArray['picture'];
$pictureb = $newArray['pictureb'];
//these are the session variables
$_SESSION[specials] = mysql_result($result, 0, 'specials');
$_SESSION[picture] = mysql_result($result, 0, 'picture');
//echo the results on screen
echo "
<tr>
<td align=\"center\"><a href=\"data.php\" target=\"blank\"><img border=\"0\" src=\"$picture\"></a></td>
<td>$vname</td>
<td>$cat</td>
<td>$sub</td>
<td>The current specials are $specials.</td>
<td>We are situated at $vaddress</td>
<td>and you can get hold of us on $vtel.</td>
<td> <a href=\"$vote\" target=\"blank\">Vote for us.</a></td>
</tr>";
//if authorized, get the values of f_name l_name and other details
$cat = mysql_result($result, 0, 'cat');
$picture = mysql_result($result, 0, 'picture');
//these are the session variables
$_SESSION
= mysql_result($result, 0, 'cat');
$_SESSION[picture] = mysql_result($result, 0, 'picture');
}
print "</table>";
mysql_free_result($result);
mysql_close($link);
?>
*********************************************
DATA.PHP
**********************************************
Reality is built on a foundation of dreams.
I'm using php4 and apache 2. I need to display additional information in a seperate window according to a fieldset that is selected from a table. I was thinking of using session variables(as below) but it either repeats one of the fieldsets repeatedly or shows the same info no matter what link image(which is the link to data.php) I click on.
I also had to paginate my results which is where I think the problems are coming in.
The 2 php pages (view.php and data.php) are below.
Any ideas?
**************************************************
VIEW.PHP
**************************************************
<?
session_start();
define(MAX_DISPLAY, 2);
$link = mysql_connect("localhost", "", ""

or die("Could not connect : " . mysql_error());
mysql_select_db("online"

or die("Could not select database"

printf("<br>Row Start: %d Next Row: %d<br><br>\n", $_GET[page], $_GET[page]+MAX_DISPLAY);
if(!$_GET[page]) {
printf("<a href='view.php?page=%s'>Prev Page</a> ", $prevpage);
printf("<a href='view.php?page=%s'>Next Page<br><br></a>", ($_GET[page] + MAX_DISPLAY));
$query = "select cat, sub, vname, vtel, vaddress, vote, specials, picture, pictureb from place limit ".MAX_DISPLAY."";
} else {
$query = "select cat, sub, vname, vtel, vaddress, vote, specials, picture, pictureb from place limit ".($_GET[page] - 1).",".MAX_DISPLAY."";
$prevpage = ($_GET[page] - MAX_DISPLAY);
$_GET[page] = ($_GET[page] + MAX_DISPLAY);
printf("<a href='view.php?page=%s'>Prev Page</a> ", $prevpage);
printf("<a href='view.php?page=%s'>Next Page</a><br><br>", $_GET[page]);
}
$result = mysql_query($query)
or die("Could not complete query : " . mysql_error());
if(!$result) {
printf("No entries found.\n"

exit;
}
print "<table border=1><tr><th>Picture</th>";
print "<th>Name</th><th>Category</th><th>sub</th><th>Specials</th><th>Address</th><th>Telephone</th><th>Vote Page</th></tr>";
// go through each row in the result set and display data
while ($newArray = mysql_fetch_array($result)) {
// give a name to the fields
$cat = $newArray['cat'];
$sub = $newArray['sub'];
$vname = $newArray['vname'];
$vtel = $newArray['vtel'];
$vaddress = $newArray['vaddress'];
$vote = $newArray['vote'];
$specials = $newArray['specials'];
$picture = $newArray['picture'];
$pictureb = $newArray['pictureb'];
//these are the session variables
$_SESSION[specials] = mysql_result($result, 0, 'specials');
$_SESSION[picture] = mysql_result($result, 0, 'picture');
//echo the results on screen
echo "
<tr>
<td align=\"center\"><a href=\"data.php\" target=\"blank\"><img border=\"0\" src=\"$picture\"></a></td>
<td>$vname</td>
<td>$cat</td>
<td>$sub</td>
<td>The current specials are $specials.</td>
<td>We are situated at $vaddress</td>
<td>and you can get hold of us on $vtel.</td>
<td> <a href=\"$vote\" target=\"blank\">Vote for us.</a></td>
</tr>";
//if authorized, get the values of f_name l_name and other details
$cat = mysql_result($result, 0, 'cat');
$picture = mysql_result($result, 0, 'picture');
//these are the session variables
$_SESSION
![[cat] [cat] [cat]](/data/assets/smilies/cat.gif)
$_SESSION[picture] = mysql_result($result, 0, 'picture');
}
print "</table>";
mysql_free_result($result);
mysql_close($link);
?>
*********************************************
DATA.PHP
**********************************************
Reality is built on a foundation of dreams.