I'm inserting some data into my database that are found in two tables. The insert is working fine, however when i try to insert again, if the cell has a value, the new value will be inserted next to it. I tried an if/else condition to prevent a new insertion if the cell has already a value in it, but failed on making it work. Maybe it's not the solution or i did it wrong. Any help please?
if(isset($_POST['submit'])) {
$degree = $_POST['Degree'];
$major = $_POST['Major'];
$univ = $_POST['Univ'];
$brevet = $_POST['Brevet'];
$baccbt = $_POST['Baccbt'];
$selectaf = $_POST['SelectAF'];
$sql1="SELECT certificatesgrading.brevet,
certificatesgrading.baccbt,
university.degree,
university.major,
university.univ
FROM university,
certificatesgrading
WHERE afnumber = '$selectaf'";
if ($result=mysqli_query($con,$sql1)) {
// Return the number of rows in result set
$rowcount=mysqli_num_rows($result);
}
$sql="INSERT INTO university
(afnumber,
university.degree,
university.major,
university.univ)
VALUES ('$selectaf',
'$degree',
'$major',
'$univ')";
$sql1="INSERT INTO certificatesgrading
(afnumber,
certificatesgrading.brevet,
certificatesgrading.baccbt)
VALUES ('$selectaf',
'$brevet',
'$baccbt') ";
$result = mysql_query($sql);
$result = mysql_query($sql1);
}
echo $menu;