-
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
-
delete them in phpmyadmin
-
yes, deleting in phpmyadmin will be the easiest
-
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.
-
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>
<?
}
}
?>
-
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?
-
-
Lol i know that.
Thats the code above, the problem i have is it doesnt record the id?