Code: Select all
<?php
include("mySqlConnect.php");
mysql_select_db($dbname,$testConnect) or die (mysql_error());
// creating table
/*$sql= "CREATE TABLE `user`.`example`
(`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`firstname` VARCHAR(64) NOT NULL,
`lastname` VARCHAR(64) NOT NULL,
`region_name` INT ,
`ssnumber` INT ,
`age` INT)
ENGINE = MyISAM;";
mysql_query($sql) or die (mysql_error());
print "Table Created Successfully";
*/
// inserting values in the table
if(isset($function)&&$function=="add"){
print("This is the value");
$sqlInsert = "INSERT INTO 'user' . `example`(
firstName,
lastName,
region_name,
ssnumber,
age)
VALUES ('Tarun', 'Ghosh', 1, 44,54)";
print("$sqlInsert<br>");
//mysql_query($sqlInsert) or die (mysql_error());
}
$sqlReg = "SELECT regionName,regionNumber FROM regions";
$Result = mysql_query($sqlReg,$testConnect) or die (mysql_error());
/*$row_nameCheck =mysql_fetch_assoc($Result);
$firstNameValue = $row_nameCheck['regionName'];
$middleNameValue = $row_nameCheck['regionNumber'];
echo "This is the First Name:- $firstNameValue <br>";
echo "This is the MIddle Name :- $middleNameValue <br>";*/
//$myrow = mysql_fetch_array($Result);
//print_r("$Result");
//echo $myrow['regionNumber'];
//print_r("$Result");
?>
<!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>Untitled Document</title>
</head>
<body>
<form id="enterForm" name="dateEnter" method="post" action="index.php?function=add">
Enter First Name: <input type="text" name="name" id="name"/><br />
Enter Last Name : <input type="text" name="lastname" id="lastname"/><br />
Select Region Number:
<select name="regionNumber"id="regionNumber">
<option>
<?php while ($myRow = mysql_fetch_array($Result)){ ?>
<option value="<?php echo $myRow['regionNumber'];?>"><?php echo $myRow['regionNumber']. "-" .$myRow['regionName']; ?></option>
<?php } ?>
</option>
</select>
<br/>
Please Enter SS Number No Dashes:
<input type="text" name="ssnumber" id="ssnumber"/><br/>
Enter your age : <input type="text" name="age" id="age"/><br />
<input type="submit" name="addData" id="addData" value="Ok" />
</form>
</body>
</html>
Thanks.