HI. Im new to database. I didnt know how to use bridge table. In my bridge table i have SubjectID and studentID, PK from student table and subject table. In my subject table have SubjectID, SubjectName and SubjectLecturer while in my student table have studentID,,studentName,IC,studentFac,studentPhone, studentEmail,pswd,studentAddress. I didnt know where is the wrong part because when i click my form which is enroll button, this enroll page blank. Can someone check my coding ? Help ? - <!DOCTYPE HTML> <html> <head> <?php
-
error_reporting(0);
-
session_start();
-
if (!isset($_SESSION['studentID']))
-
{
-
$_SESSION['studentID'] = $_POST['studentID'];
-
$_SESSION['pswd'] = $_POST['pswd'];
-
}
-
-
include("connect.php");
-
$sql = "SELECT * FROM student WHERE
-
studentID='".$_SESSION['studentID']."' AND
-
pswd='".$_SESSION['pswd']."'";
-
-
$result = mysql_query($sql);
-
$row = mysql_num_rows($result);
-
if ($row == 0)
-
{
-
echo "Login fail Try again <a href='http://bytes.com/'>here</a>";
-
?> <meta http-equiv="refresh" content="0;userlogin.php" /> <?php
-
}
-
else
-
{
-
$row = mysql_fetch_assoc($result);
-
}
-
?> <meta charset="UTF-8"> <title>E-Education portal</title> <link href="http://bytes.com/style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="header"></div> <?php
-
-
if(isset($_POST["submit"]))
-
{
-
session_start();
-
include("connect.php");
-
-
$SubjectID = $_POST['SubjectID'];
-
$SubjectName = $_POST['SubjectName'];
-
$SubjectLecturer = $_POST['SubjectLecturer'];
-
-
-
$Subject= "SELECT SubjectID
-
FROM Subject
-
WHERE SubjectID='$SubjectID'";
-
-
$queryssubject=mysql_query($subject) or die(mysql_error);
-
$record=mysql_num_rows($querysubject);
-
-
if($record==1)
-
{
-
header ('Location: studentSubject.php');
-
}
-
else if($record<1)
-
{
-
if(substr($subjectID))
-
{
-
-
$insertIntoSubject= "INSERT INTO Subject ('SubjectID', 'SubjectName', 'SubjectLecturer') VALUES ('$SubjectID','$SubjectName','$SubjectLecturer')";
-
-
$result1=mysql_query($insertIntoSubject) or die(mysql_error());
-
-
$insertIntobridge="INSERT INTO `bridge`(`SubjectID`, `studentID`)
-
VALUES ('$SubjectID', '$studentID')";
-
$result2=mysql_query($insertIntobridge)or die(mysql_error());
-
-
$insertIntostudent="INSERT INTO student (`studentID`, `studentName`, `IC`, `studentFac`, `studentPhone`, `studentEmail`, `pswd`, `studentAddress')
-
VALUES ('$studentID', '$studentName', '$IC', '$studentFac', '$studentPhone', '$studentEmail', 'abc123', '$studentAddress')";
-
-
$result3=mysql_query($insertIntostudent)or die(mysql_error());
-
-
-
-
if ($result1 && $result2 && $result3)
-
{
-
header ('Location: studentSubject.php');
-
}
-
}
-
else echo 'insert error';
-
}
-
-
else
-
{
-
echo "<script type='text/javascript'>
-
alert('Data Updated!')
-
location.href='homestudent.php'
-
</script>";
-
-
}
-
mysql_close($conn);
-
}
-
?>
0 1106 Sign in to post your reply or Sign up for a free account.
Similar topics
by: CoOL! . |
last post by:
Hello,
I found the key to solve this problem in:
http://darkstar.ist.utl.pt/mysql/doc/en/InnoDB_foreign_key_constraints.html
You'll probably need an INDEX for that new foreign key you are...
|
by: Matt |
last post by:
Hi all,
We recently upsized two Microsoft Access Databases to SQL. We're
using an ADP (2002) as the front end.
All the conversion issues have been resolved, except for one:
Whenever we...
|
by: Symphony |
last post by:
Hi, all:
In our web application(vb.net), we are using Table, Table Row, Table Cell
web controls dymanically load data, we define two columns, left column likes
header, list data titles(eg....
|
by: David Bradbury |
last post by:
I currently have an iframe on a webpage into which users can insert
content. They can further customise the text as I've included buttons
such as Bold, Italic, Bullet point etc. This is done along...
|
by: Ken |
last post by:
I have a table I am trying to create with a unique Pk
Table fields
JobID---PK
JobDate
I would like to have the primary key be a combination of increment
number starting with 001 and year and...
|
by: poppy |
last post by:
I have a dataset which has 1 table with 10 coloumns and n
rows.
I create a new table "newTable" which contains 2
columns "A" and "B".
I want to copy the contents of col 7 and col 8 of the...
|
by: steve |
last post by:
Hello,
I am having a problem with an index controlled partitioned table. I
was altering a table using SQL. I was trying to add a partition to a
table to change it from index controlled to...
|
by: RayPower |
last post by:
I'm having problem with using DAO recordset to append record into a
table and subsequent code to update other tables in a transaction. The
MDB is Access 2000 with the latest service pack of JET 4....
|
by: patrickkellogg |
last post by:
I have this code when you click the buttom is suppose to add a job
history. it works with firefox, opera, but not ie. (please note -
new entries don't have all the elements in them yet, but...
|
by: pbd22 |
last post by:
Hi.
Like the title says - how do i do this?
I was given the following example:
INSERT INTO TABLE2 SELECT * FROM TABLE1 WHERE COL1 = 'A'
The above statement threw the following error:
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |