Well, the first reason is that, i feel if i post here my problem I get more accurate answer which fulfils my needs better. secondly, i do not have a library access where i can find all the relevant books. thirdy, i cannot afford buying all these books.
So, hope experts lend their support in helping me learn PHP better.
the following code works job fine as long as just insertion of data in concerned. but if i delete one row from it..the auto increment no doest not go back to its previous postion. what is mean is for example in my book table i have a primary key named call_no which is a auto increment int type.
If i insert a few row it starts from 1,2,3.........and so on.. but if i delete for example row no 5, and then insert another row....it skip the no 5 and move on to 6. My question is how can i over come this problem?
It looks like something :
Code: Select all
1
2
3
4
їafter i deleted it there is no row no 5!!]
6here is the code:
Code: Select all
<html>
<body>
<?php
if (isset($_POST['reset'])) {
echo "just a min..we will make it work soon ";
}
else if (isset($_POST['submit'])) {
// process form
$db = mysql_connect("localhost", "root");
mysql_select_db("library",$db);
$sql = "INSERT INTO book (title,author1,author2,publisher,isbn,price,no_of_page,edition) VALUES ('{$_POST['title']}','{$_POST['author1']}','{$_POST['author2']}','{$_POST['publisher']}','{$_POST['isbn']}','{$_POST['price']}','{$_POST['no_of_page']}','{$_POST['edition']}')";
$result = mysql_query($sql);
echo "Your data was inserted successfuly\n";
} else{
// display form
?>
<table border="0" width="35%">
<tr>
<td width="100%"><img border="0" src="f:\web\ibcslarge.png" width="317" height="30"></td>
</tr>
<tr>
<td width="100%"> </td>
</tr>
</table>
<table border="0" width="35%">
<tr>
<td width="100%"> </td>
</tr>
<tr>
<td width="100%"></td>
</tr>
</table>
<table border="0" width="100%">
<tr>
<td width="100%"><a href="http://">Home </a> <a href="http://">Account </a>
<a href="file:///F:/my%20project%20work%20(final)/CD_ENTRY_FORM.htm">New
CD Entry Form </a> <a href="http://">New Journal Entry
Form </a> <a href="http://">Delete Record</a></td>
</tr>
</table>
<table border="0" width="35%">
<tr>
<td width="100%"> </td>
</tr>
</table>
<table border="0" width="35%" bgcolor="#FFCC66">
<tr>
<td width="100%">
<p align="center"><font size="3">NEW BOOK ENTRY FORM</font></td>
</tr>
</table>
<table border="0" width="35%">
<tr>
<td width="100%"> </td>
</tr>
</table>
<form method="post" action="<?php echo $PHP_SELF?>">
Book Title: <input type="Text" name="title" size="24"><br>
Author1: <input type="Text" name="author1" size="24"><br>
Author2: <input type="Text" name="author2" size="24"><br>
Publisher: <input type="Text" name="publisher" size="24"><br>
ISBN: <input type="Text" name="isbn" size="24"><br>
Price:
<input type="Text" name="price" size="8"><br>
No Of Page: <input type="Text" name="no_of_page" size="8"><br>
Edition: <input type="Text" name="edition" size="8">
<p>
<input type="Submit" name="submit" value="Submit">
<input type="Submit" name="reset" value="Reset">
</p>
</form>
<?php
} // end if
?>
</body>
</html>[Edit: Added PHP and CODE tags for eyecandy. Use 'em. --JAM]
