<form method="POST">
<input type="submit" name="submit" value="submit" />
<?php
if (isset($_POST['submit']))
{
include '_includes/db.php';
mysql_query("INSERT INTO `en_stud` (en_subj, en_desc, en_code)
SELECT subj_code, subj_name, subj_deg FROM `subjects` WHERE subj_deg='PREP'");
}
?>
</form>
Hi, Ok, so i used the INSERT SELECT for this, in order to insert all regular subjects for prep inside the database, but what if i wanted to add something. Like
Adding
Input Box and another value separated into the select table command, how would i be able to add it there?
<form method="POST">
<input type="text" name="f" value="1"
<input type="submit" name="submit" value="submit" />
<?php
if (isset($_POST['submit']))
{
include '_includes/db.php';
$f = "$_POST['f']";
mysql_query("INSERT INTO `en_stud` (en_fname, en_subj, en_desc, en_code)
SELECT subj_code, subj_name, subj_deg FROM `subjects` WHERE subj_deg='PREP'");
}
?>
</form>
As you can see the "en_fname" doesn't have any corresponding values, does this have any corresponding code to make it work?
<?php
if (isset($_POST['submit']))
{
include '_includes/db.php';
$f = "$_POST['f']";
mysql_query("INSERT INTO `en_stud` (en_fname, en_subj, en_desc, en_code) VALUES ('$f')
SELECT subj_code, subj_name, subj_deg FROM `subjects` WHERE subj_deg='PREP'");
}
?>
</form>