
May 8th, 2008, 05:15 AM
|
|
Registered User
|
|
Join Date: Apr 2008
Posts: 45
Time spent in forums: 10 h 50 m 27 sec
Reputation Power: 0
|
|
this is code of INSERT
PHP Code:
<!-- the part of php code that get and set from data bse -->
<?
include("../DBAccess.php");
if(isset($_POST["DocName"])){
if($_POST["DocName"]!=""){
// Stories
mysql_pconnect("localhost","","")or die("لم يتم اتصالك");
mysql_select_db("eoc");
$m_sql = "SELECT * FROM appointment WHERE Time='". $_POST['Time'] ."'";
$m_query = mysql_query($m_sql);
if (!$m_query) {
echo "<script>window.alert('error');</script>";
}
else{
$m_rows_count = mysql_num_rows($m_query);
if ($m_rows_count > 0) {
echo "<script>window.alert('اuse another appointment);</script>";
}
else {
$query="INSERT INTO `appointment` ( `ANO` , `DocNO`,`DocName` ,`Date` ,`Time` ,`FileNO` ,`PationtName` )VALUES ('', '".$_POST["DocNO"]."', '".$_POST["DocName"]."', '".$_POST["Date"]."', '".$_POST["Time"]."', '".$_POST["FileNO"]."', '".$_POST["PationtName"]."')";
mysql_query($query);
echo "<script>window.alert('add ');</script>";
}
}
}
else
{
echo "<script>window.alert('fill text');</script>";
}
}
?>
<!-- end of php code -->
<!-- start HTML code that include the FORM -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" type="text/javascript" src="datetimepicker.js">
</script>
<script language="JavaScript">
<!--
function change_doctor(ref)
{
document.getElementById('DocName').value = ref;
}
function change_pationt(ref)
{
document.getElementById('PationtName').value = ref;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<title>:: ::</title>
<style type="text/css">
<!--
.style1 {
color: #FFFFFF;
font-weight: bold;
}
.style2 {color: #FFFFFF}
body {
background-image: url(../images/black.JPG);
}
.style3 {font-family: Tahoma}
-->
</style>
</head>
<body background="../images/0201_01.jpg" dir="rtl">
<table width="745" border="0" dir="rtl" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td>
<form id="form1" name="form1" method="post" action="<? echo $_SERVER["PHP_SELF"]; ?>" >
<table width="745" border="0" align="center" dir="rtl">
<tr>
<td colspan="6" background="../images/bg.gif"><div align="center" class="style1 style2 style3">add new/div></td>
</tr>
<tr><td height="20"></td>
<td></td>
<td><?php
if(isset($_POST["Submit"])){
echo "$message;";
}
?><td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td width="16%" background="../images/bg.JPG" bgcolor="#0066FF"><div align="center" class="style1">
<div align="center">emp no </div>
</div></td>
<td width="1%"><div align="center" class="style2"><strong>:</strong></div></td>
<td><select name="DocNO" onChange="change_doctor(this.value);" style="background:#CCCCFF">
<?
$query="SELECT * FROM employee";
$result=mysql_query($query) or die("error: " . mysql_error());
while($row=mysql_fetch_array($result))
{
echo "Error";
?>
<option value="<?php echo $row['EmpName'] ; ?>"><?php echo $row['EMP'] ; ?></option>
<?
}
?>
</select></td>
<td background="../images/bg.JPG"><div align="center" class="style2 style2"><strong>emp name</strong></div></td>
<td><span class="style2">:</span></td>
<td><label>
<input name="DocName" type="text" id="DocName" style="background:#CCCCFF"/>
</label></td>
</tr>
<tr>
<td background="../images/bg.JPG" bgcolor="#0066FF"><div align="center" class="style1">
<div align="center">date</div>
</div></td>
<td><div align="center" class="style2"><strong>:</strong></div></td>
<td><input id="Date" name="Date" type="text" size="25" style="background:#CCCCFF">
<a href="javascript:NewCal('Date','ddmmyyyy')"><img src="../images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a></td>
<td background="../images/bg.JPG" bgcolor="#0066FF"><div align="center" class="style1 style2">
<div align="center">time</div>
</div></td>
<td><span class="style2">:</span></td>
<td><label>
<input type="text" name="Time" style="background:#CCCCFF"/>
</label></td>
</tr>
<tr>
<td background="../images/bg.JPG" bgcolor="#0066FF"><div align="center" class="style1">
<div align="center">fileno </div>
</div></td>
<td><div align="center" class="style2"><strong>:</strong></div></td>
<td><label>
<select name="FileNO" onChange="change_pationt(this.value);" style="background:#CCCCFF">
<?
$query="SELECT * FROM pationt";
$result=mysql_query($query) or die("error: " . mysql_error());
while($row=mysql_fetch_array($result))
{
echo "Error";
?>
<option value="<?php echo $row['Name'] ; ?>"><?php echo $row['FileNo'] ; ?></option>
<?
}
?>
</select></label></td>
<td background="../images/bg.JPG" bgcolor="#0066FF"><div align="center" class="style1 style2">
<div align="center">pationt name </div>
</div></td>
<td><span class="style2">:</span></td>
<td>
<input name="PationtName" type="text" id="PationtName" style="background:#CCCCFF"/> </td>
</tr>
<tr>
<td colspan="6"></td>
</tr>
<tr>
<td colspan="6"><div align="center"></div></td>
</tr>
<tr>
<td colspan="6">
<div align="center">
<input type="submit" name="Submit" value=".:ok:." />
<input type="button" name="back" value=".:back:." src="appointment.php" />
</div></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
and the code of display is :-
PHP Code:
<?
include("../DBAccess.php");
$tbl_name="appointment"; // Table name
$query="select * from $tbl_name";
$result=mysql_query($query);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<title>:: ::</title>
<style type="text/css">
<!--
.style2 {
color: #FFFFFF;
font-weight: bold;
}
body {
background-image: url(../images/black.JPG);
}
.style4 {font-family: Tahoma}
-->
</style></head>
<body dir="rtl" background="../images/0201_01.jpg">
<table width="745" border="0" align="center" >
<tr>
<td background="../images/bg.gif"><div align="center" class="style2">
<p class="style4">display </p>
</div></td>
</tr>
<tr>
<td>
<table width="745" border="1" bordercolor="#666666">
<tr>
<td width="245" background="../images/bg.JPG" bgcolor="#0066FF"><div align="center" class="style2">doc name </div></td>
<td width="179" background="../images/bg.JPG" bgcolor="#0066FF"><div align="center" class="style2">date</div></td>
<td width="147" background="../images/bg.JPG" bgcolor="#0066FF"><div align="center" class="style2">time</div></td>
<!-- <td width="103" background="../images/bg.JPG" bgcolor="#0066FF"><div align="center" class="style2">file no </div></td>-->
<td width="140" background="../images/bg.JPG" bgcolor="#0066FF"><div align="center" class="style2"> name of pationt</div></td>
</tr>
<?
$i=0;
while($row=mysql_fetch_array($result)){
$i++;
?>
<tr>
<td bgcolor="#99CCFF" ><div align="center"><em><strong><?php echo $row["DocName"]; ?></strong></em></div></td>
<td bgcolor="#CCCCFF" ><div align="center"><em><strong><?php echo $row["Date"]; ?></strong></em></div></td>
<td bgcolor="#99CCFF" ><div align="center"><em><strong><?php echo $row["Time"]; ?></strong></em></div></td>
<!-- <td bgcolor="#CCCCFF" ><div align="center"><em><strong><?php echo $row["FileNo"]; ?></strong></em></div></td>-->
<td bgcolor="#99CCFF" ><div align="center"><em><strong><?php echo $row["PationtName"]; ?></strong></em></div></td>
</tr>
<?
}
?>
</table></td>
</tr>
</table>
<div align="center">
<input type="button" name="back" value=".:back:." src="appointment.php" />
</div>
</div>
</body>
</html>
|