PHP query on "date" field
| From: | Jason | Date: | Tue, 30 Oct 2001 17:31:20 +0000 |
| Subject: | PHP query on "date" field | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-13851@lists.php.net to get a copy of this message | ||
Here is my problem once again... =P I am wondering if I should change the
date table to something other than date... maybe something like date_1?
Would doing that resolve my issue, because of the fact that the date
variable in php is function? Thanks in advance...
Jason
/* Form to supply variables */
<form name="auth" method="post" action="http://path/to/search.php">
<p>Search for Ads</p>
First name:
<input type="text" name="fname">
<br>
Last name:
<input type="text" name="lname">
<br>
Area Code:
<input type="text" name="phonea" size="3"
maxlength="3">
Phone:
<input type="text" name="phone" size="8"
maxlength="8">
<br>
Date:
<input type="text" name="date">
<br>
<p>
<input type="submit" name="login"
value="Submit">
<input type="reset" name="reset"
value="Reset">
</p>
</form>
Once user clicks submit button it links to this php script to connect, query
and display results... eveything works fine except for the date variables.
If anyone with a little more know how can point me out the error I would
greatly appriciate it.
/* php script to connect, query and display results */
<?php
mysql_connect ("db_host", "db_username", "db_password") or
die("Couldn't
connect!");
mysql_select_db ("db_name") or die("Couldn't select database");
if ($fname == "")
{$fname = '%';}
if ($lname == "")
{$lname = '%';}
if (phonea == "")
{$phonea = '%';}
if ($phone == "")
{$phone = '%';}
if ($date == "")
{$date = '%';}
$result = mysql_query ("SELECT * FROM ads
WHERE fname LIKE '%$fname%' AND lname LIKE
'%$lname%' AND phonea LIKE '%$phonea%' AND phone LIKE '%$phone%' AND
date
LIKE '%$date%'");
if ($row = mysql_fetch_array($result)) {
do {
PRINT "Your search results: <br><br>";
PRINT "<b>First Name: </b> ";
print $row["fname"];
print ("<br>");
PRINT "<b>Last Name: </b> ";
print $row["lname"];
print ("<br>");
PRINT "<b>Address: </b> ";
print $row["address"];
print ("<br>");
PRINT "<b>City: </b> ";
print $row["city"];
print ("<br>");
PRINT "<b>State: </b> ";
print $row["state"];
print ("<br>");
PRINT "<b>Zip: </b> ";
print $row["zip"];
print ("<br>");
PRINT "<b>Area Code: </b> ";
print $row["phonea"];
print ("<br>");
PRINT "<b>Phone: </b> ";
print $row["phone"];
print ("<br>");
PRINT "<b>Email: </b> ";
print $row["email"];
print ("<br>");
PRINT "<b>Weeks: </b> ";
print $row["weeks"];
print ("<br>");
PRINT "<b>City 1: </b> ";
print $row["cty1"];
print ("<br>");
PRINT "<b>City 2: </b> ";
print $row["cty2"];
print ("<br>");
PRINT "<b>City 3: </b> ";
print $row["cty3"];
print ("<br>");
PRINT "<b>Ad: </b> ";
print $row["ad"];
print ("<br>");
PRINT "<b>Total: </b> ";
print $row["total"];
print ("<br>");
PRINT "<b>Number of weeks: </b> ";
print $row["num"];
print ("<br>");
PRINT "<b>Date: </b> ";
print $row["date"];
print ("<br>");
PRINT "<b>Time: </b> ";
print $row["time"];
print ("<br>");
print ("<hr>");
} while($row = mysql_fetch_array($result));
} else {print "Sorry, no records were found!";}
?>