Hi Good people of PHPBuilder...

I have a tiny issue and am seeking help/assistance...

I am building a website in which a person can search a database for location and language... The HTML Form is:

<form name="hotelSearch" action="hotelSearchRes1.php" method="post">
    Search for language 	<select name="hotelLang">
                            <option value="English">English</option>
                            <option value="French">French</option>
                            <option value="German">German</option>
                            </select>
                            <select name="hotelLoc">
                            <option value="Galway">Galway</option>
                            <option value="Sligo">Sligo</option>
                            <option value="Mayo">Mayo</option>
                            <input name="Submit" type="submit" value="Submit" />
   </form>

So hotelLang is language, hotelLoc is location.

I have sent this to a new page and created a recordset to check the database. This is going good if I want to search for just 1 item. But I am looking for 2.. I have tried to alter the MySQL to search for 2, but to no avail... My PHP/SQL code generated by Dreamweaver is:

$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

$colname_Recordset1 = "-1";
if (isset($_POST['hotelLang'])) {
  $colname_Recordset1 = $_POST['hotelLang'];
  $loc = $_POST['hotelLoc']; [B]<------- I have made loc to be filled with the posting from the location of the form[/B]
}
mysql_select_db($database_mainConn, $mainConn);
$query_Recordset1 = sprintf("SELECT * FROM hotel WHERE hotelLang = %s", GetSQLValueString($colname_Recordset1, "text"));
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $mainConn) 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;
?> 

Any guidance is greatly appreciated..... PEACE

PoppaFluff

    17 days later

    PoppaFluff,

    The code generated by Dreamweaver is incomplete.

    I have come up with a start for you..

    $maxRows_Recordset1 = 10;
    $pageNum_Recordset1 = 0;
    
    if (isset($_GET['pageNum_Recordset1'])) {
      $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
    }
    
    $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
    
    $colname_Recordset1 = "-1";
    if (isset($_POST['hotelLang'])) {
      $colname_Recordset1 = $_POST['hotelLang'];
      $loc = $_POST['hotelLoc']; <------- I have made loc to be filled with the posting from the location of the form
    }
    
    mysql_select_db($database_mainConn, $mainConn);
    $query_Recordset1 = sprintf("SELECT * FROM hotel WHERE hotelLang = %s OR hotelLoc = %s", GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($loc, "text")  );
    $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
    $Recordset1 = mysql_query($query_limit_Recordset1, $mainConn) 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;
    ?>
    

    What you need to look at is sprintf to see how it works.

    I would also recommend you follow some of the many tutorials available on the internet to write your own code versus using anything from Dreamweaver.

    Best of luck

      Write a Reply...