Welcome to Geeklog, Anonymous Friday, November 29 2024 @ 01:54 am EST
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:
I find the num of records like this:
if ($nrows > 0) {
Then let us loop through all of the records and find all the men:
$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.
$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.
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!
}
8
7
Quote
Rinny
Anonymous
Nevermind. Figured it out. Sorry.
6
8
Quote
All times are EST. The time is now 01:54 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