Jump to content

[SOLVED] need help with Initials PLEASE ...


rsammy

Recommended Posts

i need to just display the initials of a doctors name - say if the doctor is John Smith, JS shud be displayed.

this is my code:

**************
$query2="SELECT visit_mgr.visit_id, visit_mgr.visit_status, visit_mgr.visit_loc, visit_mgr.visit_pat_id, visit_mgr.visit_phy_id,
Date_Format(visit_mgr.visit_date, '%m/%d/%Y') as date,  phy_det.phy_fname, phy_det.phy_lname, pat_dgraphics.pat_first_name,
pat_dgraphics.pat_last_name, Date_Format(pat_dgraphics.pat_dob, '%m/%d/%Y') as pat_birthday, pat_dgraphics.pat_sex, pat_dgraphics.pat_ssn,
pat_dgraphics.pat_ID, diag.diag_diag, visit_mgr.client_id

FROM visit_mgr, phy_det, pat_dgraphics, diag

WHERE visit_mgr.visit_type like '%$select1%' AND phy_det.phy_id=visit_mgr.visit_phy_id AND visit_mgr.visit_pat_id=pat_dgraphics.pat_ssn
AND phy_det.phy_fname like '%$search3%' AND phy_det.phy_lname like '%$search4%' AND pat_dgraphics.pat_first_name like '%$search1%'
AND pat_dgraphics.pat_last_name like '%$search2%' AND pat_dgraphics.pat_ssn like '%$search5%' AND diag.diag_visit_id=visit_mgr.visit_id
AND diag.diag_patid=pat_dgraphics.pat_ID AND visit_mgr.client_id $clientid AND visit_date <= '$dates' AND visit_date >= '$datez'

ORDER BY $select2  $select";

$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=\"center\">");
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>");

}

}

****************

how can i accomplish that in this code?

thanks in advance
Link to comment
Share on other sites

or just create a new field and record it first thing would be easier.
Because either of these method's are great, but what if they have 3 names.
Like for there first name they put
Joyel West
my middle name's are
West Lee
Joyel West Lee Puryear
say I put west lee after joyel, then how is your program goign to cut that up, it won't.
See what I mean, you have to accont for that as well.
Link to comment
Share on other sites

[quote author=businessman332211 link=topic=115083.msg468454#msg468454 date=1163613847]my middle name's are
West Lee
Joyel West Lee Puryear
say I put west lee after joyel, then how is your program goign to cut that up, it won't.
See what I mean, you have to accont for that as well.
[/quote]

ex:
[code=php:0]$name = "Joyel West Lee Puryear";
echo preg_replace('/(\w)\w+ ?/', "\\1", $name);[/code]
Link to comment
Share on other sites

Try adding this function to the beginning of the file:
[code]function initials($name){
$nword = explode(" ",$name);
foreach($nword as $letter){
$new_name .= $letter{0};
}
return $new_name;
}[/code]

Next... Replace this code:
[code] $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=\"center\">");
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>");[/code]

With this code:
[code] $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=\"center\">");
print($row->initials(phy_fname));
print(" ");
print($row->initials(phy_lname));
print("</div></td>");
$client_id=($row->client_id);
print("<td height=\"14\"> <div align=\"center\">");
print($row->date);
print("</div></td>");[/code]

Tell us if it works.
Link to comment
Share on other sites

[quote author=rsammy link=topic=115083.msg468540#msg468540 date=1163620552]i wud like to show the first and last name initials for phy_fname and phy_lname in the code above! how do i do that. im not too comfortable with php yet!
[/quote]

ex
[code=php:0]print($row->phy_fname[0] . $row->phy_lname[0]);[/code]
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.