<?php
$per_page = 15;
$result = mysql_query("SELECT * FROM users_history where userid='".$_SESSION['userid']."'");
$total_results = mysql_num_rows($result);
if ($total_results > 0){
$total_pages = ceil($total_results / $per_page);
$pg = $_GET['page'];
if (isset($_GET['page']) && is_numeric($_GET['page'])){
$show_page = $_GET['page'];
if ($show_page > 0 && $show_page <= $total_pages)
{
$start = ($show_page -1) * $per_page;
$end = $start + $per_page;
}
else
{
$start = 0;
$end = $per_page;
}
}
else
{
$start = 0;
$end = $per_page;
}
echo "<div><b>View Page:</b> ";
for ($i = 1; $i <= $total_pages; $i++) {
echo "<a href='owninfo.php?page=$i'>$i</a> ";
}
$pg = $_GET['page'];
echo "</div><br>";
echo "</h1></center>";
echo "<center>Page: $pg</center>
<div style='overflow:auto;'>
<br><table border='1' cellpadding='10' width='100%'>";
echo "<tr> <th>Previous Dentist</th><th>Last Dental Visit</th><th>Name of Physician</th><th>Physican Specialty</th>
<th>Official Address</th><th>Official Number</th><th>In Good Health</th><th>Under Medical Treatment</th><th>Condition Treated</th>
<th>Had Operation</th><th>Specify Operation</th><th>Hospitalized</th><th>Why Hospitalized</th><th>Taking Prescription Medication</th>
<th>Specify Prescription</th><th>Do use Tobacoo?</th><th>Do use/drink Illegal Drugs/Alcohol?</th><th>Allergies</th>
<th>Bleeding Time</th><th>For Women</th><th>Blood Type</th><th>Blood Pressure</th><th>Health/Sick Background</th></tr>";
for ($i = $start; $i < $end; $i++){
if ($i == $total_results) {
break;
}
echo "<tr>";
echo '<td>' . mysql_result($result, $i, 'prev_dent') . '</td>';
echo '<td>' . mysql_result($result, $i, 'last_dent_visit') . '</td>';
echo '<td>' . mysql_result($result, $i, 'name_physician') . '</td>';
echo '<td>' . mysql_result($result, $i, 'physician_specialty') . '</td>';
echo '<td>' . mysql_result($result, $i, 'off_add') . '</td>';
echo '<td>' . mysql_result($result, $i, 'off_num') . '</td>';
echo '<td>' . mysql_result($result, $i, 'good_health') . '</td>';
echo '<td>' . mysql_result($result, $i, 'under_med_treatment') . '</td>';
echo '<td>' . mysql_result($result, $i, 'condition_treated') . '</td>';
echo '<td>' . mysql_result($result, $i, 'had_operation') . '</td>';
echo '<td>' . mysql_result($result, $i, 'specify_operation') . '</td>';
echo '<td>' . mysql_result($result, $i, 'hospitalized') . '</td>';
echo '<td>' . mysql_result($result, $i, 'why_hospi') . '</td>';
echo '<td>' . mysql_result($result, $i, 'prescrip_med') . '</td>';
echo '<td>' . mysql_result($result, $i, 'specify_prescrip') . '</td>';
echo '<td>' . mysql_result($result, $i, 'do_smoke') . '</td>';
echo '<td>' . mysql_result($result, $i, 'do_badvices') . '</td>';
echo '<td>' . mysql_result($result, $i, 'allergy') . '</td>';
echo '<td>' . mysql_result($result, $i, 'bleed_time') . '</td>';
echo '<td>' . mysql_result($result, $i, 'for_women') . '</td>';
echo '<td>' . mysql_result($result, $i, 'blood_type') . '</td>';
echo '<td>' . mysql_result($result, $i, 'blood_pressure') . '</td>';
echo '<td>' . mysql_result($result, $i, 'sick_bg') . '</td>';
echo '<td><a href="owninfo.php?action=edithealth&uid='.$_SESSION['userid'].'">edit health</a></td>';
echo "</tr>";
}
}else{
echo '<br/>';
echo '<center><h1>No found records for Health History</h1></center>';
}
echo "</table>";
if(isset($_REQUEST["action"]) && $_REQUEST["action"] == "edithealth" && $_REQUEST["uid"]){
$uid=$_REQUEST["uid"];
$query = mysql_query("SELECT * FROM users_history WHERE userid='$uid'") or die(mysql_error());
echo "<div style=\"overflow:scroll;height:500px;position:absolute;top:0;right:180;z-index:1;background-color:FFFFFF;border:1px solid black;\">";
echo "Edit<br/><br/>";
$aaaat = mysql_result($query, 0, 'userid');
$prevt = mysql_result($query, 0, 'prev_dent');
$lastt = mysql_result($query, 0, 'last_dent_visit');
$pnamet = mysql_result($query, 0, 'name_physician');
$pspect= mysql_result($query, 0, 'physician_specialty');
$ofaddt = mysql_result($query, 0, 'off_add');
$ofnumt = mysql_result($query, 0, 'off_num');
$healtht = mysql_result($query, 0, 'good_health');
$udtt = mysql_result($query, 0, 'under_med_treatment');
$ctreatt = mysql_result($query, 0, 'condition_treated');
$hadoperat = mysql_result($query, 0, 'had_operation');
$specoperat= mysql_result($query, 0, 'specify_operation');
$hospitt = mysql_result($query, 0, 'hospitalized');
$whospitt = mysql_result($query, 0, 'why_hospi');
$presmedt = mysql_result($query, 0, 'prescrip_med');
$sprest = mysql_result($query, 0, 'specify_prescrip');
$smoket = mysql_result($query, 0, 'do_smoke');
$vicest = mysql_result($query, 0, 'do_badvices');
$geryt = mysql_result($query, 0, 'allergy');
$btimet = mysql_result($query, 0, 'bleed_time');
$woment = mysql_result($query, 0, 'for_women');
$btypet = mysql_result($query, 0, 'blood_type');
$bpresst = mysql_result($query, 0, 'blood_pressure');
$sickt = mysql_result($query, 0, 'sick_bg');
echo "<form method='request' action='owninfo.php'>";
echo "<input type='hidden' name='aaaa' value='$aaaat'><br/>";
echo "<p>Previous Dentist:<input type='text' name='prev' value='$prevt' onkeypress='return alphaOnly(event)'></p>";
echo "<p>Last Dental Visit:<input onclick='scwShow(this,event);' name='last' value='$lastt' /></p><br/>";
echo "<p>Medical History</p>";
echo "<p>Name of Physician:<input type='text' name='pname' value='$pnamet' onkeypress='return alphaOnly(event)'></p>";
echo "<p>Specialty , If Applicable:<input type='text' name='pspec' value='$pspect' onkeypress='return alphaOnly(event)'></p>";
echo "<p>Official Address:<input type='text' name='ofadd' value='$ofaddt'></p>";
echo "<p>Official Number:<input type='text' name='ofnum' value='$ofnumt' onkeypress='return blockNonNumbers(this, event, false, false);'></p>";
echo "<p>1.Are you in good health?";
echo "<select name='health' value='$healtht'>";
echo "<option value='yes'>Yes</option>";
echo "<option value='no'>No</option>";
echo "</select></p>";
echo "<p>2.Are you under medical treatment now?";
echo "<select name='udt' value='$udtt'>";
echo "<option value='yes'>Yes</option>";
echo "<option value='no'>No</option>";
echo "</select></p>";
echo "<p>    If so, What is the condition being treated?";
echo "    <input type='text' name='ctreat' value='$ctreatt' onkeypress='return alphaOnly(event)'></p>";
echo "<p>3.Have you ever had serious illness or surgical operation?";
echo "<select name='hadopera' value='$hadoperat'>";
echo "<option value='yes'>Yes</option>";
echo "<option value='no'>No</option>";
echo "</select></p>";
echo "<p>    If so , What illness or operation?";
echo "    <input type='text' name='specopera' value='$specoperat' onkeypress='return alphaOnly(event)'></p>";
echo "<p>4.Have you ever been hospitalized?";
echo "<select name='hospit' value='$hospitt'>";
echo "<option value='yes'>Yes</option>";
echo "<option value='no'>No</option>";
echo "</select></p>";
echo "<p>    If so , when and why?";
echo "    <input type='text' name='whospit' value='$whospitt' onkeypress='return alphaOnly(event)'></p>";
echo "<p>5.Are you taking any prescription/non-prescription medication?";
echo "<select name='presmed' value='$presmedt'>";
echo "<option value='yes'>Yes</option>";
echo "<option value='no'>No</option>";
echo "</select></p>";
echo "<p>    If so , please specify";
echo "    <input type='text' name='spres' value='$sprest'onkeypress='return alphaOnly(event)'></p>";
echo "<p>6.Do you use tobacco products?";
echo "<select name='smoke' value='$smoket'>";
echo "<option value='yes'>Yes</option>";
echo "<option value='no'>No</option>";
echo "</select></p>";
echo "<p>7.Do you use/drink alcohol,cocaine or other dangerous drugs?";
echo "<select name='vices' value='$vicest'>";
echo "<option value='yes'>Yes</option>";
echo "<option value='no'>No</option>";
echo "</select></p>";
echo "<p>8.Are you allergic to any of the following:<br/>";
echo "<input type='checkbox' name='allergy[]' value='Anesthetic' />Local Anesthetic (ex. Lidocaine)";
echo "<input type='checkbox' name='allergy[]' value='sulfa'/> Sulfa Drugs<br />";
echo "<input type='checkbox' name='allergy[]' value='penicillin' /> Penicillin.Antibiotics ";
echo "<input type='checkbox' name='allergy[]' value='aspirin' />Aspirin";
echo "<input type='checkbox' name='allergy[]' value='latex' />Latex <br/>";
echo "Others<input type='text' name='allergy[]' onkeypress='return alphaOnly(event)'></p>";
echo "<p>9.Bleeding time";
echo "<input type='text' name='btime' value='$btimet'/></p>";
echo "<p>10.For women only:<br/>";
echo "    Are you pregnant?";
echo "    <select name='for_women1'>";
echo " <option value='Yes Pregnant'>Yes</option>";
echo "<option value='Not Pregnant'>No</option>";
echo "</select>";
echo "<br/>";
echo "    Are you nursing?";
echo "    <select name='for_women2'>";
echo "<option value='Yes Nursing'>Yes</option>";
echo "<option value='Not Nursing'>No</option>";
echo "</select><br/>";
echo "    Are you taking birth control pills?";
echo "    <select name='for_women3'>";
echo "<option value='yes taking cp'>Yes</option>";
echo "<option value='not taking cp'>No</option>";
echo "</select>";
echo "</p>";
echo "<p>11.Blood type";
echo "<select name='btype' value='$btypet'>";
echo "<option value='a'>A</option>";
echo "<option value='b'>B</option>";
echo "<option value='o'>O</option>";
echo "<option value='ab'>AB</option>";
echo "</select>";
echo "</p>";
echo "<p>12.Blood Pressure";
echo "<input type='text' name='bpress' value='$bpresst'onkeypress='return blockNonNumbers(this, event, false, false);'>";
echo "</p>";
echo "<p>13.Do you have or have you had any of the following? Check which apply<br/>";
echo "<input type='checkbox' name='sick_bg[]' value='highbloodpressur' />High Blood Pressure";
echo "<input type='checkbox' name='sick_bg[]' value='lowbloodpressure' />Low Blood Pressure<br />";
echo "<input type='checkbox' name='sick_bg[]' value='highbloodpressure' />Heart Disease";
echo "<input type='checkbox' name='sick_bg[]' value='lowbloodpressure' />Asthma<br />";
echo "Others:";
echo "<input type='text' name='sick_bg[]' onkeypress='return alphaOnly(event)'></p>";
echo "<input type='submit' name='omitz'/>";
echo "<a href='owninfo.php'><input type='button' value='back'/></a>";
echo "</form>";
echo "</div>";
}
if(isset($_POST['omitz'])) {
$id = mysql_real_escape_string(stripslashes($_POST['aaaa']));
$prev_dent= mysql_real_escape_string(stripslashes($_POST['prev']));
$last_dent_visit= mysql_real_escape_string(stripslashes($_POST['last']));
$name_physician= mysql_real_escape_string(stripslashes($_POST['pname']));
$physician_specialty= mysql_real_escape_string(stripslashes($_POST['pspec']));
$off_add= mysql_real_escape_string(stripslashes($_POST['ofadd']));
$off_num= mysql_real_escape_string(stripslashes($_POST['ofnum']));
$good_health= mysql_real_escape_string(stripslashes($_POST['health']));
$under_med_treatment= mysql_real_escape_string(stripslashes($_POST['udt']));
$condition_treated= mysql_real_escape_string(stripslashes($_POST['ctreat']));
$had_operation= mysql_real_escape_string(stripslashes($_POST['hadopera']));
$specify_operation= mysql_real_escape_string(stripslashes($_POST['specopera']));
$hospitalized= mysql_real_escape_string(stripslashes($_POST['hospit']));
$why_hospi= mysql_real_escape_string(stripslashes($_POST['whospit']));
$prescrip_med= mysql_real_escape_string(stripslashes($_POST['presmed']));
$specify_prescrip= mysql_real_escape_string(stripslashes($_POST['spres']));
$do_smoke= mysql_real_escape_string(stripslashes($_POST['smoke']));
$do_badvices= mysql_real_escape_string(stripslashes($_POST['vices']));
$bleed_time= mysql_real_escape_string(stripslashes($_POST['btime']));
$blood_type= mysql_real_escape_string(stripslashes($_POST['btype']));
$blood_pressure= mysql_real_escape_string(stripslashes($_POST['bpress']));
$for_women = $_POST['for_women3']."|".$_POST['for_women1']."|".$_POST['for_women2'];
$allergys = $_POST['allergy'];
$allerstore;
$x = count($allergys);
for($i=0; $i < $x; $i++)
{
$allerstore.=$allergys[$i]."|";
}
$sickdaw = $_POST['sick_bg'];
$sickstore;
$x = count($sickdaw);
for($i=0; $i < $x; $i++){
$sickstore.=$sickdaw[$i]."|";
}
$sql = "SELECT off_num FROM users_history WHERE off_num='".mysql_real_escape_string($_POST['off_num'])."'";
$query = mysql_query($sql) or die(mysql_error());
$m_count = mysql_num_rows($query);
if($m_count >= "1"){
echo "The Number is already exist choose another one";
}else
echo $for_woman;
mysql_query("UPDATE users_history SET userid='$id',prev_dent='$prev_dent'
,last_dent_visit='$last_dent_visit',name_physician='$name_physician',physician_specialty='$physician_specialty',
off_add='$off_add',off_num='$off_num',good_health='$good_health',under_med_treatment='$under_med_treatment',condition_treated='$condition_treated',had_operation='$had_operation',
specify_operation='$specify_operation',hospitalized='$hospitalized',why_hospi='$why_hospi',prescrip_med='$prescrip_med',
specify_prescrip='$specify_prescrip',do_smoke='$do_smoke',do_badvices='$do_badvices',allergy='$allerstore',bleed_time='$bleed_time',for_women='$for_women',blood_type='$blood_type',blood_pressure='$blood_pressure',sick_bg='$sickstore'");
echo '<meta http-equiv="refresh" content="0;url=owninfo.php">';
exit;
}
echo "</div>";
?>
only problem is my update fails either the column where it goes being erase or the table won't update at all.

New Topic/Question
Reply




MultiQuote




|