Results 1 to 8 of 8

Thread: Mysql help

  1. #1
    Join Date
    Sep 2006
    Posts
    2,114
    Tokens
    0

    Latest Awards:

    Default Mysql help

    Okay well i have a script which i can use to put links and stuff onto my nav.

    But..

    I need a way to be able to delete them.

    I think i need a my page with a sql script so it deletes it form the database by id.

    Am i right?

    Becuase i aint very good at mysql, could someone write it for me please.

    Thanks

    Chris
    Looking for a good desiner to design a social networking template.

    PM me.

  2. #2
    Join Date
    Feb 2006
    Location
    Ontario Canada
    Posts
    4,587
    Tokens
    0

    Latest Awards:

    Default

    delete them in phpmyadmin

    .:.:#14:.:. .:.: Impossible Is Nothing :.:. .:.: 845 Rep:.:.
    .:.: Stand up for what is right, even if you stand alone:.:.


  3. #3
    Join Date
    Jul 2005
    Location
    -
    Posts
    2,995
    Tokens
    0

    Latest Awards:

    Default

    yes, deleting in phpmyadmin will be the easiest

  4. #4
    Join Date
    Mar 2006
    Location
    Scotland
    Posts
    1,012
    Tokens
    175

    Latest Awards:

    Default

    Actually it wouldn't.

    When I get back i'll write you a script but all you would need to do is have a drop-down menu and a submit box. When you click the submit box it performs an action such as

    Code:
    DELETE $variable FROM `tablename`
    Please note that code doesn't work.


    You don't like me
    Chances are I don't like you.

  5. #5
    Join Date
    Apr 2005
    Location
    North Carolina, USA
    Posts
    4,535
    Tokens
    0

    Latest Awards:

    Default

    Or something like this:

    <?
    include "config.php";

    if($_GET[action] == "delete") {
    mysql_query("DELETE FROM nav WHERE id='$_GET[id]'") or die(mysql_error());
    }else{


    $query = mysql_query("SELECT * FROM nav ORDER BY id DESC");
    while($row = mysql_fetch_array($query) {
    ?>
    <a href="?action=delete&id=<? echo $row[id]; ?>"><? echo $row[name]; ?></a>
    <?
    }
    }
    ?>

  6. #6
    Join Date
    Sep 2006
    Posts
    2,114
    Tokens
    0

    Latest Awards:

    Default

    So if i have this script:

    PHP Code:

    <?php
    include('config.php');
    include(
    'header.php');

    $q mysql_query("SELECT * FROM links sort by `id` ASC"); // querys the db

    while($r=mysql_fetch_array($q)){ // gets the links in the db

    $title $r["title"]; // the title of the link
    $url $r["url"]; // the url for the link

    echo "<table width=\"100%\">
    <tr>
    <td><a href=\"
    $url\" target='content'>$title</a><br></td>
    </tr>
    </table>"
    ;
    }
    mysql_close(); // closes the mysql connection
    ?>
    where would i put it?
    Last edited by Ini; 13-10-2006 at 05:04 PM.
    Looking for a good desiner to design a social networking template.

    PM me.

  7. #7
    Join Date
    Apr 2005
    Location
    North Carolina, USA
    Posts
    4,535
    Tokens
    0

    Latest Awards:

    Default

    Where your nav is :p

  8. #8
    Join Date
    Sep 2006
    Posts
    2,114
    Tokens
    0

    Latest Awards:

    Default

    Lol i know that.

    Thats the code above, the problem i have is it doesnt record the id?
    Looking for a good desiner to design a social networking template.

    PM me.

Posting Permissions

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