PLEASE HELP

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
gracie
Forum Newbie
Posts: 4
Joined: Mon Mar 24, 2008 8:46 am

PLEASE HELP

Post by gracie »

I'm working on a auction site and added a search feature to it. I can get it to return a search result using the following statements -

Code: Select all

  $sqlString = "SELECT * FROM items WHERE name LIKE '%" . $search . "%' LIMIT $offset, $rowsPerPage";
   $sqlResult = mysql_query($sqlString);
   $searchnumrows = mysql_num_rows($sqlResult);
   
   $String = "SELECT * FROM items WHERE name LIKE '%" . $search . "%' ";
   $Result = mysql_query($String);
   $numrows = mysql_num_rows($Result);

I have a field in my 'items' table called dateends and i would like to return all the auction items that havent expired. I have tried the following statement and i get no result at all. i hope someone might be able to tell me i'm going wrong. Thanks.


Code: Select all

  $sqlString = "SELECT * FROM nam_items WHERE dateends > NOW() AND name LIKE '%" . $search . "%' LIMIT $offset, $rowsPerPage";
   $sqlResult = mysql_query($sqlString);
   $searchnumrows = mysql_num_rows($sqlResult);
   
   $String = "SELECT * FROM nam_items WHERE dateends > NOW() AND name LIKE '%" . $search . "%' ";
   $Result = mysql_query($String);
   $numrows = mysql_num_rows($Result);
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: PLEASE HELP

Post by s.dot »

Hi, to further help us help you, please edit your title to something descriptive, and put your code in BBCode [ CODE ] tags. I have edited your post to reflect how we would like it posted. :)

What type of field is dateends? Is it a timestamp or mysql datetime?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply