Jump to content

Using strtoupper on a MySQL query


suttercain

Recommended Posts

Hello and good friday night to you all,

 

Right now I am running the following code:

<?php
//Connect to the Database via the Include File!
require ('get_connected.php');

// Begin your table outside of the array
echo "<table width='100%' border='0' cellpadding='1' cellspacing='0'>
    <tr>
    </tr>";

// Perform an statndard SQL query:
$res = mysql_query("SELECT * FROM cars ORDER BY vehicle ASC") or die (mysql_error());

// Assuming $res holds the results from your query:
$class = 'even';
$current = '';
while($row = mysql_fetch_array($res)) {
  if($current != $row['vehicle']) {
    $current = $row['vehicle'];
    echo "<tr>
        <td width='110'><br><b>$current</b></td>
	<td width='110'><br><b>FUEL</b></td>
	<td width='110'><br><b>DISPLACEMENT</b></td>
</tr>";
  }
  $class = $class == 'even' ? 'odd' : 'even';
  echo "<tr class=\"$class\">\n";
  echo "<td>$row[sub_class]</td>\n";
  echo "<td>$row[disp]</td>\n";
  echo "<td>$row[fuel]</td>\n";
  echo "</tr>\n";
}
?>

 

What I would like to be able to do is have the output of the column title "vehicle" to be in uppercase. I am using the $current variable to echo out the query result but for the life of me I cannot figure out where to place the strtoupper command.

 

Can anyone assist?

 

Thank you.

Link to comment
Share on other sites

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.