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
https://forums.phpfreaks.com/topic/98892-please-help/
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
https://forums.phpfreaks.com/topic/98892-please-help/#findComment-506301
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
https://forums.phpfreaks.com/topic/98892-please-help/#findComment-507976
Share on other sites

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.