Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Recordset Navigation Bar - displaying blank records at the end (displaying for records which don't exist). Why?

Avatar of Adam
AdamFlag for United Kingdom of Great Britain and Northern Ireland asked on
HTMLPHPAdobe Dreamweaver
9 Comments1 Solution322 ViewsLast Modified:
Dear Experts,

I have a set up which is basically a search - master - detail record set.
After a search, master information is displayed in the form of small subprofiles (which is essentially a repeating DIV tag displaying 22 'mini profiles' (detail divs) per page.

For an example of the page, see here:

http://www.orangutanjapan.com/newsearch/expertssetup17.php?pageNum_m=0&totalRows_m=2058&language=&prefecture=&Submit=%92T%82%B7

A problem I've noticed however is that when I navigate to the last entry - the last entry displays a DIV tag with no associated field, and then pushing the previous arrow again reveals another blank dataset (i.e the miniprofile has no entries - no photo, no name etc). Also, the nav bar seems to list
profiles beyond the available no of profiles - i.e. displaying records where records don't exist

Teacher 2069 to 2058 of 2058 (no records)

Teacher 2091 to 2058 of 2058 (no records)

Again, this will make more sense if you see for yourself.

At the following page:

http://www.orangutanjapan.com/newsearch/expertssetup17.php?pageNum_m=0&totalRows_m=2058&language=&prefecture=&Submit=%92T%82%B7

If you scroll to the botton of the page and select the last arrows you will see the problem (Teacher 2091 to 2058 of 2058).
The press the back button (Teacher 2069 to 2058 of 2058 ).


I'm not sure what the cause of this could be. Any help finding the solution would be great.

Many Thanks.

I have attached what I guess is the relevant code below. Please let me know if you require to see more.
?php require_once('../Connections/a.php'); ?><?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}


$colname_member = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_member = $_SESSION['MM_Username'];
}
mysql_select_db($database_a, $a);
$query_member = sprintf("SELECT autonum, firstname, famname, password, compemail FROM students WHERE compemail = %s", GetSQLValueString($colname_member, "text"));
$member = mysql_query($query_member, $a) or die(mysql_error());
$row_member = mysql_fetch_assoc($member);
$totalRows_member = mysql_num_rows($member);

$maxRows_m = 22;
$pageNum_m = 0;
if (isset($_GET['pageNum_m'])) {
  $pageNum_m = $_GET['pageNum_m'];
}
$startRow_m = $pageNum_m * $maxRows_m;
 
$query_m = "SELECT autonumber, photoid, date_format(date, '%d %M %Y') as date, password, photo, imagelocation, video, vid, sex, firstname, fullname, age, nationality, `language`, OthLanguage, teachingexperience, LangSchls, LangQual, qualifications, prefecture, private_price, teflconfirm, expconfirm, degreeconfirm FROM TestTable  
     WHERE TestTable.language LIKE '%" . $_REQUEST["language"] . "%' 
     AND TestTable.prefecture LIKE '%" . $_REQUEST["prefecture"] . "%' 
     ";

$query_limit_m = sprintf("%s LIMIT %d, %d", $query_m, $startRow_m, $maxRows_m);
$m = mysql_query($query_limit_m, $a) or die(mysql_error());
$row_m = mysql_fetch_assoc($m);
 
if (isset($_GET['totalRows_m'])) {
  $totalRows_m = $_GET['totalRows_m'];
} else {
  $all_m = mysql_query($query_m);
  $totalRows_m = mysql_num_rows($all_m);
}
$totalPages_m = ceil( ( $totalRows_m + $maxRows_m -1) / $maxRows_m);
 
$queryString_m = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_m") == false && 
        stristr($param, "totalRows_m") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_m = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_m = sprintf("&totalRows_m=%d%s", $totalRows_m, $queryString_m); 


?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

... and then....

...
<div class="footersearch" id="apDiv1">
    <table border="0">
      <tr>
        <td width="71"><div align="center">
            <?php if ($pageNum_m > 0) { // Show if not first page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, 0, $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OFirst.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not first page ?>
        </div></td>
        <td width="76"><div align="center">
            <?php if ($pageNum_m > 0) { // Show if not first page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, max(0, $pageNum_m - 1), $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OPrevious.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not first page ?>
        </div></td>
        <td width="440" align="right" valign="middle">&nbsp;
            Teacher <em><?php echo ($startRow_m + 1) ?></em> to <em><?php echo min($startRow_m + $maxRows_m, $totalRows_m) ?></em> of <span class="style10"><?php echo $totalRows_m ?></span> </td>
        <td width="57"><div align="center">
            <?php if ($pageNum_m < $totalPages_m) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, min($totalPages_m, $pageNum_m + 1), $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/ONext.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not last page ?>
        </div></td>
        <td width="67"><div align="center">
            <?php if ($pageNum_m < $totalPages_m) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, $totalPages_m, $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OLast.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not last page ?>
        </div></td>
      </tr>
    </table>
  </div>
  </div>
 
<div id="content">
 
 <?php if ($totalRows_m == 0) { // Show if recordset empty ?>
     <img src="../newsearch/noteachers.gif" width="133" height="29" />
     <?php } // Show if recordset empty ?>  <br>

  <?php if ($totalRows_m > 0) { // Show if recordset not empty ?>
 
 
 
  <?php do { ?>
  <div class="profilebox">
  <div class="profileheader"><div id="apDiv3">
    <div align="left"><img src="http://www.orangutanjapan.com/newsearch/flags/<?php echo $row_m['nationality'] ?>flag.gif" alt="teacher's nationality" width="46" height="33" class="flagposition" /></div>
  </div>
  <span class="largeheader"></span><?php echo $row_m['firstname']; ?><br />
    <span class="smallheader">Profile added / updated:
    <span class="style12"><?php echo $row_m['date']; ?></span></span>    </div>
  <a href="Ddetails.php?pageNum_m=<?php echo $_GET['pageNum_m']; ?>&amp;language=<?php echo $_GET['language'] ?>&amp;prefecture=<?php echo $_GET['prefecture'] ?>&amp;recordID=<?php echo $row_m['autonumber']; ?>&amp;"><img src="http://orangutanenglish.com/upload/<?php echo $row_m['photoid']; ?>" width="136" height="116" class="imageclass" /></a><span class="boxtext">&nbsp;<span class="style14">&nbsp;Nationality:</span>&nbsp; <?php echo $row_m['nationality']; ?><br />
  <span class="AccordionPanelTabHover">&nbsp;&nbsp;<span class="style14">Language:</span></span> &nbsp;&nbsp;<?php echo $row_m['language']; ?><br />
  &nbsp;<span class="style14">&nbsp;Teach Ex: </span>&nbsp;&nbsp;&nbsp;<?php echo $row_m['teachingexperience']; ?><br />
  <span class="style14">&nbsp;&nbsp;Prefecture:</span> <?php echo $row_m['prefecture']; ?><br />
  <span class="style15">&nbsp;&nbsp;<br />
  &nbsp;&nbsp;<? $img1=($row_m['vid'])? "<img src=\"videoimage.gif\" alt=\"This teacher has video in their profile\" width=\"41\" height=\"20\" />" : "";  echo $img1; ?></span><br />
  </span>
  <p align="left">&nbsp;
    &nbsp;&nbsp;&nbsp;</p>
  <table width="334" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="132" height="33">
      
      
   <img src="../newsearch/mail.gif" alt="Email Teacher" width="50" height="45" />
   <input name="favs" type="image" id="favs" src="favourites.gif" />
   <br />
      
           
      </td>
      <td width="202"><div align="right">
        <?php
$DbImg = $row_m['expconfirm'] ;
if ($DbImg =="expconfirm") {  
    $altText = "Teaching Experience";
}
else {
   $altText = "No Teaching Experience";
}
?>
        <img src="http://www.orangutanjapan.com/newsearch/icons/<?php echo $DbImg ?>icon.gif" alt="<?php echo $altText ?>" width="45" height="45" /><?php
$DbImg = $row_m['teflconfirm'] ;
if ($DbImg =="yest") {  
    $altText = "TEFL Certified";
}
else {
   $altText = "Not TEFL Certifed";
}
?>
        <img src="http://www.orangutanjapan.com/newsearch/icons/<?php echo $DbImg ?>icon.gif" alt="<?php echo $altText ?>" width="45" height="45" /><?php
$DbImg = $row_m['degreeconfirm'] ;
if ($DbImg =="yesd") {  
    $altText = "University Graduate Degree";
}

elseif ($DbImg =="studying") {  
    $altText = "Currently Studying";
}

else {
   $altText = "No University Degree";
}
?>
        <img src="http://www.orangutanjapan.com/newsearch/icons/<?php echo $DbImg ?>icon.gif" alt="<?php echo $altText ?>" width="45" height="45" /> </div></td>
    </tr>
  </table>
  <p align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
  </div>
 
    
  	<?php } while ($row_m = mysql_fetch_assoc($m)); ?>
  	<br style="clear:both;" />
    
    <?php } // Show if recordset not empty ?>
    
    
  <div class="footersearch" id="footersearch">
      <div align="center">
  <table border="0">
    <tr>
      <td width="71"><div align="center">
        <?php if ($pageNum_m > 0) { // Show if not first page ?>
          <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, 0, $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OFirst.gif" border="0" class="footersearch" /></a>
          <?php } // Show if not first page ?>
        </div></td>
        
        
        <td width="76"><div align="center">
          <?php if ($pageNum_m > 0) { // Show if not first page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, max(0, $pageNum_m - 1), $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OPrevious.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not first page ?>
          </div></td>
        <td width="440" align="center" valign="middle">&nbsp;          <div align="center">Teacher <em><?php echo ($startRow_m + 1) ?></em> to <em><?php echo min($startRow_m + $maxRows_m, $totalRows_m) ?></em> of <span class="style10"><?php echo $totalRows_m ?></span> </div></td>
        <td width="57" align="center" valign="middle"><div align="center">
          <?php if ($pageNum_m < $totalPages_m) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, min($totalPages_m, $pageNum_m + 1), $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/ONext.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not last page ?>
          </div></td>
          
          
        <td width="67"><div align="center">
          <?php if ($pageNum_m < $totalPages_m) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_m=%d%s", $currentPage, $totalPages_m, $queryString_m); ?>"><img src="../graphics/Words/find a teacher/logosandbanners/arrows/OLast.gif" border="0" class="footersearch" /></a>
            <?php } // Show if not last page ?>
          </div></td>
          
          
      </tr>
  </table>
  <br />
        <br />
      </div>
  	</div>
ASKER CERTIFIED SOLUTION
Avatar of István Nagy
István NagyFlag of Romania imageSenior Systems Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answers