Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Quick Prob - search issue
Old 07-18-2005, 06:41 AM Quick Prob - search issue
Experienced Talker

Posts: 35
Trades: 0
Hi Guys,

I have this search:

PHP Code:
<?php 
include("../*********.php");
include(
"../*********.php");

# define simple variable from posted 'q' 
$q trim(stripslashes(htmlspecialchars($_GET['q']))); 

# output no results found message
$XX "No Record Found"

# start your query 
# using like to match with the % wildcards 

$query=mysql_query("select * from news where headline like '%%$q%%' or opening like '%%$q%%'") or die(mysql_error()); 


while(
$rows mysql_fetch_assoc($query)) { 
echo 
'<a href="http://www.mysite.org/site/news/news.php?newsid='$rows['newsid'] .'">'$rows['headline'] .'</a><br>'
echo 
$rows['opening'].'<br><br>'


//below this is the function for no record!! 
if ($q <= 0

print (
"$XX"); 


?>
...and it works, but even if it returns results it outputs the result and link then at the bottom 'no records found' even though it has? I don't see why though as the above I think **should** just say 'no records found' if that is the case?

Thanks

Chris
chrisb is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-18-2005, 11:33 AM
Experienced Talker

Posts: 47
Trades: 0
Instead of doing
PHP Code:
if ($q <= 0

print (
"$XX"); 

You might want to try something like this
PHP Code:
if (mysql_num_rows($query 1)
{
print(
"$XX");

What you are doing now is checking if the passed variable $q is <= 0, and you need to check for the results in the sql resource.
Synchronize is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Quick Prob - search issue
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.37201 seconds with 12 queries