By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,600 Members | 1,887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,600 IT Pros & Developers. It's quick & easy.

automatic appear

P: 47
Expand|Select|Wrap|Line Numbers
  1. <input name="matric" type="text" class="style26" id="matric" value="<?php echo $row_rs_mas['matric_no']; ?>" size="15" /> 
<------ this input that i insert those matric_no

Expand|Select|Wrap|Line Numbers
  1. <input name="name" type="text" class="style26" id="name" value="<?php echo $row_rs_mas['name']; ?>" size="50"/>
<------ appear automatic when I insert the matric_no..

my problem is how to make it automatically appear when insert matric_no
Jul 23 '08 #1
Share this Question
Share on Google+
25 Replies


P: 77
where do you want to appear that value???is it in input or what type of tag??

if you want to appear the value of matric_no (input), than you can use the div or something tag to store that value...
Jul 23 '08 #2

P: 47
yup.. i want to appear dynamically value in that input"name"..like this.. if i key in matric no, then dynamically appear those name... those name n matric are in database
Jul 23 '08 #3

P: 77
yup.. i want to appear dynamically value in that input"name"..like this.. if i key in matric no, then dynamically appear those name... those name n matric are in database

i see, so you want to appear the name that you input from textfield and get + check the name whether it is in the database or not,, i think you must use AJAX, and you just need to learn that things in this URL

AJAX

kind regards,
mamin
Jul 23 '08 #4

P: 47
Expand|Select|Wrap|Line Numbers
  1.  var url="gethint.asp";
  2. url=url+"?q="+str;
  3. url=url+"&sid="+Math.random();
  4. xmlHttp.onreadystatechange=stateChanged;
  5. xmlHttp.open("GET",url,true);
  6. xmlHttp.send(null);
what this function are for??? because i had try so many time but still error..i'm new ni ajax..please help me...
Jul 23 '08 #5

gits
Expert Mod 5K+
P: 5,343
basicly it starts a XMLHttpRequest in the background to invoke the code that is found at the 'url'. you assign a callback-function to the onreadystatechange-property of the request-object and this function is called every time the state of the request-object changes. the code you posted is not enough ... you need the full code from an example ... post how you tried to make the call with all relevant lines ...

kind regards
Jul 23 '08 #6

P: 47
before this i tried to make with some button but my boss doesn't want those button... so he want to make those data dynamically appear... i'm very newbie in java n ajax.. i'm so stuck right now!
Jul 23 '08 #7

gits
Expert Mod 5K+
P: 5,343
post what you have tried so far ... may be just use a textbox and try to demonstrate your attempt and tell us where you're stuck ... so that we may help you with your particular problem ...

kind regards
Jul 23 '08 #8

P: 47
[HTML]


<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="436" 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="35" 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="32" 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>
//this part i want to make dynamically appear
<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="114" 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>
//this part i want to make dynamically appear
<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="27" 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="73" bgcolor="#CCFFCC"><div align="right"></div></td>
<td width="176" bgcolor="#CCFFCC">&nbsp;</td>
</tr>

<tr>
<td height="24" 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>

</html> [/HTML]
hurm i send my coding... there is 2 part which i want to make it dynamically appear..
Jul 23 '08 #9

P: 47
anybody can help me??
Jul 25 '08 #10

gits
Expert Mod 5K+
P: 5,343
so what you want is that you put in the matric_no and then the corresponding textboxes name and s_code should be populated automatically.

the general idea is the following:

1. onchange of the textbox matric_no call a js-function that starts a XMLHttpRequest and retrieves the data from the database

2. in the callbackfunction of that request you process the responseText and fill in the data into the corresponding fields ...

are you familiar with such an ajax-call? did you use/try that before?

kind regards
Jul 25 '08 #11

P: 47
yup you right! when i put matric_no textfield name will automatically appear the name so with if i select year,s_code will automatically appear...

i'm not familiar with ajax and that's why i need somebody help me.... urgent and really urgent....plezzzz!!!
Jul 26 '08 #12

gits
Expert Mod 5K+
P: 5,343
ok ... so let me give you a short example, it uses GET and requests just a local file called test.txt where you could put in any text ... when the request is ready it will put this text from the file into the second textbox ... as you see it is quite simple to use the XMLHttpRequest ... note: this example just works with browsers like FF/Safari/Opera (that have a native XMLHttpRequest-Object) since i didn't implement the request-initialisation for IE

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function _get_request_obj() {
  5.     var obj = null;
  6.  
  7.     if (typeof window.XMLHttpRequest != 'undefined') {
  8.         obj = new XMLHttpRequest;
  9.     } else if (typeof window.ActiveXObject != 'undefined') {
  10.         // MS specific trunk to init a request-object
  11.     }
  12.  
  13.     return obj;
  14. }
  15.  
  16. function get_data(val, id) {
  17.     var obj = _get_request_obj();
  18.  
  19.     if (obj == null) {
  20.         alert('currently no ajax-call supported');
  21.     } else {
  22.         _request_data(obj, val, id);
  23.     }
  24. }
  25.  
  26. function _request_data(req, val, id) {
  27.     var qs = 'test.txt?val=' + val;
  28.  
  29.     req.open('GET', qs, true);
  30.     req.onreadystatechange = function() {
  31.         if (this.readyState == 4) {
  32.             var result_box = document.getElementById(id);
  33.             result_box.value = this.responseText;
  34.         }
  35.     };
  36.     req.send(null);
  37. }
  38.  
  39. </script>
  40. </head>
  41. <body>
  42.     <form>
  43.         <input type="text" id="my_box_1" onchange="get_data(this.value, 'my_result');"/>
  44.         <input type="text" id="my_result"/>
  45.     </form>
  46. </body>
  47. </html>
  48.  
