RE: Looking for help with forms/variables and an array!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I had done that before,

But here it goes again because I have learned a little bit more

 

-> establish db connect

-> drop down box stores result as a variable

-> first initial query performed

-> query array established

-> drop down box 2 is saved as a variable

-> variable 2 filters query 1

-> display one record at a time

 

Here is what I have right now. It is error free, just doest work, all I have
done change some variables and not even bothering with record set 2 yet

 

Anything in bold is what I have played with since it would pull every
record, just not filter and now does not work.

 

Brad

 

 

<?php require_once('connections/ftn.php'); ?>

 

<?php

$currentPage = $_SERVER["PHP_SELF"];

 

$maxRows_Recordset1 = 1;

$pageNum_Recordset1 = 0;

if (isset($_GET['pageNum_Recordset1'])) {

  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];

}

$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

 

mysql_select_db($database_ftn, $ftn);

@extract($_POST);

$query_Recordset1 = "SELECT * FROM lstng_tbl WHERE price_range = '$state'";

$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1,
$startRow_Recordset1, $maxRows_Recordset1);

$Recordset1 = mysql_query($query_limit_Recordset1, $ftn) 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;

 

$queryString_Recordset1 = "";

if (!empty($_SERVER['QUERY_STRING'])) {

  $params = explode("&", $_SERVER['QUERY_STRING']);

  $newParams = array();

  foreach ($params as $param) {

    if (stristr($param, "pageNum_Recordset1") == false && 

        stristr($param, "totalRows_Recordset1") == false) {

      array_push($newParams, $param);

    }

  }

  if (count($newParams) != 0) {

    $queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));

  }

}

$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s",
$totalRows_Recordset1, $queryString_Recordset1);

?>

 

<body>

<form id="form1" name="form1" method="post" action="index_dev2.php">

        <label>market

           <select name="states">

                     <OPTION value="IN">Indiana</OPTION>

                     <OPTION value="WI">Wisconsin</OPTION>

                     <OPTION value="IL">Illinois</OPTION>

                     <OPTION value="MI">Michigan</OPTION>

                     <OPTION value="GA">Georgia</OPTION>

                     <OPTION value="FL">Florida</OPTION>

                     </select>

        </label>

   </form>

<?php 

  if ($states=="value" || !isset($states)) echo "selected"; 

?>

            <br>

<form id="form2" name="form2" method="post" action="index_dev2.php">

        <label>price_range

            <select name="price">

                     <OPTION value="1">Over $2 million</OPTION>

                     <OPTION value="2">$1 million - $2 million</OPTION>

                     <OPTION value="3">$750,000 - $1 million</OPTION>

                     <OPTION value="4">under $750,000</OPTION>

              </select>

         <input name="submit" type="submit" value="post"/>

         </label>

 </form>

<?php 

  if ($price=="value"|| !isset($price)) echo "selected"; 

?>

 

  <?php do { ?>

 

-----Original Message-----
From: Jim Lucas [mailto:lists@xxxxxxxxx] 
Sent: Tuesday, June 12, 2007 8:26 PM
To: BSumrall
Cc: php-general@xxxxxxxxxxxxx
Subject: Re:  Looking for help with forms/variables and an array!

 

Are you wanting to setup some sorta pagination, or just get the results from
the DB limited by the 

selected option in the form?

 

oh, where is your second form in this example?

 

In pseudo code, write out what you are attempting to do?

 

 

-- 

Jim Lucas

 

    "Some men are born to greatness, some achieve greatness,

        and some have greatness thrust upon them."

 

Twelfth Night, Act II, Scene V

     by William Shakespeare

 


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux