SQL delete query
mdb Offline
Junior Member
**
Posts: 27
Joined: May 2012
Post: #5
RE: SQL delete query
Hmm, for passing the table name as an ID, do you mean creating a variable for that?

In the script now where the delete button is shown, the user has the option to view a ban list from a few different tables using a switch:

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
switch($_GET['s']){
	case '1' :
		$sname = 'Ban List 1';
		$stable = 'ban_list_1';
		break;
	case '2' :
		$sname = 'Ban List 2';
		$stable = 'ban_list_2';
		break;
	default:
		$sname = 'Ban List 1';
		$stable = 'ban_list_1';
}


So basically with that code, I should just add in this?

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
switch($_GET['s']){
	case '1' :
		$sname = 'Ban List 1';
		$stable = 'ban_list_1';
		$id = '1';
		break;
	case '2' :
		$sname = 'Ban List 2';
		$stable = 'ban_list_2';
		$id = '2';
		break;
	default:
		$sname = 'Ban List 1';
		$stable = 'ban_list_1';
		$id = '1';
}


Also, how would I get ID's of each row? I was thinking maybe assigning them in the while loop like so:

Code:
1
2
3
4
5
6
7
8
9
10
11
$i = 0;
$rowid = 0;
while( ( $row = mysql_fetch_array( $result ) ) ) {
	$rowid = $rowid + $i;
	$row['name'] = htmlspecialchars( $row['name'] );
	$maskip = MaskIP( $row['ip'] );
	$row['ban'] = htmlspecialchars( $row['ban'] );
	$row['ban_created'] = gmdate("d-M-h:ia", $row['ban_created'] + $zone);
	$i++;
	eval("\$ban_results .= \"".$templates->get("test_page_row")."\";");
}


Something like that? But then how would I use that data on the delete_ban.php without running that same while loop on it? Since that id isn't recorded into the sql table.

Or am I totally thinking of this in a wrong way? hahaha.

(This post was last modified: 10-23-2012 09:42 AM by mdb.)
10-23-2012 09:40 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
SQL delete query - mdb - 10-21-2012, 05:30 PM
RE: SQL delete query - ZiNgA BuRgA - 10-21-2012, 10:01 PM
RE: SQL delete query - mdb - 10-22-2012, 03:00 AM
RE: SQL delete query - ZiNgA BuRgA - 10-22-2012, 09:14 AM
RE: SQL delete query - mdb - 10-23-2012 09:40 AM
RE: SQL delete query - ZiNgA BuRgA - 10-24-2012, 08:19 AM
RE: SQL delete query - devid456 - 07-06-2013, 12:45 AM

 Standard Tools
Forum Jump: