1 Reply Latest reply on Nov 23, 2009 4:45 PM by Günter Schenk

    [locked] PHP repeat region only showing first record

    JoeSmoe_03

      Hello,


      So I am trying to get dreamweaver to show all the returned records from my sql query but it only shows the first record even though $totalrows_rs_WineNotes shows up as more.

      Here is what the code looks like:

       

      <?php require_once('../Connections/PF_WINE.php'); ?>
      
      <?php
      $Vintage = $_POST['Vintage'];
      ?>
      
      <?php
      if (!function_exists("GetSQLValueString")) {
      function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
      {
        if (PHP_VERSION < 6) {
          $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;
      }
      }
      
      
      $Vintage_rs_WineNotes = "0";
      if (isset($Vintage)) {
        $Vintage_rs_WineNotes = $Vintage;
      }
      mysql_select_db($database_PF_WINE, $PF_WINE);
      $query_rs_WineNotes = sprintf("SELECT * FROM WINE WHERE WINE.WINE_VINTAGE = %s", GetSQLValueString($Vintage_rs_WineNotes, "int"));
      $rs_WineNotes = mysql_query($query_rs_WineNotes, $PF_WINE) or die(mysql_error());
      $row_rs_WineNotes = mysql_fetch_assoc($rs_WineNotes);
      $totalRows_rs_WineNotes = mysql_num_rows($rs_WineNotes);
      
      
      mysql_free_result($rs_WineNotes);
      ?>
      
      <?php echo $totalRows_rs_WineNotes ?>
      <p></p>
      
      <?php do { ?>
        <hr />
        <p><?php echo $row_rs_WineNotes['WINE_VINTAGE']; ?></p>
        <p><?php echo $row_rs_WineNotes['WINE_PRICE_RANGE']; ?></p>
        <p><?php echo $row_rs_WineNotes['WINE_ID']; ?></p>
      <p><?php echo $row_rs_WineNotes['VARIETAL_TYPE_ID']; ?></p>
        <?php } while ($row_rs_WineNotes = mysql_fetch_assoc($rs_WineNotes)); ?>