Jump to content

How To Insert Value In Specific Column Inside Phpmyadmin Database Table


EzwanAbid

Recommended Posts

i tried to insert 'semester' value into specific column in table 'register' inside my database/phpmyadmin... But after I submit the value, it doesn't bring the data into the table .. so the column of 'semester' was empty without any values.

 

Here the code for inserting data/value into 'semester' column inside 'register' table :

 

<?php
$reg_id=$_GET['reg_id'];
$stud_id=$_POST['IDUSER'];
$sub_code=$_GET['sub_code'];
$semester=$_GET['semester'];
$aDoor = $_POST['formDoor'];
if(empty($aDoor))
{
echo("<h2>You didn't select any subject.</h2>");
}
else
{
$N = count($aDoor);
echo("<h2>You selected $N subject(s): </h2><br><br>");
mysql_connect ("localhost","","");
mysql_select_db ("projek");

for($i=0; $i < $N; $i++)
{
$subject=$aDoor[$i];
$stuff = mysql_query("SELECT sub_code FROM `register` WHERE stud_id='".$stud_id."' AND sub_code='".$subject."'") or die("MySQL Login Error: ".mysql_error());
if (mysql_num_rows($stuff) > 0)
{
$row=mysql_fetch_array($stuff);


echo '<br><br><h2>Fail register </h2>' ;
echo $row['sub_code'];

}
else if (mysql_num_rows($stuff) <= 0)
{

$sql_insert="INSERT INTO register(reg_id,stud_id,sub_code,semester)
VALUES('$reg_id','$stud_id','$subject','$semester')";
$result=mysql_query($sql_insert);

echo '<br><br>Success register';
echo($aDoor[$i] . " ");
}



}
}
?>

 

Hope someone can help me here.. I'm new in PHP and MySQL . :(

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.