zura_84 0 Report post Posted June 23, 2008 <?php require_once('Connections/mas.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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; } } ?> <? $usr = "root"; $pwd = "123"; $db = "mas"; $host = "localhost"; $cid = mysql_connect($host,$usr,$pwd); if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); } $matric = $_POST['matric_no']; $block = $_POST['block']; $s_code = $_POST['s_code']; $sessi = $_POST['sessi']; $year = $_POST['year']; $group = $_POST['group']; $SQL = ("INSERT INTO medic_registered_course "); $SQL = $SQL . " (`matric_no`, `block`, `s_code`, `sessi`, `year`, `group`) VALUES "; $SQL = $SQL . " ('$matric_no', '$block','$s_code','$sessi', '$year', '$group') "; $result = mysql_db_query($db,"$SQL" ,$cid); ?> <?php mysql_select_db($database_mas, $mas); $query_terd = "SELECT medic_block_reg.matric_no, medic_block_reg.block, medic_block_reg.name,medic_subject_offered.s_code, medic_block_reg.sessi, medic_block_reg.`year`, medic_block_reg.`group`, medic_block_reg.status, medic_subject_offered.s_title FROM medic_block_reg, medic_subject_offered ORDER BY `matric_no` ASC"; $terd = mysql_query($query_terd, $mas) or die(mysql_error()); $row_terd = mysql_fetch_assoc($terd); $totalRows_terd = mysql_num_rows($terd); if (isset($_POST['matric_no'])) { $colname_gre = $_POST['matric_no']; } mysql_select_db($database_mas, $mas); $query_gre = sprintf("SELECT * FROM medic_block_reg WHERE matric_no = %s", GetSQLValueString($colname_gre, "text")); ?> <!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=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style1 { font-size: 18px; font-weight: bold; } --> </style> </head> <body> <form id="form1" name="form1" method="post" action=""> <p align="center" class="style1">LIST REGISTERED SUBJECTS</p> <p align="center"> </p> <p>Matric No: <input name="textfield" type="text" id="textfield" value="<?php echo $row_terd['matric_no']; ?>" /> Year : <input name="textfield3" type="text" id="textfield3" value="<?php echo $row_terd['year']; ?>" size="5" /> </p> <p>Name : <input name="textfield2" type="text" id="textfield2" value="<?php echo $row_terd['name']; ?>" size="50" /> </p> <p> </p> </form> <form id="form2" name="form2" method="post" action=""> <table width="598" height="69" border="1" align="center"> <tr> <th width="138" scope="col">S_Code</th> <th width="124" scope="col">S_Title</th> <th width="79" scope="col">Sessi</th> <th width="72" scope="col">Block</th> <th width="73" scope="col">Group</th> <th width="72" scope="col">Status</th> </tr> <tr> <td><div align="center"><?php echo $row_terd['s_code']; ?></div></td> <td><?php echo $row_terd['s_title']; ?></td> <td><div align="center"><?php echo $row_terd['sessi']; ?></div></td> <td><div align="center"><?php echo $row_terd['block']; ?></div></td> <td><div align="center"><?php echo $row_terd['group']; ?></div></td> <td><div align="center"><?php echo $row_terd['status']; ?></div></td> </tr> </table> <p> </p> <p align="center"> <input type="submit" name="button" id="button" value="ADD" /> <input type="submit" name="button2" id="button2" value="DROP" onclick="return confirmLink(this, 'ALTER TABLE `medic_registered_course` DROP `matric_no`')"/> </p> <div align="center"> <p> </p> <p class="style10"><a href="reg_main.php">Back</a> | <a href="main.php">Module Menu</a> | <a href="<?php echo $logoutAction ?>" onclick="MM_popupMsg('You\'re successfully logout from this system...')">Logout</a></p> </div> </form> </body> </html> <?php mysql_free_result($terd); ?>bleh tolong tak cam ner nak insert dlm table coz column semua masuk tapi value takde.. return to 0 and cam ne nak masuk multiple record yek coz kalau pakai insert into pastu value satu2 payah la coz admin akan keyin then auto masuk dlm table.. Quote Share this post Link to post Share on other sites