473,385 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

selected

47
[PHP]<?php require_once('Connections/mas.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);

$logoutGoTo = "login.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;

// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}

$MM_restrictGoTo = "login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["name"])) && ($_POST["name"] != "")) {
$insertSQL = sprintf("INSERT INTO medic_block_reg (matric_no, name, sessi, `year`, `group`) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['matric'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['sessi'], "text"),
GetSQLValueString($_POST['year'], "text"),
GetSQLValueString($_POST['group'], "int"));

$insertSQL2 = sprintf("INSERT INTO medic_registered_course (matric_no, name, sessi, `year`,`s_code`, `group`) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['matric'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['sessi'], "text"),
GetSQLValueString($_POST['year'], "text"),
GetSQLValueString($_POST['s_code'], "text"),
GetSQLValueString($_POST['group'], "int"));

mysql_select_db($database_mas, $mas);
$Result1 = mysql_query($insertSQL, $mas) or die(mysql_error());
$Result2 = mysql_query($insertSQL2, $mas) or die(mysql_error());
$saved = true;
}
if ((isset($_POST["name"])) && ($_POST["name"] == "")) {
$colname_rs_mas = "-1";
if (isset($_POST['matric'])) {
$colname_rs_mas = (get_magic_quotes_gpc()) ? $_POST['matric'] : addslashes($_POST['matric']);
}
mysql_select_db($database_mas, $mas);
$query_rs_mas = sprintf("SELECT matric_no, name FROM medic_student WHERE matric_no = '%s'", $colname_rs_mas);
$rs_mas = mysql_query($query_rs_mas, $mas) or die(mysql_error());
$row_rs_mas = mysql_fetch_assoc($rs_mas);
$totalRows_rs_mas = mysql_num_rows($rs_mas);

$colname_scode = "-1";
if (isset($_POST['year'])) {
$colname_scode = $_POST['year'];
}
mysql_select_db($database_mas, $mas);
$query_scode = sprintf("SELECT `year`, s_code FROM medic_subject_offered WHERE `year` = %s", GetSQLValueString($colname_scode, "text"));
$scode = mysql_query($query_scode, $mas) or die(mysql_error());
$row_scode = mysql_fetch_assoc($scode);
$totalRows_scode = mysql_num_rows($scode);

}


?>

