Re: amount of elements in an array ? - building dynamic html tables for sets of MySQL results
| From: | Andrian Pervazov | Date: | Thu, 13 Jul 2000 01:33:41 +0000 |
| Subject: | Re: amount of elements in an array ? - building dynamic html tables for sets of MySQL results | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-6349@lists.php.net to get a copy of this message | ||
Nick wrote:
>
> i'm trying to write a script that dynamically generates HTML tables depending on the
> results from an SQL query. So far, I have managed to set the HTML table headers to be the same as
> those in the MySQL table. [thanks to rod k -cheers !]
> Now i'm trying to put the results in the table. Basically, I need a MySQL function to
> retrieve data and put it into the table until there is no data left....
>
> my problem basically is that I do not have a way of putting the data into the table unless i
> know how many elements to put in before creating a new <tr>[html table row].
>
> Is there a way of finding out the amount of elements in an array ?
>
> Then I could do something like:
>
> while($array=mysql_fetch_row ($this->Query_ID)):
> $i = 0;
> $j = [amount of elements in $array];
> echo "<tr>";
> while ($i < $j):
> echo "<tr><td>$db->Rowdata[$i]</td>
> <td>"; $i++;
> endwhile;
> echo "</tr>";
>
> any ideas ?
>
> -nick
mysql_num_fields() should provide this.
Andrian