1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Delete MYSQL Rows

Discussion in 'Web Design & Development' started by bob121, Jul 6, 2007.

Thread Status:
Not open for further replies.
  1. bob121

    bob121 Thread Starter

    Joined:
    Sep 10, 2006
    Messages:
    207
    Hello,

    I was woundering if someone could help me out ,,

    what i would like is a script that:

    Connects to MYSQL

    Accesses my gbook table

    Displays A List In PHP Of All The Entrys

    And A Delete Button Next To Each one Or When You Click On The Item To Delete The Row

    Info You Will Need

    DB NAME = carsey_guestbook
    UserName = carsey_carsey
    password = i will enter that just put in its place "password"

    Name Of Items In Row:
    Name
    Email
    Post

    I Have Made A Script Like This Before But Can't Seem To Make Them Now , I Believe Its Fairly Easy If You Have An Idea In PHP.

    Thanks In Advance James


    Also if you do require any extra infomation please do request it.
     
  2. bob121

    bob121 Thread Starter

    Joined:
    Sep 10, 2006
    Messages:
    207
    I Have Done This So Far , Not Completly working tho:
    It displays each Post and it says i have deleted it when i click on it but dosnt attucaly delete it.
    can anyone see an error

    Code:
    <?
    switch($_GET['do']) {
    default:
    
    $gbook = mysql_query("SELECT * FROM `gbook` ORDER by `name` ASC");
    while($n=mysql_fetch_array($gbook)) {
    echo("<b>ID:</b> $n[ID]<br/>
        <b>Name:</b> $n[name]<br/>
    	<b>Email:</b> $n[email]<br />
    	<b>Post:</b> $n[post]<br/>
    	<b>Action:</b> <a href=\"gbook.php?do=del&book=$n[ID]\">Delete</a><br/> <br>");
    }
    
    break;
    
    case "del" :
    	$id = $_GET[book];
    	$obtainbooks = mysql_query("SELECT * FROM `gbook` WHERE `ID`= '$ID'");
    	$gb = mysql_fetch_array($obtainbooks);
    echo ("You've deleted the entry");
    	    mysql_query("DELETE FROM `gbook` WHERE `ID` = '$gb[ID]'");
    break;
    }
    ?>
    
    
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/592529

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice