Hi can some one let me know what I am doing wrong in this code the first result set returned from the mysql query is working however the actual results are not being displayed properly (at all!). I seem to think it may be the for loop that is messed up... Im new to PHP and could use some help to arrive at a bit of clarity regardinf why this is failing. Any help is appreciated.
Chris
heres the code...
<script language="php">
include("../../sitedefs.phtml");
include ("requests_past24.phtml");
include ("header.html");
</Script>
<?
//inputs
// $sYear
// $sMonth
// $sDay
$search_date = $sYear . "/" . $sMonth . "/" . $sDay;
$read_date = $sMonth . "/" . $sDay . "/" . $sYear ;
$match_date = $sYear.'-'.$sMonth.'-'.'%%';
?>
<?php
// Connect to mysql---------------------------------------------------------------------
//
$conn = mysql_connect($mysql_host,$db_user,$db_pass);
mysql_select_db($mysql_database,$conn);
//---------------------------------------------------------------------------------------
// Create Your Limit and Offset for Previous/Next links
// Set the $limit and the offset will automatically do its job
if (empty($offset) || $offset < 0) {
$offset=0;
}
// Number of rows to return per page
$limit = 20;
// Create Your FULL SQL statement
$sql = "SELECT *
FROM
customer_requests
WHERE date like '$match_date' ";
// Make call to database and run the SQL statement
$sql_result = mysql_query($sql,$conn);
// Get the results from the SQL call
$rows = mysql_num_rows($sql_result);
// Calculate the Previous/Next pages from results
$begin =($offset+1);
$end = ($begin+($limit-1));
if ($end > $rows) {
$end = $rows;
}
// Display result information. Page Counts
echo "<tr><th bgcolor=#3e6fa0><font color=navy>There is <b>$rows</b> results.       Now showing results <b>$begin</b> to <b>$end<b/>.</th></table>";
// Create your SQL statement that uses the $limit and Offset features
// Generally it is the same SQL statement as the first one adding the limit
// functions on the end of the statement.
$sql2 = "SELECT name, email, event_id,call,
color_from,color_to,carat_from,
carat_to,clarity_from,clarity_to,
shape,message,request_date
FROM
customer_requests
WHERE date like '$match_date' limit $limit,$offset ";
// Make call to database and run the new SQL statement
$sql_result = mysql_query($sql2,$conn);
// Get the results from the new SQL call
$rowset = mysql_num_rows($sql_result);
// Display results from new SQL call. Use HTML as desired to display results.
echo "<table>";
echo "<table border=1 width=100%>";
echo "<tr><th bgcolor=#3e6fa0 align=left><font color=navy>Results Title</th>";
for ($j=0; $j < $rowset; $j++)
{
$event_id = mysql_result($sql_result, $j, "event_id");
$request_date = mysql_result($sql_result, $j, "request_date");
$name = mysql_result($sql_result, $j, "name");
$email = mysql_result($sql_result, $j, "email");
echo "<tr>
<td><B>event_id:  </B> $event_id<br><B>request_date:  </B>$request_date<br><B>name:  </B> $name<br><B>email:   </B>$email</td>";
}
echo "</table>";
echo "<P>";
// Begin Prev/Next Links NOTE: If you have variables that you need passed
// then make sure to pass them in the links as well in the $PHP_SELF? line
// Don't display PREV link if on first page
if ($offset!=0) {
$prevoffset=$offset-$limit;
echo "<a onMouseOver=\"window.status='Previous $limit Results'; return true\"; href=\"$PHP_SELF?offset=$prevoffset\"> <B> [Previous] </B>    </a>";
}
// Calculate total number of pages in result
$pages = intval($rows/$limit);
// $pages now contains total number of pages needed unless there is a remainder from division
if ($rows%$limit) {
// has remainder so add one page
$pages++;
}
// Now loop through the pages to create numbered links
// ex. 1 2 3 4 5 NEXT
for ($i=1;$i<=$pages;$i++) {
// Check if on current page
if (($offset/$limit) == ($i-1)) {
// $i is equal to current page, so don't display a link
echo "$i ";
} else {
// $i is NOT the current page, so display a link to page $i
$newoffset=$limit*($i-1);
echo "<a onMouseOver=\"window.status='Page $i Results'; return true\"; href=\"$PHP_SELF?offset=$newoffset\"><B> $i </B></a>\n";
}
}
// Check to see if current page is last page
if (!((($offset/$limit)+1)==$pages) && $pages!=1) {
// Not on the last page yet, so display a NEXT Link
$newoffset=$offset+$limit;
echo "<a onMouseOver=\"window.status='Next $limit Results'; return true\"; href=\"$PHP_SELF?offset=$newoffset\">    <B> [Next] </B></a><p>\n";
}
?>