ballhogjoni Posted December 3, 2008 Share Posted December 3, 2008 I want to turn this int 2, into an array like this: array(0=>1,1=>2); how would I do that? Quote Link to comment Share on other sites More sharing options...
zenag Posted December 3, 2008 Share Posted December 3, 2008 $a=range(1,2); print_r($a); Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted December 3, 2008 Author Share Posted December 3, 2008 the problem is that the int 2 will change all the time. Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 3, 2008 Share Posted December 3, 2008 Still valid $i = 4 $a = range(1,$i); print_r($a); Quote Link to comment Share on other sites More sharing options...
ardyandkari Posted December 4, 2008 Share Posted December 4, 2008 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... Quote Link to comment Share on other sites More sharing options...
corbin Posted December 4, 2008 Share Posted December 4, 2008 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? Quote Link to comment Share on other sites More sharing options...
ardyandkari Posted December 4, 2008 Share Posted December 4, 2008 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. Quote Link to comment Share on other sites More sharing options...
corbin Posted December 4, 2008 Share Posted December 4, 2008 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.