Jump to content

[SOLVED] Database Array with Alternative Output


suttercain

Recommended Posts

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.

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...

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.