EzwanAbid Posted December 24, 2012 Share Posted December 24, 2012 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 . Quote Link to comment https://forums.phpfreaks.com/topic/272328-how-to-insert-value-in-specific-column-inside-phpmyadmin-database-table/ Share on other sites More sharing options...
Christian F. Posted December 24, 2012 Share Posted December 24, 2012 Please read the following post on how to debug your SQL errors. Quote Link to comment https://forums.phpfreaks.com/topic/272328-how-to-insert-value-in-specific-column-inside-phpmyadmin-database-table/#findComment-1401115 Share on other sites More sharing options...
Barand Posted December 24, 2012 Share Posted December 24, 2012 Why are some variables from $_GET and others from $_POST? Quote Link to comment https://forums.phpfreaks.com/topic/272328-how-to-insert-value-in-specific-column-inside-phpmyadmin-database-table/#findComment-1401121 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.