rsammy Posted October 30, 2006 Share Posted October 30, 2006 hihow do i display just the initials on the form ... not the full name. if thename is John Smith, I need to just dsplay JS on the screenThanks Link to comment https://forums.phpfreaks.com/topic/25607-initials/ Share on other sites More sharing options...
obsidian Posted October 30, 2006 Share Posted October 30, 2006 Suppose you always have the name in a variable. Are you wanting to use ALL provided names in the initials (including middle name, if provided)? If so, just use something like this:[code]<?phpfunction getInitials($name) { $init = ''; $name = explode(' ', $name); foreach ($name as $part) $init .= strtoupper(substr($part,0,1)); return $init;}$name = "John Smith";echo getInitials($name); // outputs 'JS'$name2 = "Wanda P. Oberholzer";echo getInitials($name2); // outputs 'WPO'?>[/code] Link to comment https://forums.phpfreaks.com/topic/25607-initials/#findComment-116866 Share on other sites More sharing options...
rsammy Posted October 30, 2006 Author Share Posted October 30, 2006 thanx for replying obsidian! i still amconfusedmy original code is like this:$query2="SELECT **********from ***** where **********$result=mysql_db_query("$database[dbname]", $query2);$num_rows=mysql_num_rows($result);$num_results=mysql_num_rows($result);$i=1;if(!isset($rowNum)){ $rowNum = 0;}$rowNumHold = $rowNum;$count = 1;$limit_results = 25;if ($num_rows > 0){ for($q=0;$q<$limit_results && $rowNum < $num_rows;$q++) { if(mysql_data_seek($result, $rowNum++)) { if ($i++%2) { print ("<tr bgcolor=\"#cccccc\">"); } else { print ("<tr>"); } $row = mysql_fetch_object($result); print("<td height=\"14\"> <div align=\"left\">"); print($row->pat_last_name); print(", "); print($row->pat_first_name); print("</div></td>"); print("<td height=\"14\"> <div align=\"center\">"); print($row->pat_birthday); print("</div></td>"); print("<td height=\"14\"> <div align=\"center\">"); print($row->pat_ssn); print("</div></td>"); print("<td height=\"14\"> <div align=\"left\">"); print($row->phy_fname); print(" "); print($row->phy_lname); print("</div></td>"); $client_id=($row->client_id); print("<td height=\"14\"> <div align=\"center\">"); print($row->date); print("</div></td>"); print("<td height=\"14\"> <div align=\"center\">");print ("<a href=\"Recorddetails.php?visit_id=$row->visit_id&visit_type=ICN&client_id=$row- >client_id&visit_status=$row->visit_status&visit_loc=$row- >visit_loc&pat_first_name=$row->pat_first_name&pat_last_name=$row- >pat_last_name&phy_fname=$row->phy_fname&phy_lname=$row- >phy_lname&pat_dob=$row->pat_birthday&pat_ssn=$row- >pat_ssn&pat_sex=$row->pat_sex\">Details</a>"); print("</div></td>"); print("</tr>"); }}*********now if you look at phy_lname and phy_fname - thats where i need to use initials in place of full phycians full name. also i need to pass the same stuff to the next page - recorddetails.phphow would i be able to do that?help will be greatly appreciatedthanx Link to comment https://forums.phpfreaks.com/topic/25607-initials/#findComment-117004 Share on other sites More sharing options...
sasa Posted October 31, 2006 Share Posted October 31, 2006 declare obsdian's function anduse print(getInitials($row->pat_first_name)); Link to comment https://forums.phpfreaks.com/topic/25607-initials/#findComment-117321 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.