Jump to content

PLEASE HELP


gracie

Recommended Posts

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  -

 

$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.

 

 

 

$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);

 

 

 

Link to comment
Share on other sites

What datatype is your dateends column? It needs to be a datetime to work correctly when comparing against NOW().

Also, why are you doing the same statement twice, one with a limit and the other without?

I should also point out that LIKE %string% will be HORRIBLY inefficient because NO INDEX can be used on it.

Link to comment
Share on other sites

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  -

 

$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.

 

 

 

$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);

 

 

 

 

As the earlier user said: your column type doesn't seem to match.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.