HI, guyz
Wordrin if sum one could help! at the moment got code which allow user to input and display in result. but mean time wana allow user to delete current input data by providing delete button next to displayd data..........
plz could some one tell me how to,what commend do i need and where to put as i tried many but nothig workin for me .
view code!
<?php
$dbcnx=@mysql_connect("localhost", "abc", "xxxx");
/* Connect to the database server */
if (!dbcnx) {
die('<p>Unable to connect ot the database Server. </p>');
}
/*Displays a message if unable*/
/* Now select the test*/
if (! @mysql_select_db('refxx')){
die ( '<p>Cannot selet test database.</p>' );
}
?>
<a>
<?php
if(isset($_GET)):
/* if a record is to be added */
?>
<form action="<?=$_SERVER?>" method="post" >
<table summary="DATA Entry Table">
<caption>Enter details</caption>
<!-- get data -->
<tr><td>authorname</td><td><input name="authorname" type="text" size="40"
Value="authorname" /></td></tr>
<tr><td>publishyear</td><td><input name="publishyear" type="text" size="40"
Value="publishyear" /></td></tr>
<tr><td>booktitle</td><td><input name="booktitle" type="text" size="40"
Value="booktitle" /></td></tr>
<tr><td>edition</td><td><input name="edition" type="text" size="40"
Value="edition" /></td></tr>
<tr><td>place</td><td><input name="place" type="text" size="40"
Value="place" /></td></tr>
<tr><td>publisher</td><td><input name="publisher" type="text" size="40"
Value="publisher" /></td></tr>
</table>
<input type="submit" name="submitdata" value="Generate" /><input type="reset" value="Clear Form" />
</form>
<?php
else:
/* Connect to Database server*/
$dbcnx=@mysql_connect("localhost", "abc", "xxxx");
/* Connect to the database server */
if (!dbcnx) {
die('<p>Unable to connect ot the database Server. </p>');
}
/*Displays a message if unable*/
/* Now select the test*/
if (! @mysql_select_db('refxx')){
die ( '<p>Cannot select test database.</p>' );
}
/* Adds record to database */
if (isset($_POST)) {
$id = $_POST;
$authorname = $_POST;
$publishyear = $_POST;
$booktitle = $_POST;
$edition = $_POST;
$place = $_POST;
$publisher = $_POST;
$sql = "INSERT INTO book set
id='$id', authorname='$authorname', publishyear='$publishyear', booktitle='$booktitle', edition='$edition', place='$place', publisher='$publisher'";
/* Confirm data entered */
if (@mysql_query($sql)) {
echo('<p></p>');
} else {
echo('<p>Error adding record: ' . mysql_error() . '</p>');
}
}
//SELECT * from abc ORDER BY id DESC LIMIT 1;
$result = @mysql_query('select * from tablename ORDER BY id DESC LIMIT 1');
if (!$result) {
die('<p>Error performing query: ' . mysql_error() . '</p>');
}
?>
<table summary="Results" border="4" width="650">
table summary="Events Time" border="4" width="900"
<caption>Your Book Reference is:</caption><br /><br /><br /><br />
<!-- code to display result -->
<?php
while ( $row = mysql_fetch_array($result) ) {
echo ('<tr><td>' . $row . '</td><td>' . $row . '</td><td>' . $row . '</td><td>' . $row . '</td><td>' . $row . '</td><td>' . $row . '</td><td>' . $row . '</td></tr>');
}
echo('<p><a href=" ' . $SERVER . '?addrecord=1">Generate New Reference</a></p>');
endif;
?>
Thanks.