View Full Version : 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
Colin-Roberts
13-10-2006, 11:45 AM
delete them in phpmyadmin
Jamie.
13-10-2006, 12:19 PM
yes, deleting in phpmyadmin will be the easiest
YouFail
13-10-2006, 01:32 PM
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
DELETE $variable FROM `tablename`
Please note that code doesn't work.
Dentafrice1
13-10-2006, 01:48 PM
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
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?
Dentafrice1
13-10-2006, 04:59 PM
Where your nav is :p
Lol i know that.
Thats the code above, the problem i have is it doesnt record the id?
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.