Jump to content

ucwords


hyster

Recommended Posts

i want to be able to use ucwords in my whole return results. i know this works.

 

$choice1 = ucwords($rows['auth']);

 

BUT. my query returns 14 $rows of data so i thought of doing this instead of doing a new chunk of code for each row.

 

$sql = "SELECT * from dsgi_serval $column ";
$result1=mysql_query($sql);
$result = ucwords($'result1');

while($rows=mysql_fetch_array($result)){
echo "$rows";
}

 

needless to say that does not work. i have tried to google this but i only get matches for manual arrays and not an sql query.

is there a way of doing this?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/223779-ucwords/
Share on other sites

Because $result holds a result resource, not an array. You also won't be able to echo $rows; all you'll get back from that should be 'Array'. I haven't tested this, but it *should* work to capitalize each one. You'll need to replace the echo pre/print_r()/echo pre with appropriate echo statements to format the output how you'd like it.

 

$sql = "SELECT * from dsgi_serval $column";
$result=mysql_query($sql);
while( $rows=mysql_fetch_array($result) ) {
   array_map('uc_words', $rows);
   echo '<pre>';
   print_r($rows);
   echo '</pre>';
}

Link to comment
https://forums.phpfreaks.com/topic/223779-ucwords/#findComment-1156677
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.