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
https://forums.phpfreaks.com/topic/39882-using-strtoupper-on-a-mysql-query/
Share on other sites

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.