Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Data Deletion with $GET

Asked Modified Viewed 2,294 times
D
Digital Remix
D
~ Digital
  • Junior Member, joined since
  • Contributed 22 posts on the community forums.
  • Started 4 threads in the forums
  • Started this discussions
asked
Junior Member

Alright. So I'm trying to make a data table very similar to the members.php list. It features 4 columns of data, then the 5th is the delete column, where the admin clicks the delete link and it deletes the row of data from the database. For some reason, it eludes me.

Here's the datatable:
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]
opentable('Discharges'wink;
$result = dbquery("SELECT * FROM fusion_discharges"wink;
$rows = dbrows($result);
if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) {
$_GET['rowstart'] = 0;
}
if ($rows) {
$i = 0;
echo "<table class='tbl-border' cellpadding='5' cellspacing='2' align='center' width='100%'>";
echo "<tr>";
echo "<td class='tbl2'><strong>Rank</strong></td>";
echo "<td class='tbl2'><strong>Name</strong></td>";
echo "<td class='tbl2'><strong>Type</strong></td>";
echo "<td class='tbl2'><strong>Date</strong></td>";
echo "<td class='tbl2'><strong>Options</strong></td>";
echo "</tr>";

$result = dbquery("SELECT * FROM fusion_discharges LIMIT ".$_GET['rowstart'].",20"wink;
while ($data = dbarray($result)) {
$cell_color = ($i % 2 == 0 ? "tbl1" : "tbl2"wink; $i++;
echo "<tr>";
echo "<td class='$cell_color'>".$data['discharge_rank']."</td>";
echo "<td class='$cell_color'>".$data['discharge_name']."</td>";
echo "<td class='$cell_color'>".$data['discharge_type']."</td>";
echo "<td class='$cell_color'>".$data['discharge_date']."</td>";
echo "<td class='$cell_color'><a href='".FUSION_SELF.$aidlink."&amp;delete=".$data['discharge_name']."'>Delete</a></td>";
echo "</tr>";
}
echo "</table>";
} else {
echo "<center><br />There seems to be an error.<br /><br /></center>";
}

if ($rows > 20) {
echo "<div align='center' style='margin-top:5px;'>".makepagenav($_GET['rowstart'], 20, $rows, 3, FUSION_SELF.$aidlink."&amp;"wink."</div>";
}
closetable();[/syntaxhighlighter]

Now to my understanding, the following needs to be included which I threw in at the top of the file.

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]if (isset($_GET['delete']) && isnum($_GET['delete'])) {
$result = dbquery("DELETE FROM fusion_discharges WHERE discharge_name='".$_GET['delete']."'"wink;
redirect(FUSION_SELF.$aidlink);
}[/syntaxhighlighter]

I see no error in this code. I'm not new to coding either, I've been around these forums for a while, but I never tried something like this, and I really can't get it right and it's annoying me.

I'm open to suggestions from my fellow developers.
0 replies

2 posts

B
Basti
B
Basti 10
[PHP-Fusion Crew Member & Admin from June 2008 - December 2010]

http://basti2web.de - Support Site for my infusions
  • Veteran Member, joined since
  • Contributed 1,099 posts on the community forums.
  • Started 32 threads in the forums
answered
Veteran Member

The function isnum() checks if the $_GET['delete'] is a number.
I guess it is not a number, but a name in your code.
So the IF will never be true.
Edited by Basti on 11-11-2010 08:24,
0 replies
D
Digital Remix
D
~ Digital
  • Junior Member, joined since
  • Contributed 22 posts on the community forums.
  • Started 4 threads in the forums
  • Started this discussions
answered
Junior Member

How stupid of me.

You sir are a gentleman and a scholar. I greatly appreciate the assistance.
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 2 posts
  • Votes 0 votes
  • Topic users 2 members

2 participants

B
B
Basti 10
[PHP-Fusion Crew Member & Admin from June 2008 - December 2010]

http://basti2web.de - Support Site for my infusions
  • Veteran Member, joined since
  • Contributed 1,099 posts on the community forums.
  • Started 32 threads in the forums
D
D
~ Digital
  • Junior Member, joined since
  • Contributed 22 posts on the community forums.
  • Started 4 threads in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet