hello phphelp.com community,
I am confused on my codes right now, and i dont know what might me the error,
I want to update multiple rows in my database using sql command and php.
guys please elaborate more your explanations, im a student working on my case study, im just a newbie.
your replies will be appreciated thank you.
btw sorry for my english.
firstpart
[php]
<?php
$host = "localhost";
$user = "root";
$pass = "";
$db = "student";
mysql_connect($host, $user, $pass);
mysql_select_db($db);
session_start();
$studID = $_SESSION['studID'];
$sql = mysql_query("SELECT * FROM student WHERE studentID='".$studID."' ");
if (mysql_num_rows($sql) == 1 ) {
$row = mysql_fetch_assoc($sql);
$_SESSION['studentYear'] = $row['year'];
$_SESSION['studentfname'] = $row['firstname'];
$_SESSION['studentlname'] = $row['lastname'];
$_SESSION['studentaverage'] = $row['average'];
if($studyear == '1'){
if (isset($_POST['submit'])) {
header("Location: enrollfreshmen.php");
}
}
else if($studyear == '2'){
if (isset($_POST['submit'])) {
header("Location: enrollsophomore.php");
}
}
}
else {
echo"Database error.";
exit();
}
?>
[/php]
enrollfreshmen.php
[php]
<?php
$host = "localhost";
$user = "root";
$pass = "";
$db = "enrolledfresmen"; //nvm the spelling ill change it.
$table = "student";
mysql_connect($host, $user, $pass);
mysql_select_db($db);
session_start();
$studyear = $_SESSION['studentYear'];
$studfname = $_SESSION['studentfname'];
$studyear = $_SESSION['studentlname'];
$studaverage = $_SESSION['studentaverage'];
$studID = $_SESSION['studID'];
$sql = "INSERT INTO $table (studentID, firstname, lastname, year, average, date) VALUES ('".$studID."', '".$studfname."', '".$studlname."', '".$studyear."', '".$studaverage."', CURRENT_TIMESTAMP )";
?>
[/php]