Jump to content

Whats the function to do this?


ballhogjoni

Recommended Posts

what is the int?

 

is it a number of entries in a db?

 

if so you can do this:

$sql="SELECT * FROM table";
$result=mysql_query($query); 
$int=mysql_num_rows($result);
$a = range(1,$int);
print_r($a);

 

if you were more specific as to where you were getting your number that would help...

what is the int?

 

is it a number of entries in a db?

 

if so you can do this:

$sql="SELECT * FROM table";
$result=mysql_query($query); 
$int=mysql_num_rows($result);
$a = range(1,$int);
print_r($a);

 

if you were more specific as to where you were getting your number that would help...

 

 

Don't take this the wrong way, but that's a horrible way to do that.

 

 

SELECT COUNT(*) FROM table;

 

Would be many times faster.

 

Why select everything when you just want to count it?

because i am stupid, duh!

no...i am pretty new to the coding thing, just a hobby...starting to get a handle on php, still not too good w/mysql.  just basics.  i appreciate it when someone points out something that works better/faster/smarter.  i have noticed that even if i can get something done, someone else can get it done in at least half the time, if not less...either way, the idea was there and he got a crappy way and a good way to do it.

 

use the good way!  i know i will from now on.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.