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['addrecord'])):

         /* if a record is to be added */
?>

<form action="<?=$_SERVER['PHP_SELF']?>" 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['submitdata'])) {

    $id = $_POST['id'];

    $authorname = $_POST['authorname'];

    $publishyear = $_POST['publishyear'];

    $booktitle = $_POST['booktitle'];

    $edition = $_POST['edition'];

    $place = $_POST['place'];

    $publisher = $_POST['publisher'];

    $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['id'] . '</td><td>' . $row['authorname'] . '</td><td>' . $row['publishyear'] . '</td><td>' . $row['booktitle'] . '</td><td>' . $row['edition'] . '</td><td>' . $row['place'] . '</td><td>' . $row['publisher'] . '</td></tr>');


    }

    echo('<p><a href=" ' . $SERVER['PHP_SELF'] . '?addrecord=1">Generate New Reference</a></p>');


    endif;
?>

Thanks.

Do you want a delete link next to your displayed rows, to delete that entry from the database when clicked ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.