suttercain Posted February 24, 2007 Share Posted February 24, 2007 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. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 24, 2007 Share Posted February 24, 2007 $current = strtoupper($row['vehicle']); You need to use 'quotes' around your array keys which are strings like you did here, on the rest of them, like $row[disp] Quote Link to comment Share on other sites More sharing options...
mcastles Posted February 24, 2007 Share Posted February 24, 2007 you could also modify your sql to retrieve the vehicle name in uppercase: SELECT UPPER(vehicle) AS vehicle, sub_class, disp, fuel FROM cars ORDER BY vehicle ASC Quote Link to comment Share on other sites More sharing options...
suttercain Posted February 24, 2007 Author Share Posted February 24, 2007 Both of those worked great. Thanks guys. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.