RE: [PHP] What could I be doing wrong here
| From: | Jack Dempsey | Date: | Mon, 26 Mar 2001 23:00:16 +0000 |
| Subject: | RE: [PHP] What could I be doing wrong here | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-45662@lists.php.net to get a copy of this message | ||
I forget the exact syntax, but it has to do with echoing a multidimensional
array in a string. Try
echo $myrow["make"] . "<br>";
you can also use {} to encapsulte the value.
there are posts in the archives about that
-jack
-----Original Message-----
From: YoBro [mailto:nospam@brochures.co.nz]
Sent: Monday, March 26, 2001 5:53 PM
To: php-general@lists.php.net
Subject: [PHP] What could I be doing wrong here
I can't figure out why this doesn't work. Rather than echo $myrow[0] which
works, I want to use the feild name. Like $myrow[make] to make reading the
code easier. IS this possible?
Here is some code:
$db = mysql_connect("localhost", $user, $pass)OR DIE("Unable to connect to
database");
mysql_select_db("database",$db) OR DIE("Unable to connect to database");
$result = mysql_query("SELECT * FROM stock",$db);
while ($myrow = mysql_fetch_row($result))
{
echo "$myrow[id]<br>"; //Usually $myrow[0] etc
echo "$myrow[make]<br>";
echo "$myrow[model]<br>";
echo "$myrow[sub_model]<br>";
}
Thanks Heaps
--
Regards,
YoBro
-------------------------------------------------------------
DO NOT REPLY TO THIS VIA EMAIL
PLEASE USE THE NEWSGROUP
All emails sent to this address are automatically deleted.
This is to avoid SPAM!
-------------------------------------------------------------
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net