Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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