Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - How would I do.....
  
User name:
Password:
Reply:
 

UserPost
Vystrix Nexoth
Posts: 207/348
$resultset = mysql_query ("SELECT whatever FROM wherever etc");
if (mysql_num_rows ($resultset) == 0) {
// there are no results. deal with it.
} else {
//do your usual thing.
}

as an aside, next time, use a more informative thread title. I almost skipped this one. "ZOMG HEPL!11" is not informative. "MySQL design problem" (e.g.) would be.
DarkSlaya
Posts: 3084/4249
I guess I suck at explaining things ...

I'll take an example of what I want, it'll be easier:

Let's say you have a browser based game, in it you have guilds or whatever you call them. In them you have players, right? So normally, you make a loop to get them. However, you wanna add something to it. You want the guilds to have Higher Ranked players (we'll call them super members). However, a guild will not necessary have one, and my have more than one.

Now, my problem (if I use the example), would be that I want to display the players in a guild even when there are no Super Members.

But the way I do it uses two while() loop, which won't display a certain row if it the condition isn't matched. The first while() will always return TRUE while the second one will return FALSE sometimes.
windwaker
Posts: 820/1797
So... you just want to echo some text?

Here's some crappy AB code that'll do what you want:

$sql = mysql_query("SELECT * FROM `table` ORDER BY `id` LIMIT 50");
for($i = 0;$var[$i] = mysql_fetch_array($sql, MYSQL_ASSOC);$i < 50;$i++);
while($whatever = $var){
echo $whatever['$fieldname'];
$whatever = next($var);
}

I can't remember where I found that code, I think it was in the Acmlmboard a few places. This'll print the first 50 rows of the table "table". I'm not exactly sure what you meant though, as this is easy and you probably already know this.
DarkSlaya
Posts: 3083/4249
Normally, I figure what I need by myself, by this time I really don't have a clue of what to do.

The thing I'd like to do would be to grab data from an mySQL database, and then do a loop to print the rows. That part's easy, I do this all the time. However, I'd like to print data even when nothing is returned (not what while() does). My guess would be to use for() but I'm not sure.

I'm not even sure if this made sense....

Edit: Forgot to mention, I make this in PHP.
Acmlm's Board - I2 Archive - Programming - How would I do.....


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.009 seconds.