Page 1 of 1

possible PHP coding error, need help please!

Posted: Tue May 09, 2006 10:27 pm
by dr002000
hi i am doing a project and have written a PHP code to access a mySQL database, however i am having problems with being able to get a html search form to query the mySQL database. here is my PHP file code:

Code: Select all

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_Listings = "***DON'T SHOW US YOUR LOGIN INFORMATION SILLY***";
$database_Listings = "***DON'T SHOW US YOUR LOGIN INFORMATION SILLY***";
$username_Listings = "***DON'T SHOW US YOUR LOGIN INFORMATION SILLY***";
$password_Listings = "***DON'T SHOW US YOUR LOGIN INFORMATION SILLY***";
$Listings = mysql_pconnect($hostname_Listings, $username_Listings, $password_Listings) or trigger_error(mysql_error(),E_USER_ERROR);
?>
<?php
$maxRows_Recordset1 = 20;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_Listings, $Listings);
$query_Recordset1 = "SELECT * FROM listings ";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $Listings) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
  $all_Recordset1 = mysql_query($query_Recordset1);
  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<table border="1">
  <tr>
    <td>Ad Number</td>
    <td>Resort</td>
    <td>City</td>
    <td>State</td>
    <td>Country</td>
    <td>Bedrooms</td>
    <td>Bathrooms</td>
    <td>Week#</td>
    <td>Lockout</td>
    <td>Price</td>
  </tr>
  <?php do { ?>
    <tr>
      <td><?php echo $row_Recordset1['Ad Number']; ?></td>
      <td><?php echo $row_Recordset1['Resort']; ?></td>
      <td><?php echo $row_Recordset1['City']; ?></td>
      <td><?php echo $row_Recordset1['State']; ?></td>
      <td><?php echo $row_Recordset1['Country']; ?></td>
      <td><?php echo $row_Recordset1['Bedrooms']; ?></td>
      <td><?php echo $row_Recordset1['Bathrooms']; ?></td>
      <td><?php echo $row_Recordset1['Week#']; ?></td>
      <td><?php echo $row_Recordset1['Lockout']; ?></td>
      <td><?php echo $row_Recordset1['Price']; ?></td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
if anyone out there could help me out with getting this to work, i would really appreciate it. Thanks, Henry

Burrito: Please use

Code: Select all

tags when [url=http://forums.devnetwork.net/viewtopic.php?t=21171]posting code in the forum[/url].[/size]

Posted: Tue May 09, 2006 10:51 pm
by hawleyjr
What error are you getting? What is it doing?

error

Posted: Tue May 09, 2006 11:00 pm
by dr002000
it loads the records from my database and posts them all instead of just the values selected in my search form.

Posted: Tue May 09, 2006 11:59 pm
by John Cartwright
Hint: search terms "Pagination" or "LIMIT clause".