Hi everybody
actually I need your help in fixing my code. Actually I have a library system that can be applied in university or any school and I'm stucking in a page that for loan student book. I have student table, Library table, books table, usersystem table and Bookoutonloan table as I mention it below so here in this table I have 4 foreign keys from different tables as I mentioned them before so here in the php page when I want to loan student I can't do it actually it will work but it's totally wrong so I want for example the students who are registered in the student table so in the attach php webpage I enter the student ID manual and might the number that I'm entering not in the origianal table for students for example I have 100 students registered so they will have from 1 to 100 number in their ID so if I write 500 in the loan it will accept and assign the the value to Bookoutonloan table but I want to change the way either I search by student name from stu ID number or what shall I do. Please I really need your help. Thanks
this is my SQL table
This is the html with php code
actually I need your help in fixing my code. Actually I have a library system that can be applied in university or any school and I'm stucking in a page that for loan student book. I have student table, Library table, books table, usersystem table and Bookoutonloan table as I mention it below so here in this table I have 4 foreign keys from different tables as I mentioned them before so here in the php page when I want to loan student I can't do it actually it will work but it's totally wrong so I want for example the students who are registered in the student table so in the attach php webpage I enter the student ID manual and might the number that I'm entering not in the origianal table for students for example I have 100 students registered so they will have from 1 to 100 number in their ID so if I write 500 in the loan it will accept and assign the the value to Bookoutonloan table but I want to change the way either I search by student name from stu ID number or what shall I do. Please I really need your help. Thanks
this is my SQL table
Code:
CREATE TABLE `library`.`bookoutonloan` ( `borrowid` INT( 12 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `stid` INT( 12 ) NOT NULL, `bookid` INT( 12 ) NOT NULL, `userid` INT( 12 ) NOT NULL, `libraryid` INT( 12 ) NOT NULL, `dateborrow` DATE NOT NULL , `datedueforreturn` DATE NOT NULL , `datereturned` DATE NOT NULL , `amountoffine` INT( 12 ) ) ENGINE = MYISAM ; ALTER TABLE bookoutonloan ADD FOREIGN KEY (stid) REFERENCES studentorstaff(stid); ALTER TABLE bookoutonloan ADD FOREIGN KEY (bookid) REFERENCES books(bookid); ALTER TABLE bookoutonloan ADD FOREIGN KEY (userid) REFERENCES usersystem(userid); ALTER TABLE bookoutonloan ADD FOREIGN KEY (libraryid) REFERENCES librarybranch(libraryid);
This is the html with php code
Code:
<?php
$submit = &$_POST["submitt2"];
$studid = $_POST["studid"];
$bookid = $_POST["bookid"];
$userid = $_POST["userid"];
$libraryid = $_POST["libraryid"];
$dateofloan = $_POST["dateofloan"];
$datereturn = $_POST["datereturn"];
$amountfine = $_POST["amountfine"];
if ($submit)
{
$connect = mysql_connect("localhost", "root", "");
mysql_select_db("library");
$queryreg = mysql_query(" INSERT INTO bookoutonloan VALUES('','$studid','$bookid','$userid', '$libraryid','$dateofloan','$datereturn','')
");
die("Loaned has been successed");
}
else
echo "please fill in <b>all</b> fields!";
?>
<html>
<body>
<form name="form1" method="post" action="loanbook.php">
<table width="37%" border="0">
<caption>
Loan Books to students
</caption>
<tr>
<td>Student ID:</td>
<td><input name="stuid" type="text" id="stuid" /></td>
</tr>
<tr>
<td>Book ID:</td>
<td><input name="bookid" type="text" id="bookid" /></td>
</tr>
<tr>
<td>User ID:</td>
<td><input name="userid" type="text" id="userid" /></td>
</tr>
<tr>
<td>Library ID:</td>
<td><input name="libraryid" type="text" id="libraryid" /></td>
</tr>
<tr>
<td>Date of Loan:</font></strong></td>
<td><input name="dateofloan" type="text" id="dateofloan" /></td>
</tr>
<tr>
<td>Date Due return:</td>
<td><input name="datereturn" type="text" id="datereturn" /></td>
</tr>
<tr>
<td>Amount of fine:</td>
<td><input name="amountfine" type="text" />
</tr>
<tr>
<td> </td>
<td><input type='submit' name='submitt2' value='Register' id='submitt2'></td>
</tr>
</table>
</form>
</body>
</html>
Comment