Jump to content

[SOLVED] add delete button


sandbudd

Recommended Posts

how would I add a delete button to this page?

 


<?php
// Connects to your Database
$db_host = ''; 
$db_user = ''; 
$db_pwd = '';

$database = '';
$table = '';

ini_set('error_reporting',E_ALL);

if (!mysql_connect($db_host, $db_user, $db_pwd))
    die("Can't connect to database");

if (!mysql_select_db($database))
    die("Can't select database");

//Retrieves data from MySQL
$data = mysql_query("SELECT * FROM ae_gallery") or die(mysql_error());

//Puts it into an array
while($info = mysql_fetch_array( $data ))
{

//Outputs the image and other data
Echo "<a href=http://www.sandbudd.com/try/images/".$info['photo'] ."> file <br></a>";
Echo "<b>Name:</b> ".$info['name'] . "<br> ";
Echo "<b>Company:</b> ".$info['company'] . " <br>";
Echo "<b>Address:</b> ".$info['address'] . " <br>";
Echo "<b>City:</b> ".$info['city'] . " <br>";
Echo "<b>State:</b> ".$info['state'] . " <br>";
Echo "<b>Zip:</b> ".$info['zip'] . " <br>";
Echo "<b>Email:</b> ".$info['email'] . " <br>";
Echo "<b>Phone:</b> ".$info['phone'] . " <br>";
Echo "<b>Fax:</b> ".$info['fax'] . " <br>";
Echo "<b>Type2:</b> ".$info['type2'] . " <br>";
Echo "<b>Type3:</b> ".$info['type3'] . " <br>";
Echo "<b>Burnish:</b> ".$info['burnish'] . " <br>";
Echo "<b>Chromate:</b> ".$info['chromate'] . " <br>";
Echo "<b>Hex:</b> ".$info['hex'] . " <br>";
Echo "<b>Impregnation:</b> ".$info['impregnation'] . " <br>";
Echo "<b>Strip:</b> ".$info['strip'] . " <br>";
Echo "<b>Part:</b> ".$info['part'] . " <br>";
Echo "<b>Description:</b> ".$info['description'] . " <br>";
Echo "<b>Alloy:</b> ".$info['alloy'] . " <br>";
Echo "<b>Quantity:</b> ".$info['quantity'] . " <br>";
Echo "<b>Spec:</b> ".$info['spec'] . " <br>";
Echo "<b>Color:</b> ".$info['color'] . " <br>";
Echo "<b>Repeat:</b> ".$info['repeat_customer'] . " <br>";
Echo "<b>Isearch:</b> ".$info['isearch'] . " <br>";
Echo "<b>Idir:</b> ".$info['idir'] . " <br>";
Echo "<b>Referral:</b> ".$info['referral'] . " <br>";
Echo "<b>Yellow:</b> ".$info['yellow'] . " <br>";
Echo "<b>Trade:</b> ".$info['trade'] . " <br>";
Echo "<b>Other:</b> ".$info['other'] . " <br>";
Echo "<b>Notes:</b> ".$info['notes'] . " <br>";
Echo "<b>id:</b> ".$info['id'] . " <br>";

}



?> 

Link to comment
https://forums.phpfreaks.com/topic/112555-solved-add-delete-button/
Share on other sites

<?php
// Connects to your Database
$db_host = ''; 
$db_user = ''; 
$db_pwd = '';

$database = '';
$table = '';

ini_set('error_reporting',E_ALL);

if (!mysql_connect($db_host, $db_user, $db_pwd))
    die("Can't connect to database");

if (!mysql_select_db($database))
    die("Can't select database");

//Retrieves data from MySQL
$data = mysql_query("SELECT * FROM ae_gallery") or die(mysql_error());

//Puts it into an array
while($info = mysql_fetch_array( $data ))
{

//Outputs the image and other data
Echo "<a href=http://www.sandbudd.com/try/images/".$info['photo'] ."> file <br></a>";
Echo "<b>Name:</b> ".$info['name'] . "<br> ";
Echo "<b>Company:</b> ".$info['company'] . " <br>";
Echo "<b>Address:</b> ".$info['address'] . " <br>";
Echo "<b>City:</b> ".$info['city'] . " <br>";
Echo "<b>State:</b> ".$info['state'] . " <br>";
Echo "<b>Zip:</b> ".$info['zip'] . " <br>";
Echo "<b>Email:</b> ".$info['email'] . " <br>";
Echo "<b>Phone:</b> ".$info['phone'] . " <br>";
Echo "<b>Fax:</b> ".$info['fax'] . " <br>";
Echo "<b>Type2:</b> ".$info['type2'] . " <br>";
Echo "<b>Type3:</b> ".$info['type3'] . " <br>";
Echo "<b>Burnish:</b> ".$info['burnish'] . " <br>";
Echo "<b>Chromate:</b> ".$info['chromate'] . " <br>";
Echo "<b>Hex:</b> ".$info['hex'] . " <br>";
Echo "<b>Impregnation:</b> ".$info['impregnation'] . " <br>";
Echo "<b>Strip:</b> ".$info['strip'] . " <br>";
Echo "<b>Part:</b> ".$info['part'] . " <br>";
Echo "<b>Description:</b> ".$info['description'] . " <br>";
Echo "<b>Alloy:</b> ".$info['alloy'] . " <br>";
Echo "<b>Quantity:</b> ".$info['quantity'] . " <br>";
Echo "<b>Spec:</b> ".$info['spec'] . " <br>";
Echo "<b>Color:</b> ".$info['color'] . " <br>";
Echo "<b>Repeat:</b> ".$info['repeat_customer'] . " <br>";
Echo "<b>Isearch:</b> ".$info['isearch'] . " <br>";
Echo "<b>Idir:</b> ".$info['idir'] . " <br>";
Echo "<b>Referral:</b> ".$info['referral'] . " <br>";
Echo "<b>Yellow:</b> ".$info['yellow'] . " <br>";
Echo "<b>Trade:</b> ".$info['trade'] . " <br>";
Echo "<b>Other:</b> ".$info['other'] . " <br>";
Echo "<b>Notes:</b> ".$info['notes'] . " <br>";
Echo "<b>id:</b> ".$info['id'] . " <br>";
Echo "<a href='delete.php?id=".$info['id']."'>delete</a>";

}

?> 

 

then you will have a separate PHP file called delete.php that looks like this:

<?php

if(isset($_GET['id'])) {
$query = "DELETE FROM ae_gallery WHERE id=".$_GET['id']." LIMIT 1";
mysql_query($query) or die("Could not delete the entry!");
}

?>

 

Regards ACE

just add that link onto what you had then put this in delete.php and youll have a very simple delete but youll want to do verification and make sure that not anyone can delete anyone elses things like that.

 

// Connects to your Database
$db_host = ''; 
$db_user = ''; 
$db_pwd = '';

$database = '';
$table = '';

ini_set('error_reporting',E_ALL);

if (!mysql_connect($db_host, $db_user, $db_pwd))
   die("Can't connect to database");

if (!mysql_select_db($database))
   die("Can't select database");

$query="DELETE FROM ae_gallery WHERE id=".$_REQUEST['id']." LIMIT 1";
mysql_query($query) or die(mysql_error());
echo 'if you see this it is deleted';

 

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.