Welcome to Geeklog, Anonymous Saturday, April 20 2024 @ 05:35 am EDT

Geeklog Forums

Need help with a few GL functions


Rinny

Anonymous
Let’s say I have a table with four fields in it: name, address, phone, gender

I read the data like this:
Text Formatted Code
$result = DB_query("SELECT * FROM mytable WHERE myconditionsaremet  ORDER BY order ASC");
 

I find the num of records like this:
Text Formatted Code
    $nrows = DB_numRows($result);
    if ($nrows > 0) {
 

Then let us loop through all of the records and find all the men:
Text Formatted Code
        for ($i=0;$i<$nrows;$i++) {
            $A = DB_fetchArray($result);
                if $A[gender] == “Male” then we got a guy here!
        }
 

Here is my question. Lets say I want to loop through the data elements once again, to find all women. How do I do it without having to do another SQL query? Seems to me I should be able to another for loop, since the $results variable still exists.
Text Formatted Code
        for ($i=0;$i<$nrows;$i++) {
            $A = DB_fetchArray($result);
                if $A[gender] == “female” then we got a gal!
        }
 
Unfortunately, this does not work. Any help would be appreciated - of course.
 Quote

Rinny

Anonymous
Nevermind. Figured it out. Sorry.
 Quote

All times are EDT. The time is now 05:35 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content