wright67uk Posted June 9, 2011 Share Posted June 9, 2011 Hello, im looking to return all of my sql results in proper case / first letter capitalised. I see from the manual you can use <?php $variable1 = 'my non capitalised text here'; $variable1 = ucwords($variable1); echo $variable1; // now my text reads My Non Capitalised Text Here ?> How can I apply somthing like the above to the results of my query without effecting the rest of my script? Is it the case of doing somthing like; $query = ucwords($query); <?php $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Accommodation' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . $nt[$i] . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> Link to comment https://forums.phpfreaks.com/topic/238916-using-ucwords-for-sql-results/ Share on other sites More sharing options...
wildteen88 Posted June 9, 2011 Share Posted June 9, 2011 You wouldn't use ucwords on the $query variable. You'll need to use it on the specific $nt variable. I'm guessing here? echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . ucwords($nt[$i]) . "</a>" . "<br/>"; Link to comment https://forums.phpfreaks.com/topic/238916-using-ucwords-for-sql-results/#findComment-1227671 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.