Jump to content

mutiple instance of same "delete " buttong


faisalabad

Recommended Posts

HI everyone .. a newbe to php

i am accessing a table and assinging it to a associate array and with wile loop printing it as table, at the end of every row i have delete button (also part of the while loop ).....

what i want to do is for user to be able Click any "delete" and corrosponding row get deleted from database and then reprint the new updated table...

at the moment it seams only the first "delete" button respond, even that does not delete any record from data base .... help please i am stuck for last 4 days and new to php and programming ...

here is the code that print the table and delete buttons

 

<?php

 

if ($_POST['delete'])

{

 

 

$cattodel = $_POST['cat_id'];

 

mysql_query("DELETE FROM catalogue WHERE cat_id ='$cattodel'");

 

}

 

mysql_connect('localhost','root','root');

mysql_select_db('Catalogues');

 

$getdata = mysql_query("SELECT * FROM catalogue");

echo "

<table border='1'>

<tr>

<td>Catalogue number</td>

<td>Catalogue name</td>

<td>File name</td>

<td>Sale setup</td>

<td>Arrival date </td>

<td>Copy & Retails links</td>

<td>Images & Catalogues pages</td>

<td>Due date</td>

<td>Status</td>

</tr>

 

<form action='viewcatalogues.php' method='post' enctype='multipart/form-data'>";

 

while($data = mysql_fetch_assoc($getdata))

{

 

echo "

<tr>

 

<td>".$data['cat_id']."</td>

<td>".$data['catalogue_name']."</td>

<td>".$data['file_name']."</td>

<td><a href='".$data['sale_setup']."'>".$data['sale_setup']."</a></td>

<td>".$data['arrival']."</td>

<td>".$data['copy_retail']."</td>

<td>".$data['image_cata']."</td>

<td>".$data['due']."</td>

<td>".$data['status']."</td>

<td><input type='submit' name='delete' ></td>

</tr>

</form>";

 

}

 

echo "</table>";

 

?>

 

Link to comment
https://forums.phpfreaks.com/topic/198901-mutiple-instance-of-same-delete-buttong/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.