<!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=iso-8859-1" />
<title>Block Registration | Medic Assessment System</title>
<link href="css/lgblue.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif}
.style10 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; }
.style12 {font-family: Arial, Helvetica, sans-serif; font-size: 14px; }
.style16 {font-size: 18px;
color: #000000;
}
.style8 {font-family: Arial, Helvetica, sans-serif; font-size: 10; }
.style17 {
font-style: italic;
font-size: small;
font-weight: bold;
}
.style18 {
font-size: 14px;
font-weight: bold;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
body,td,th {
color: #996600;
}
.style23 {color: #000000}
.style25 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; }
.style26 {
font-size: 12px;
font-weight: bold;
color: #000000;
}
.style28 {color: #000000; font-weight: bold; }
-->
</style>
<script type="text/JavaScript">
<!--
function MM_popupMsg(msg) { //v1.0
alert(msg);
}
function MM_controlSound(x, _sndObj, sndFile) { //v3.0
var i, method = "", sndObj = eval(_sndObj);
if (sndObj != null) {
if (navigator.appName == 'Netscape') method = "Play";
else {
if (window.MM_WMP == null) {
window.MM_WMP = false;
for(i in sndObj) if (i == "ActiveMovie") {
window.MM_WMP = true; break;
} }
if (window.MM_WMP) method = "play";
else if (sndObj.FileName) method = "run";
} }
if (method) eval(_sndObj+"."+method+"()");
else window.location = sndFile;
}
//-->
</script>

<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>

<body <?php if($saved){echo 'onload="alert(\'One record successfully saved.\');"';}?>>
<form id="form1" name="form1" method="POST">
<div align="center">
<p>&nbsp;</p>
<table width="456" height="458" align="center" bordercolor="#CCFFCC" class="boxads">
<tr>
<td height="46" colspan="5" bgcolor="#FFFFCC"><p align="center" class="style16">&nbsp;</p>
<p align="center" class="style16 style18">Medic Assessment System </p>
<p align="center" class="style16">&nbsp;</p></td>
</tr>
<tr>
<td height="29" colspan="5" bgcolor="#FFFFFF" class="style12"><div align="center" class="style10"><span class="style17 style23">Block Registration</span></div>
<span class="style8">
<label></label>
</span><span class="style8">
<label></label>
</span><span class="style1"></span><span class="style1">
<label></label>
</span>
<div align="center" class="style17"></div></td>
</tr>
<tr>
<td width="82" height="39" bgcolor="#CCFFCC"><div align="right" class="style26">Matric No</div></td>
<td width="11" bgcolor="#CCFFCC"><div align="center" class="style26">:</div></td>
<td colspan="3" bgcolor="#CCFFCC"><div align="left">
<input name="matric" type="text" class="style26" id="matric" value="<?php echo $row_rs_mas['matric_no']; ?>" size="15" />
</div></td>
</tr>
<tr>
<td height="38" bgcolor="#CCFFCC"><div align="right" class="style26">Name</div></td>
<td width="11" bgcolor="#CCFFCC"><div align="center" class="style26">:</div></td>
<td colspan="3" bgcolor="#CCFFCC"><div align="left">
<p>
<input name="name" type="text" class="style26" id="name" value="<?php echo $row_rs_mas['name']; ?>" size="50"/>
</p>
</div></td>
</tr>
<tr>
<td height="174" bgcolor="#CCFFCC"><div align="right"><span class="style26">Sessi</span></div></td>
<td bgcolor="#CCFFCC"><div align="center" class="style26"><strong>:</strong></div></td>
<td bgcolor="#CCFFCC"><div align="left">
<input name="sessi" type="text" class="style26" id="sessi" size="15" maxlength="9" />
</div></td>
<td bgcolor="#CCFFCC"><div align="right"><span class="style26">Year:</span></div></td>
<td bgcolor="#CCFFCC"><p>&nbsp;
</p>
<p>&nbsp;</p>
<p>
<select name="year" class="style26" id="year" value="<?php echo $row_scode['year']; ?>" >
<option value="-"> - </option>
<option value="1 block 1"> 1 block 1</option>
<option value="1 block 2"> 1 block 2</option>
<option value="1 block 3"> 1 block 3</option>
<option value="1 block 4"> 1 block 4</option>
<option value=" - "> - </option>
<option value="2 block 1"> 2 block 1</option>
<option value="2 block 2"> 2 block 2</option>
<option value="2 block 3"> 2 block 3</option>
<option value="2 block 4"> 2 block 4</option>
<option value="- "> - </option>
<option value="3 block 1"> 3 block 1</option>
<option value="3 block 2"> 3 block 2</option>
<option value="3 block 3"> 3 block 3</option>
<option value="3 block 4"> 3 block 4</option>
<option value=" - "> - </option>
<option value="4 block 1"> 4 block 1</option>
<option value="4 block 2"> 4 block 2</option>
<option value="4 block 3"> 4 block 3</option>
<option value="4 block 4"> 4 block 4</option>
<option value="4 block 5"> 4 block 5</option>
<option value="4 block 6"> 4 block 6</option>
<option value="4 block 7"> 4 block 7</option>
<option value=" - "> - </option>
<option value="5 block 1"> 5 block 1</option>
<option value="5 block 2"> 5 block 2</option>
<option value="5 block 3"> 5 block 3</option>
<option value="5 block 4"> 5 block 4</option>
<option value="5 block 5"> 5 block 5</option>
</select>
</p>
<p>
<input name="s_code" type="text" class="style26" id="s_code" value="<?php echo $row_scode['s_code']; ?>"/>
</p>
<p>&nbsp;</p></td>
</tr>

<tr>
<td height="29" bgcolor="#CCFFCC"><div align="right" class="style26">Group</div></td>
<td bgcolor="#CCFFCC"><div align="center" class="style26">:</div></td>
<td width="90" bgcolor="#CCFFCC"><div align="left">
<p class="style25">
<select name="group" size="1" class="style26" id="group">
<option value="-">-</option>
<option value="1" >1</option>
<option value="2" >2</option>
<option value="3" >3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</p>
</div></td>
<td width="65" bgcolor="#CCFFCC"><div align="right"></div></td>
<td width="184" bgcolor="#CCFFCC">&nbsp;</td>
</tr>

<tr>
<td height="32" colspan="5" bgcolor="#CCFFCC"><div align="center">
<input name="save" type="submit" class="style26" id="save" value="Save" />
<input name="Reset" type="reset" class="style26" value="Reset" />
</div>
<div align="center"></div></td>
</tr>
</table>
<div align="center">
<p>&nbsp;</p>
<p class="style10"><a href="reg_main.php">Back</a> | <a href="main.php">Module Menu</a> | <a href="reg_query.php"> View Registered Student</a> | <a href="<?php echo $logoutAction ?>" onclick="MM_controlSound('play','document.CS121055 9072500','Windows Notify.wav');MM_popupMsg('You\'re successfully logout from this system...')">Logout</a></p>
</div>
<p align="center">&nbsp;</p>
</div>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<embed name="CS1210559072500" src="Windows Notify.wav" loop="false" autostart="false" hidden="true" width="0" height="0" enablejavascript="true"></embed>
</body>

<?php
if ((isset($_POST["block"])) && ($_POST["block"] == "")) {
mysql_free_result($rs_mas);

mysql_free_result($scode);

}

?>
</html>[/PHP]

how can i make when i enter matric no,then automatic appear those name who belong to the matric_no and when i select the drop down menu,automatic appear the data...
Jul 23 '08 #1
3 1498
r035198x
13,262 8TB
If the dynamic values are coming from the database then you need to use AJAX.
Jul 23 '08 #2
azura
47
how i want to use ajax because i'm very not familiar with ajax.. i'm also new in php..perhaps u can show how it works.
Jul 23 '08 #3
r035198x
13,262 8TB
how i want to use ajax because i'm very not familiar with ajax.. i'm also new in php..perhaps u can show how it works.
In short:
You need to change the data displayed on your page by making a call to the database to retrieve the new data. Traditionally you'd have to provide a submit button and submit the whole page to some server side script which can connect to the database and retrieve the values for you (because Javascript cannot connect to databases). AJAX allows you to call a server side script and retrieve the results without submitting the whole page. The user doesn't have to submit the whole form and wait for the results but they just fire a Javascript event, like for example onChange on a select, and the Javascript function calls the server side script which returns the values to the Javascript function that called it. This function can then use that data to make the page changes.

Read the AJAX tutorial from w3schools for a more detailed explanation.
If you get problems implementing it, you can post in the Javascript forum.
Jul 23 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Stanley J Mroczek | last post by:
I have tried this with no luck. What i want is to show the selected item on the first post. the selected item is NY but the first in the list shows as selected. If Page.IsPostBack = False Then...
15
by: TJ Walls | last post by:
Hello All, Is it possible to create a <select> element with no selected options? I have tried setting the selectedIndex attribute to -1, but as far as I can tell this only works for <select...
1
by: smash2004 | last post by:
I want to keep selected values in select list when i click on another option...with a click on a mouse... if i have 3 options in select list and i click first option..it gets selected..if i then...
8
by: McKirahan | last post by:
Firefox does not reflect selected option via innerHTML How do I get Firefox to reflect selected option values? <html> <head> <title>FFinner.htm</title> <script type="text/javascript">...
10
by: dhnriverside | last post by:
Hi guys Still having a problem with this dropdownlist. Basically, I've got 4. The first 2 work fine, then my code crashes on the 3rd. ddlEndTimeHour.Items.FindByValue(endTime).Selected =...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
2
by: John | last post by:
I have a listbox that is databound when my form loads. A user can then select and option using a drop down box. When the user selects an option the corresponding items in the listbox gets selected....
2
by: sicapitan | last post by:
FYI, with something like this: hotelement = "hotelement"+hotcount; hotspot = Builder.node('div', { id:'hotspot'+hotcount, className:'hotspot', style:''+divstyle }, ) ]);
6
by: artev | last post by:
if I have a select with more options, how I can know if is there an option selected; is necessary a cycle? or is there an inner property?
1
by: angelicdevil | last post by:
i have listbox 1 which displays status , based on selection of status listbox 2 displays usernames. and based on username selected the textbox displays the email id. its working fine till...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.