SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist safeasfcuk's Avatar
    Join Date
    Jan 2006
    Location
    UK (SWANSEA)
    Posts
    517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    deleting data from mysql

    im trying to make a link managment app to add links to my website i have made the script for adding links but not the deleting links. how do i go about this my mind is totaly blank? i mean how do i list the links and delet them?

    this is my code for the add links page any ides guys?

    Code:
    else if (isset($_GET['addlinks'])) {
    ?>
    <form action="" method=post>
    <p>Link Name:<br>
    <input type="text" name="frmlinkname" size="20" value="">
    <br>
    
    Link:<br>
    <input type="text" name="frmlink" size="20" value="">
    <br>
    
    <input type="submit" name="Submit" value="Submit">
    </p>
    </form>
    <?php
    
    
     if ($_POST['Submit']) {
     
    include ("dbconnect.php");
    
    $link = $_POST['frmlink'];
    $linkname = $_POST['frmlinkname'];
    
    $link="<a href=http://$link>$linkname</a>";
    
    $sql = "INSERT INTO links (id,link) VALUES ('', '$link')";
    
    //Executing the query with mysql_quey().
    
    
    //Executing the query with mysql_query().
    mysql_query($sql) or die(mysql_error());
    echo"Your link has been added";
    }
    }
    
    else if (isset($_GET['dellinks'])) {
    
    
    }

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    list.php
    PHP Code:
    include('dbconnect.php');
    $sql "SELECT * FROM links";
    $sql_result mysql_query($sql);
    while (
    $row mysql_fetch_array($sql_result)) {
      echo 
    "<a href=\"delete.php?id=" $row['id'] . "\">delete</a> " $row['link'] . "<br />";

    delete.php
    PHP Code:
    include('dbconnect.php');
    mysql_query("DELETE FROM links WHERE id = " $_GET['id']); 

  3. #3
    SitePoint Evangelist safeasfcuk's Avatar
    Join Date
    Jan 2006
    Location
    UK (SWANSEA)
    Posts
    517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks dave worked out same time u posted


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •