Hope somebody can help me with some bugs in my php scripts !
firstly, there is a master-detail relationship between two scripts namely "Event.php" and "eventDetails.php".
I have three problems with these scripts:
The pagination script "Events.php" calculates the correct amount of pages etc and used to work, however now it does not allow me to navigate between pages ! I may have changed something in the code or the php.ini file or something, I just don't know how to get it working again.
"eventDetails.php" is supposed to work by running an SQL query using the 'eventID' which is passed from a hidden field field on the "Event.php" script. Basically, there is no value being passed between the two pages. This is also happening on some other scripts I have that do SQL inserts into the database. End result, nothing is posted to the database. In a nutshell I am having problems passing values between scripts !
Assigning values to hidden fields or something.
There are two 'if statements' in "eventDetails.php" (lines 45 and 46) that do not work ?
I hope someone can help me with these problems because they are driving me crazy.
Scripts below, they are lengthy so you might need to cut and paste into Dreamweaver to work on.
Script 2 to follow - ran out of word count
##########################################
<?php //Events.php script
require "dbase.php";
$dbcon=new db();
$dbcon->getConnection();
if (!($limit)){
$limit = 6;}
if (!($page)){
$page = 0;}
$numresults = $dbcon->getResultOf("SELECT event_tickets_booked, event_max_booking, eventID, event_name, event_start_date, event_venue, event_comments, event_town
FROM tblevents
WHERE event_expired = 'N'"); //and county = ''
$numrows = mysql_num_rows($numresults);
if ($numrows == 0){
echo("No results found matching your query - $query");
exit();}
$pages = $numrows/$limit;
// $pages now contains int of pages, unless there is a remainder from division.
if ($numrows%$limit) {
$pages++;} // has remainder so add one page
$current = intval($page/$limit) + 1; // Current page number.
if (($pages < 1) || ($pages == 0)) {
$total = 1;} // If $pages is less than one or equal to 0, total pages is 1.
else {
$total = $pages;} // Else total pages is $pages value.
$first = $page + 1; // The first result.
if (!((($page + $limit) / $limit) >= $pages) && $pages != 1) {
$last = $page + $limit;} //If not last results page, last result equals $page plus $limit.
else{
$last = $numrows;} // If last results page, last result equals total number of results.
?>
<html>
<head>
<title>Search Results for <?=$query?></title>
<style type="text/css">
<!--
.style1 {font-size: 18px}
-->
</style>
</head>
<body>
<center>
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="171"><span class="style1" style="font-size: 18px;"><span class="style1" style="font-size: 18px;">
<?
if ($page != 0) { // Don't show back link if current page is first page.
$back_page = $page - $limit;
echo("<a href=\"$PHP_SELF?query=$query&page=$back_page&limit=$limit\">back</a> \n");}
for ($i=1; $i <= $pages; $i++) // loop through each page and give link to it.
{
$ppage = $limit*($i - 1);
if ($ppage == $page){
echo("<b>$i</b> \n");} // If current page don't give link, just text.
else{
echo("<a href=\"$PHP_SELF?query=$query&page=$ppage&limit=$limit\">$i</a> \n");}
}
if (!((($page+$limit) / $limit) >= $pages) && $pages != 1) { // If last page don't give next link.
$next_page = $page + $limit;
echo("<a href=\"$PHP_SELF?query=$query&page=$next_page&limit=$limit\">next</a>\n");}
?>
</span>
</span></td>
<td width="329"><span class="style1" style="font-size: 18px;">Events</span><span class="style1"> for</span>
<?=$query?></td>
</tr>
</table>
</center>
<table width="100%" border="0">
<tr>
<td width="50%" align="left">Results <b>
<?=$first?>
</b> - <b>
<?=$last?>
</b> of <b>
<?=$numrows?>
</b>
</td>
<td width="50%" align="right">
Page <b><?=$current?></b> of <b><?=$total?></b>
</td>
</tr>
<tr>
<td colspan="2" align="right">
</td>
</tr>
</table>
<?
// Now we can display results.
$results = $dbcon->getResultOf("SELECT event_tickets_booked, event_max_booking, eventID, event_name, event_start_date, event_venue, event_comments, event_town
FROM tblevents
WHERE event_expired = 'N'
ORDER BY eventID ASC
LIMIT $page, $limit"); //and event_county = %s
//<?php if($data['event_tickets_booked']==$data['event_max_booking'])
//{
//echo trim($data['event_name']);
//echo " This show is fully booked";
//echo "<img src=\"booked.gif\" alt=\"This show is fully booked\" width=\"20\" height=\"20\">\n";
// }
//else
// {
while ($data = mysql_fetch_array($results))
{
?>
<tr>
<td colspan="2" align="right"><div align="left">
<p><small><a href="../frmEventDetails.php"> <?php echo trim($data['event_name']); ?> </a>
<br>
<font face="Arial">
<label></label>
<?php echo stripslashes($data['eventID']); ?> <br>
<font color='#0066CC'>Venue </font>
<label></label>
<span style="color: #000000"><?php echo stripslashes($data['event_venue']); ?></span><font color='#0066CC'> Address
<label></label>
</font><?php echo stripslashes($data['event_town']); ?> <br>
<font color='#0066CC'>Comments </font>
<label><span style="color: #000000"><?php echo stripslashes($data['event_comments']); ?></span></label>
</font></small> </p>
<form name="form2" method="post" action="../frmEventDetails.php">
<input name="ID" type="hidden" id="ID" value="<?php echo stripslashes($data['eventID']); ?>">
</form>
<small><font face="Arial"><label></label>
</font></small></div></td>
</tr>
<?
}
?>
<p><span class="style1" style="font-size: 18px;">
</span></p>
<p> </p>
<p align="center"> </p>
</body>
</html>