Re: Array HELP PLEASE
| From: | Martín Marqués | Date: | Thu, 08 Nov 2001 22:43:32 +0000 |
| Subject: | Re: Array HELP PLEASE | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-73965@lists.php.net to get a copy of this message | ||
On Jue 08 Nov 2001 19:25, you wrote:
> (Before you write RTFM, please know that I have checked www.php.net,
> zend.com, phpbuilder.com, et all, and--in the eternal words of Bono--I
> still haven't found what I'm looking.)
>
> The situation: I extract an array from a MySQL table. Code:
>
> $models = mysql_fetch_array(mysql_query("SELECT * FROM models WHERE
> lang='$lang' AND key1='data' AND key2='$series'",$db));
>
> Based on the above criteria, there should be two rows in $modelsrow, with
> each row containing about twenty elements. (A two-dimensional array,
> right?) All I want to do is display the contents of $models. With the
> following...
>
> for ($i = 1; $i <= 20; $i++) {
> echo $models[$i]."<p>";
> }
>
> ...I get just one row. How can I also display the other row? I've tried
> variations of $models[1][2], but I just can't get right syntax. (Help is
> much appreciated. Thanks.)
What you need is a god manual of programinnig, so you can RTFM.
for ($i = 1; $i <= 2; $i++) {
foreach($models[$i] AS $val){
echo $val."<p>";
}
echo "<br>";
}
> If you know of a good tutorial on multidimension arrays + mySQL, that would
> be nice too.
>
> ...Rene
--
Porqué usar una base de datos relacional cualquiera,
si podés usar PostgreSQL?
-----------------------------------------------------------------
Martín Marqués | mmarques@unl.edu.ar
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------