Re: Creating an array of mySQL results with PHP
| From: | John Hughes, Jomari Works | Date: | Tue, 12 Mar 2002 07:02:54 +0000 |
| Subject: | Re: Creating an array of mySQL results with PHP | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-17620@lists.php.net to get a copy of this message | ||
OK. I can see how that works, assuming that the value would be
\"log[$week_no][classroom]\" as well.
What would the mysql_fetch_array look like?
----- Original Message -----
From: "Shrock, Court" <ShrockC@inhs.org>
To: "'John Hughes, Jomari Works'" <john@jomari.com>;
<php-db@lists.php.net>
Sent: Monday, March 11, 2002 10:50 PM
Subject: RE: [PHP-DB] Creating an array of mySQL results with PHP
> Well, you could use the power of PHP arrays and just name your input
fields
> in such a way that would create an array upon submittal. For example:
>
> <td align=\"center\">
> <input type=\"text\" name=\"log[$week_no][classroom]\"
> value=\"$classroom\">
> </td>
>
> Then, after submittal, you just loop through the array $log like such:
>
> foreach($log as $week_no => $data) {
> $sql = "UPDATE table SET classroom='{$data['classroom']}' WHERE
> week_no=$week_no";
> mysql_query($sql);
> }
>
> Of course, this all assumes that the key is week_no. Hope this helps,
> Court
>
> > -----Original Message-----
> > From: John Hughes, Jomari Works [mailto:john@jomari.com]
> > Sent: Monday, March 11, 2002 10:42 PM
> > To: php-db@lists.php.net
> > Subject: [PHP-DB] Creating an array of mySQL results with PHP
> >
> >
> > while ($row = mysql_fetch_array($result)) {
> > $week_no = $row['week_no'];
> > $week_date = $row['week_date'];
> > $parent_id = $row['parent_id'];
> > $student_id = $row['student_id'];
> > $class_id = $row['class_id'];
> > $classroom = $row['classroom'];
> > $homework = $row['homework'];
> > $library = $row['library'];
> > $fieldtrip = $row['fieldtrip'];
> > $pta = $row['pta'];
> > $mast = $row['mast'];
> > $meetings = $row['meetings'];
> > $other = $row['other'];
> >
> > I then create a table row of the result and loop through.
> >
> > A sample table cell looks like this:
> >
> > <td align=\"center\">
> > <input type=\"text\" name=\"classroom\"
> > value=\"$classroom\" size=\"2\"
> > maxlength=\"4\">
> > </td>
> >
> > How would I change the mysql_fetch_array to create an array
> > of weeks and how
> > would I change the table output coding to accommodate such an array?
>
>