Jump to content

initials


rsammy

Recommended Posts

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]
<?php
function 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
Share on other sites

thanx for replying obsidian! i still amconfused
my 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.php

how would i be able to do that?

help will be greatly appreciated
thanx
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.