$query = mysql_query("SELECT whatever FROM whatever;");
while($row = mysql_fetch_array($query))
        $construct[] = $row[whatever];

That will give you an array (construct) with position 0 being the first
row, position 1 being the second row, and so on.

Adam Voigt
[EMAIL PROTECTED]

On Mon, 2002-07-15 at 13:04, [EMAIL PROTECTED] wrote:
> 
> "Adam Alkins" <[EMAIL PROTECTED]> wrote on 07/13/2002 07:56:46 PM:
> 
> > > I have a database, all the data is numbers. I want to make a query that
> > > will extract the data and then make it available in an array, so the
> > > array is populated 'real-time'. I could just enter the number into an
> > > array manually, but I want to automate the job. I don't know what to
> > > start looking for, the 3 books I have either don't talk about this or I
> > > just am missing it.
> > > Could someone point me in the right direction?
> 
> > Well after you SELECT the data and run the query, you can use a few
> > functions, it depends on your database type?
> 
> > For example, for MySQL, you can use mysql_fetch_array() which will take
> your
> > data and store it in an array, both numeric and associative.
> 
> > i.e. $data = mysql_fetch_array($result) can be accessed like
> 
> > $data['column_name']
> > $data[column_number]
> 
> > You can also fetch an array only as an associative (mysql_fetch_assoc) or
> > numeric (mysql_fetch_row). And simply if selecting multiple rows, use a
> loop
> 
> > while($data = mysql_fetch_array())...
> 
> > --------------
> > Adam Alkins
> 
> I guess I wasn't very clear on exactly what results I expect. I can get the
> data and print all the numbers, that's no problem. What I want is to have
> all the numbers inserted into an array that would look like this:
> $datax = (50,50,50,60,60,60,70,70,70,65,65,70,75,75,80);
> Each number in the array is from a single row in the table (15 rows in this
> example).
> The database is weights, entered after a work-out, along with their reps.
> I only need the weights, as shown above. This array $datax is then
> processed
> by a php script to create a graph showing the progress of the person's
> wieght
> lifting over time. I can enter all the numbers into the array manually and
> the graph is drawn correctly, but prefer the web interface I made. This is
> okay for me, but not others.
> So, I made a web form that takes the data and inserts into the database.
> That works fine also. The table contains columns:
> squats, squats_reps, legpress, legpress_reps, etc etc.
> The first is the weight and the second is the number of reps. So after
> each workout the appropriate numbers would be entered via the form page,
> the graph would be generated with the updated numbers from another page.
> 
> Hope this helps to explain it a bit better,
> 
> --
> Chip
> 
> > http://www.rasadam.com
> > --------------
> 
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to