|
Posted by Jerry Stuckle on 05/18/07 01:58
Akhenaten wrote:
> I have an array created but I need to search it. The array is created
> from a mysql call. Code as follows:
>
> ******************
> function respond_check($qid)
> {
> include "db.inc.php";
> $postchk2 = mysql_query("SELECT * FROM `answers` , `users` WHERE `qid`
> = $qid AND `a_uid` = `userid` LIMIT 0, 30",$db);
>
> while ($userx=mysql_fetch_array($postchk2))
> {
> $poster2 = $u_row22['username'];
>
>
> }
>
> }
>
> ******************
> I've tried including various *if* statements to search for $X in the
> array (which does exist) but I keep failing miserably. Suggestions?
>
I think maybe your problem is $postchk2 is a resource, not an array.
You get a single-dimensional array when you call mysql_fetch_array - but
only the current rows. If you want to search the entire contents
retrieved by MySQL, you need to do something like read everything
returned into an array in PHP then search it. Beware this can take huge
amounts of memory in the case of large rows and/or number of rows.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|