sandbudd Posted June 30, 2008 Share Posted June 30, 2008 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 More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 first of all you need to add a check box to the end. Link to comment https://forums.phpfreaks.com/topic/112555-solved-add-delete-button/#findComment-578025 Share on other sites More sharing options...
sandbudd Posted June 30, 2008 Author Share Posted June 30, 2008 then what do I do please? Link to comment https://forums.phpfreaks.com/topic/112555-solved-add-delete-button/#findComment-578027 Share on other sites More sharing options...
Guest Posted June 30, 2008 Share Posted June 30, 2008 echo "<a href='delete.php?id=".$info['id']."'>delete</a>"; then on delete.php $query="DELETE FROM ae_gallery WHERE id=".$_REQUEST['id']." LIMIT 1"; of course theres alot more to it than that but theres some place to start Link to comment https://forums.phpfreaks.com/topic/112555-solved-add-delete-button/#findComment-578028 Share on other sites More sharing options...
sandbudd Posted June 30, 2008 Author Share Posted June 30, 2008 Jeff can you point me in the right direction to finish the code? Link to comment https://forums.phpfreaks.com/topic/112555-solved-add-delete-button/#findComment-578034 Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 <?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 Link to comment https://forums.phpfreaks.com/topic/112555-solved-add-delete-button/#findComment-578038 Share on other sites More sharing options...
Guest Posted June 30, 2008 Share Posted June 30, 2008 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'; Link to comment https://forums.phpfreaks.com/topic/112555-solved-add-delete-button/#findComment-578041 Share on other sites More sharing options...
sandbudd Posted June 30, 2008 Author Share Posted June 30, 2008 perfect worked great thanks guys Link to comment https://forums.phpfreaks.com/topic/112555-solved-add-delete-button/#findComment-578047 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.