kind regards
Jul 26 '08 #13

P: 47
what if i want to implement with ff and ie?? sorry i still don't get it... if i implement your example in my line, which want should i change..?? test.txt stand for what??
Jul 26 '08 #14

gits
Expert Mod 5K+
P: 5,343
1. test.txt stands for the requested program ... so qs has to be your querystring (probably a php-file and some get-params in case you want to use GET) ...

2. for IE you have to create an instance of an ActiveX object like this (that would replace the comment in line 10):

Expand|Select|Wrap|Line Numbers
  1. try {
  2.     obj = new ActiveXObject('Msxml2.XMLHTTP');
  3. } catch (ex) {
  4.     try {
  5.         obj = new ActiveXObject('Microsoft.XMLHTTP');
  6.     } catch (ex) {
  7.     }
  8. }
note: make an attempt and show what you have done ... at this forum nobody is supposed to do your work for you or give you a complete solution ... with the currently given example you could simulate one test for your requirement ... just try to adapt it to your problem and show the code that is not working and ask specific questions ... a thread like this is not the appropriate place to give you a complete ajax-tutorial ... so you need to search for some basic information for your own ... ok?

kind regards
Jul 26 '08 #15

P: 47
oh ok..sorry because i'm newbie to the forum.. so thanks for your help
Jul 26 '08 #16

gits
Expert Mod 5K+
P: 5,343
there is no problem and there is no need to apologize ... just come back when you have specific questions about the correct implementation of the code i showed you ... and post what you have tried so far to get it to work ... the general idea is to let you learn something ... i'm happy to explain everything to you but i should have at least the 'feeling' that you are interested in it and try to understand the code ... vs just waiting to get a copy and paste script ...

kind regards
Jul 26 '08 #17

P: 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 = $_POST['matric'];
}
mysql_select_db($database_mas, $mas);
$query_rs_mas = sprintf("SELECT matric_no, name FROM medic_student WHERE matric_no = %s ORDER BY `id` ASC" , GetSQLValueString($colname_rs_mas, "text"));
$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);

if ((isset($_POST["s_code"])) && ($_POST["s_code"] == ""))
$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="clienthint.js">
var xmlHttp

function showHint(str)
{
if (str.length==0)
{
document.getElementById("txtHint").innerHTML=""
return
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="gethint.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("txtHint").innerHTML=xmlHt tp.responseText
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
</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="347" align="center" bordercolor="#CCFFCC" class="boxads">
<tr>
<td height="65" 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="35" 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 type="text" id="txt1"
onkeyup="showHint(this.value)">
</div></td>
</tr>
<tr>
<td height="33" 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>
<span id="txtHint"></span>
</p>
</div></td>
</tr>
<tr>
<td height="114" 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" >
<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="27" 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="73" bgcolor="#CCFFCC"><div align="right"></div></td>
<td width="176" bgcolor="#CCFFCC">&nbsp;</td>
</tr>

<tr>
<td height="24" 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]

i had followed all the basic that i had learn it work if i want to search a name.. what should i do if i want to enter matric(number) and appear those name which are in the databse....
Jul 28 '08 #18

P: 47
i got it! it work! but why can't save into database? it's say name cannot be null... how i'm gonna fix it...?
Jul 29 '08 #19

gits
Expert Mod 5K+
P: 5,343
first: well done :) glad to hear you got it working ... to your question: it seems to be a query-problem ... are all params passed correctly? i think its an insert and is 'name' a db-field? could you show the query and how it is build up in the php?

kind regards
Jul 29 '08 #20

P: 47
[PHP]
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"));[/PHP]

actually i not done with matric but i tried using drop down menu and use ajax to display infomation.. it woked nicely..!! thanks.. but matric no i now still trying... hehhehe... so sudenlly i got stuck with how to save it.. because it said that s_code can't be null...my registration flow should be like this.. if admin insert data then when they selected one of the drop menu list, it automatic display info about the selected list... but when i click button save, the automatic display(s_code) cannot be insert in database..error:s_code cannot be null?? can you explain what's wrong..???
Jul 29 '08 #21

gits
Expert Mod 5K+
P: 5,343
is s_code posted to the php-script correctly? is the s_code field filled in the form before you submit it?
Jul 29 '08 #22

P: 47
the s_code is automatic display which is connected to the selected year...s_code i'm using ajax.. currently i have 3 pages to do this ajax... then i implement into the original page.. so i had paste my script java to the original page..but the php page i do not implement into the original page..should i paste it same as the ajax script or not??
Jul 30 '08 #23

acoder
Expert Mod 15k+
P: 16,027
Where's the code that makes the call to save into the database? Show the generated client-side version.
Jul 31 '08 #24

P: 47
it's ok.... it's already work!! thanks guys
Aug 1 '08 #25

acoder
Expert Mod 15k+
P: 16,027
That's good news. Can you post what was causing the problem and how you solved it? Thanks.
Aug 1 '08 #26

Post your reply

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