suttercain Posted February 28, 2007 Share Posted February 28, 2007 Hello, I have an array via the MySQL database. The column I am working with is fuels and the fields are "GN11," "NN01." and "DC03". I need them to echo as GN11=>GASOLINE, NN01=>CNG, DC03=>DIESEL. Here is the code I am using (I also used it for vehicles and it worked), but the output isn't changed: // Convert the Array FUEL to FUEL TYPE $fuel_types = array('GN11'=>'GASOLINE', 'NN01'=>'CNG', 'DC03'=>'DIESEL'); print $fuel_types[$row['fuel']]; echo "<td width='60'><font size=1.5>$row[fuel]</font></td>\n"; So the output I am getting is Still GN11 instead of GASOLINE. Where am I going wrong? Thank you in advance. Link to comment https://forums.phpfreaks.com/topic/40548-solved-database-array-with-alternative-output/ Share on other sites More sharing options...
itsmeArry Posted February 28, 2007 Share Posted February 28, 2007 use this:: echo "<td width='60'><font size=1.5>$fuel_types[$row[fuel]]</font></td>\n"; Link to comment https://forums.phpfreaks.com/topic/40548-solved-database-array-with-alternative-output/#findComment-196217 Share on other sites More sharing options...
suttercain Posted February 28, 2007 Author Share Posted February 28, 2007 Thanks for responding, I added: echo "<td width='60'><font size=1.5>$fuel_types[$row[fuel]]</font></td>\n"; and replaced: echo "<td width='60'><font size=1.5>$row[fuel]</font></td>\n"; But I am getting the following parse error: Parse error: parse error, unexpected '[', expecting ']' in C:\wamp\www\ARB\pio\2007ccvl.php on line 131 I don't know why... Link to comment https://forums.phpfreaks.com/topic/40548-solved-database-array-with-alternative-output/#findComment-196223 Share on other sites More sharing options...
boo_lolly Posted February 28, 2007 Share Posted February 28, 2007 change $row[fuel] to $row['fuel'] Link to comment https://forums.phpfreaks.com/topic/40548-solved-database-array-with-alternative-output/#findComment-196226 Share on other sites More sharing options...
redarrow Posted February 28, 2007 Share Posted February 28, 2007 <?php echo "<td width='60'><font size=1.5>".$row['fuel']."</font></td>\n"; ?> Link to comment https://forums.phpfreaks.com/topic/40548-solved-database-array-with-alternative-output/#findComment-196227 Share on other sites More sharing options...
suttercain Posted February 28, 2007 Author Share Posted February 28, 2007 Thanks for responding, I tried: echo "<td width='60'><font size=1.5>".$row['fuel']."</font></td>\n"; And it still echoed GN11 instead of GASOLINE I also tried adding ' ' around fuel: echo "<td width='60'><font size=1.5>$fuel_types[$row['fuel']]</font></td>\n"; and still got the parse error listed above. I am not sure why it isn't working... From the looks of it, it should be running. Any other suggestions? Thanks. Link to comment https://forums.phpfreaks.com/topic/40548-solved-database-array-with-alternative-output/#findComment-196232 Share on other sites More sharing options...
suttercain Posted February 28, 2007 Author Share Posted February 28, 2007 I got it: I changed the line of code to: echo "<td width='60'><font size=1.5>".$fuel_types[$row['fuel']]."</font></td>\n"; Thanks guys for getting me on the right track. Shannon Link to comment https://forums.phpfreaks.com/topic/40548-solved-database-array-with-alternative-output/#findComment-196242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.