Expand|Select|Wrap|Line Numbers
- ///certificate.php
- <html>
- <head>
- <script type="text/javascript" src="stmenu.js"></script>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- </head>
- <body>
- <form method ="post" action="databasensert.php" enctype="multipart/form-data">
- <table border="0">
- <tr><td><B> Available <br/> Certificates</B></td><td><p></p></td><td><B>Selected<br/> Certificate</B></td></tr>
- <tr>
- <td>
- <select name="sel1" style="width:110px" size="15" multiple="multiple">
- <?php
- $con = mysql_connect('localhost','root','');
- if($con){
- mysql_select_db('dballiance', $con);
- $stmt1 = mysql_query ("select * from certification order by description asc" ) ;
- if ( $stmt1 ) {
- while ( $row1 = mysql_fetch_array( $stmt1 ) ) {
- $id = $row1['certification_id'] ;
- $name = $row1['name'] ;
- echo "<option value='".$id."'> ".$name." </option>";
- }
- }
- mysql_close($con);
- }else{
- echo "error.".mysql_error();
- }
- ?>
- </select>
- </td>
- <td align="center">
- <input type="button" value="-->"
- onclick="moveOptions(this.form.sel1, this.form.sel2);" /><br />
- <input type="button" value="<--"
- onclick="moveOptions(this.form.sel2, this.form.sel1);" />
- </td>
- <td>
- <select name="sel2" style="width:110px" size="15" multiple="multiple">
- </select>
- </td>
- </tr>
- </table>
- <br/>
- <fieldset>
- <legend>
- Alternative Certificate
- </legend>
- <table border="0">
- <tr>
- <td>
- <p><label for="Name">Name</label><br/>
- <input id="Name" maxlength="40" name="Name" autocomplete="off" size="15" type="text" />
- </td>
- <td>
- <p><label for="Description">Description</label><br/>
- <input id="Description1" maxlength="40" name="Description1" autocomplete="off" size="40" type="text" />
- </td>
- </tr>
- <tr><td colspan="2"><div align= 'right'>
- <input name="Submit" type="Submit" value="Request for creation" ></div> </td>
- </tr>
- </table>
- </fieldset>
- <table border = "0" align ="right">
- <tr>
- <td>
- <input name="button" type="button" value="Back" ONCLICK="window.location.href='service.php'">
- </td>
- <td>
- <div><input id="Submit" name="Submit" type="Submit" value="Submit">
- </div>
- </td>
- </tr>
- </table>
- <!-- JavaScript code -->
- <script language="JavaScript">
- var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
- function addOption(theSel, theText, theValue)
- {
- var newOpt = new Option(theText, theValue);
- var selLength = theSel.length;
- theSel.options[selLength] = newOpt;
- }
- function deleteOption(theSel, theIndex)
- {
- var selLength = theSel.length;
- if(selLength>0)
- {
- theSel.options[theIndex] = null;
- }
- }
- function moveOptions(theSelFrom, theSelTo)
- {
- var selLength = theSelFrom.length;
- var selectedText = new Array();
- var selectedValues = new Array();
- var selectedCount = 0;
- var i;
- // Find the selected Options in reverse order
- // and delete them from the 'from' Select.
- for(i=selLength-1; i>=0; i--)
- {
- if(theSelFrom.options[i].selected)
- {
- selectedText[selectedCount] = theSelFrom.options[i].text;
- selectedValues[selectedCount] = theSelFrom.options[i].value;
- deleteOption(theSelFrom, i);
- selectedCount++;
- }
- }
- // Add the selected text/values in reverse order.
- // This will add the Options to the 'to' Select
- // in the same order as they were in the 'from' Select.
- for(i=selectedCount-1; i>=0; i--)
- {
- addOption(theSelTo, selectedText[i], selectedValues[i]);
- }
- if(NS4) history.go(0);
- }
- </script>
- </form>
- </body>
- </html>
Expand|Select|Wrap|Line Numbers
- ///databaseinsert.php
- <?php
- //$Name=trim($_POST["Name"]);
- //$Description=trim($_POST["Description1"]);
- //$query="INSERT INTO alternative_certificate (certificate_id,name,description) VALUES ('', '".$Name."','".$Description."')";
- $CertId=trim($_POST["sel1"]);
- while (list ($val) = @each ($CertId)) {
- echo "Certificate_id: ".$val."</br>";
- }
- $con = mysql_connect('localhost','root','');
- if($con){
- mysql_select_db('dballiance', $con);
- $stmt = mysql_query ("select * from certification order by description asc" ) ;
- while ( $row = mysql_fetch_array( $stmt ) ) {
- echo $row['certification_id'];
- $query="INSERT INTO partner_certification (partner_id,certification_id) VALUES ('4','".$CertId."')";
- echo $query;
- mysql_query($query);
- }
- mysql_close($con);
- }else{
- echo "error.".mysql_error();
- }
- //echo "<script>document.location.href='summary.php'</script>";
- ?>
Expand|Select|Wrap|Line Numbers
- ///database Script
- # --------------------------------------------------------
- # Host: 127.0.0.1
- # Database: dballiance
- # Server version: 5.1.41
- # Server OS: Win32
- # HeidiSQL version: 5.0.0.3272
- # Date/time: 2010-06-11 01:40:07
- # --------------------------------------------------------
- # Dumping database structure for dballiance
- CREATE DATABASE IF NOT EXISTS `dballiance` /*!40100 DEFAULT CHARACTER SET latin1 */;
- USE `dballiance`;
- # Dumping structure for table dballiance.alternative_certificate
- CREATE TABLE IF NOT EXISTS `alternative_certificate` (
- `certificate_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `name` varchar(20) NOT NULL,
- `description` varchar(255) NOT NULL,
- `partner_id` tinyint(3) unsigned NOT NULL,
- PRIMARY KEY (`certificate_id`)
- ) ENGINE=MyISAM AUTO_INCREMENT=42 DEFAULT CHARSET=latin1;
- # Dumping structure for table dballiance.certification
- CREATE TABLE IF NOT EXISTS `certification` (
- `certification_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `name` varchar(45) NOT NULL,
- `description` varchar(255) DEFAULT NULL,
- PRIMARY KEY (`certification_id`)
- ) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=latin1 COMMENT='\r\n';
- # Dumping structure for table dballiance.partner_certification
- CREATE TABLE IF NOT EXISTS `partner_certification` (
- `partner_id` int(10) unsigned NOT NULL,
- `certification_id` int(10) unsigned NOT NULL,
- `name` varchar(10) DEFAULT NULL,
- PRIMARY KEY (`partner_id`,`certification_id`),
- KEY `partner_has_Certification_FKIndex1` (`partner_id`),
- KEY `partner_has_Certification_FKIndex2` (`certification_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1;