Jump to content

problems with search form numerical "between" sending by php


4x4ing

Recommended Posts

I am trying to display the results of a search, on a sql database, on a web page. I set up html "select form" and set value to "Between x and x" I get a resource error when submitting the form. I works ok when using "LIKE" or "<" but I cannot get a between to work.

The purpose for this is to allow a custormer to search a vehicle inventory by prices between set points.

The HTML page the form is <a href="http://www.docwilsonsauto.com/index.html">here</a> there is no php on this page so just view the source.

 

Here is the code from the .PHP

And thank you for reading this I am stumped on why this will not work. The other searches I made work great.

 

 

<?php

$con = mysql_connect("***********.***.*****","********","******");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("docwilson", $con);

 

$result = mysql_query("SELECT *

FROM  `Inventory`

WHERE  `Selling Price`('$_POST[search1]')");

 

while($row = mysql_fetch_array($result))

  {

  echo $row ['Stock Number'] . " " . $row['Make']." " . $row['Model']." " . $row['Color']." ". $row['Miles']." ". $row['Selling Price'];

  echo "<br />";

  }

 

mysql_close($con)

?>

 

 

I don't see how that query would work. You don't even have an operator next to the WHERE clause. but MySQL has a between operator

 

its usage is simple. something like

SELECT * FROM table WHERE column BETWEEN low and high

obviously low and high would be your min and max numbers[/code]

Well I have the BETWEEN operator in the html for like this

 

 

Is there anything wrong with that?

I tried it the other way also. Like you said with the between operator on the php page and it did not work either. How does Method= "post" handle spaces? could it be introducing an error?

Thanks

 

 

[pre]<form action="jeep-search-by-price.php" method="post">

 

  Search By Price Range:

  <select name="search1">

    <option VALUE= "BETWEEN 0 AND 5000">Less Than $5000</option>

    <option value="BETWEEN 4500 and 10500">$5000-$10,000</option>

    <option value="BETWEEN 10000 and 99000">More Than $10,000</Option>

   

  </select>   

    <input type="submit" value="Submit">[/pre]

I changed the form to text and added the between operator to the php page. I guess that method=post doesn't handle spaces well? And I am sorry I guess this was not a php problem but an html. woops. thanks to all. and a Merry Christmas.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.