TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   SQL/Array question (http://www.talkphp.com/general/120-sql-array-question.html)

NixMaster 10-14-2005 08:10 PM

SQL/Array question
 
I'm trying to create an array from a mysql query. For example

$query = mysql_query("SELECT id FROM users ORDER BY id DESC LIMIT 84");

now I need to create an array of the id's.

For example $id[0], $id[1] - $id[83].

Thanks.

AlEast 10-14-2005 08:23 PM

Ok this is what I'm getting from your question. Let me know if I understood incorrectly.

You want an array with all the values to do something with later. You could create your array dynamically by using the mysql_fetch_array

Code:

$idArray = array();
while($row=mysql_fetch_row($result)){
    $idArray[] = $row[0];
}


NixMaster 10-14-2005 08:49 PM

Thats great, thanks for the help.

1 problem. How can I read the database backwards? The graph's high point is left now and I want it on the right. If I do the query ASC it pulls old information instead of the new information, if I pull it DESC its the correct information but as I said above the graph is backwards.


Thanks again for the help.

jaswinder_rana 10-14-2005 10:21 PM

ASC or DESC are the only options, but to get your desired results you might need to make a complex query.
can you show by example, what you need and also give us table details.

certainly someone will be happy to help you.


All times are GMT. The time now is 12:00 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0