Web Based Admin Probs

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

Web Based Admin Probs

Post by blacksnday »

I am attempting to create a webbased admin that allows for
viewing/updating(editing)/and deletion of records pulled from mysql.

I understand how to do a Delete but am having trouble how to do the
delete when using variables to pull the info from the database.

In this example, I am pulling categories from the DB and would like help
with how to create delete options based on the example.

Code: Select all

$query = mysql_query("SELECT * FROM categories WHERE parentid = 0 ORDER BY catid ASC");
while($cat=mysql_fetch_array($query)){
echo "
<p><a href=\"sub.php?c=$cat[catid]\">$cat[catname]</a>
$cat[description]</p>
";
}
Which the above could create something like
Name and link to Category
This would be the category decription.

and to do a delete would be something like

Code: Select all

$cats = mysql_query("DELETE * FROM categories WHERE catid = $this is the problem");
I cant seem to figure out how to assign the WHERE catid = $this is the problem
to correctly get the catid from the first example.

Just like to say I have been able to delete by manually suggesting what to delete

Code: Select all

$cats = mysql_query("DELETE * FROM categories WHERE catid = 10");
Its the dang variables I am again having trouble with to work in unison regardless of the
function/query/etc :P
ruchit
Forum Commoner
Posts: 53
Joined: Mon Sep 26, 2005 6:03 am

Post by ruchit »

Code: Select all

$cats = mysql_query("DELETE FROM categories WHERE catid = {$_GET['c']}");
Post Reply