Re: [PHP] count with match probelm

2005-03-24 Thread Jochem Maas
Richard Lynch wrote:
...
$how_many = mysql_result(mysql_query(SELECT COUNT(*), MATCH(ad_sub,
ad_text) AGAINST('$words') AS score from .$tcname.ads WHERE
MATCH(ad_sub,
ad_text) AGAINST('$words') FROM .$tcname.ads where is_confirmed=1),0);

H.  Actually, I *can* tell you that you shouldn't have FROM in there
twice.  You've messed up your query something awful with that.
also he just wants the count with this statement so:
'MATCH(ad_sub,ad_text) AGAINST('$words') AS score'
shouldn't be part of this query, instead:
SELECT COUNT(*) FROM .$tcname.ads where is_confirmed=1 WHERE 
MATCH(ad_sub,ad_text) AGAINST('$words')
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] count with match probelm

2005-03-22 Thread Ryan A
Hi,
I am running this kind of a statement:

$q=mysql_query(select cno,date_and_time,MATCH(ad_sub, ad_text)
AGAINST('$words') AS score from .$tcname.ads WHERE MATCH(ad_sub, ad_text)
AGAINST('$words') AND is_confirmed=1 LIMIT $limit1, $limit2);

which is running fine...my problem is I am using a class for pagination
which requires the total number of records that will be returned to break
the query into pagesand which will give me the values of $limit1 and ,
$limit2 which i will use in the above statement...but running a count() is
not working, it gives me an error, what other options do i have other than
running the same query twice and using mysql_num_rows? (which i think would
be quite intensive/wasteful as i am querying @ 100 rows each time)

This is my count() query, maybe theres a problem here?

$how_many = mysql_result(mysql_query(SELECT COUNT(*), MATCH(ad_sub,
ad_text) AGAINST('$words') AS score from .$tcname.ads WHERE MATCH(ad_sub,
ad_text) AGAINST('$words') FROM .$tcname.ads where is_confirmed=1),0);

Thanks in advance,
Ryan



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.0 - Release Date: 3/21/2005

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] count with match probelm

2005-03-22 Thread Richard Lynch
On Tue, March 22, 2005 11:30 pm, Ryan A said:
 $q=mysql_query(select cno,date_and_time,MATCH(ad_sub, ad_text)
 AGAINST('$words') AS score from .$tcname.ads WHERE MATCH(ad_sub,
 ad_text)
 AGAINST('$words') AND is_confirmed=1 LIMIT $limit1, $limit2);

This is pretty much a MySQL question, really...

But:  There is a new-ish SQL_CALC_FOUND_ROWS constant you can use in your
query to get MySQL to tell you how many rows you would have gotten without
the LIMIT clause.  You may be able to use that.

 which is running fine...my problem is I am using a class for pagination
 which requires the total number of records that will be returned to break
 the query into pagesand which will give me the values of $limit1 and ,
 $limit2 which i will use in the above statement...but running a count() is
 not working, it gives me an error, what other options do i have other than
 running the same query twice and using mysql_num_rows? (which i think
 would
 be quite intensive/wasteful as i am querying @ 100 rows each time)

 This is my count() query, maybe theres a problem here?

Probably.

But since you only told us it gives me an error and don't tell use
*WHAT* the error is, we really can't help you, can we?

 $how_many = mysql_result(mysql_query(SELECT COUNT(*), MATCH(ad_sub,
 ad_text) AGAINST('$words') AS score from .$tcname.ads WHERE
 MATCH(ad_sub,
 ad_text) AGAINST('$words') FROM .$tcname.ads where is_confirmed=1),0);

H.  Actually, I *can* tell you that you shouldn't have FROM in there
twice.  You've messed up your query something awful with that.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php