possible PHP coding error, need help please!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dr002000
Forum Newbie
Posts: 2
Joined: Tue May 09, 2006 7:53 am

possible PHP coding error, need help please!

Post 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]
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

What error are you getting? What is it doing?
dr002000
Forum Newbie
Posts: 2
Joined: Tue May 09, 2006 7:53 am

error

Post by dr002000 »

it loads the records from my database and posts them all instead of just the values selected in my search form.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Hint: search terms "Pagination" or "LIMIT clause".
Post Reply