| 
	
 | 
 Posted by James54321 on 10/23/06 17:05 
Ok I have modified it like you said but i still have the same problem 
NONE of the code is executed (even the echo("something is said here");) 
doesnt work so i dont think the function is being called corectly 
....but I have no idea why ...if you do please tell me. 
 
Below is my revised code: 
 
<?php 
//include('../config.php'); 
include('../head.php'); 
	echo("<body bgcolor=\"lightblue\">"); 
	echo("<title>approval</title>"); 
include('../links.php'); 
echo("<BR><BR>"); 
 
	// open connection 
	$connection = mysql_connect($host, $user, $pass) or die ("Unable to 
connect!"); 
 
	// select database 
	mysql_select_db($db) or die ("Unable to select database!"); 
 
displayIdeas(); 
 
 
 
 
 
 
function displayIdeas() 
{ 
//funciton opened 
 
    // create query 
$query = "SELECT ID,Idea_Name,Category,Idea,Time,Date,User,IP_Address 
FROM ideas WHERE Approved = 0 AND Category != 'ADMIN' Order by 'id' 
ASC"; 
 
	//replace sites with your table name 
	//replace address and description with the filed name 
 
    // execute query 
    $result = mysql_query($query) or die ("Error in query: $query. 
".mysql_error()); 
 
echo("<form method=\"post\">"); 
 
print "\n<table border=\"1\">\n<tr>\n" . 
	"\n\t<th>Approve</th>" . 
	"\n\t<th>Delete</th>" . 
	"\n\t<th>Ban</th>" . 
	"\n\t<th>Idea ID</th>" . 
	"\n\t<th>Idea Name</th>" . 
	"\n\t<th>Category</th>" . 
	"\n\t<th>Idea</th>" . 
	"\n\t<th>Time Submitted</th>" . 
	"\n\t<th>Date Submitted</th>" . 
	"\n\t<th>User</th>" . 
	"\n\t<th>IP Address</th>" . 
	"\n</tr>"; 
 
	while($row = mysql_fetch_row($result)) { 
	list($ID,$Idea_Name,$Category,$Idea,$Time,$Date,$User,$IP_Address) = 
$row; 
{ 
 
if ($rowcounter == '1') { 
 
	print "\n<tr bgcolor=\"yellow\">"; 
 
	$rowcounter = '2'; 
} else { 
 
	print "\n<tr bgcolor=\"lightblue\">"; 
 
	$rowcounter = '1'; 
} 
 
	print "\n\t<td><center><input type=\"radio\" name=\"id[$ID]\" 
value=\"Approve\" /></center></td>"; 
 
	print "\n\t<td><center><input type=\"radio\" name=\"id[$ID]\" 
value=\"Delete\" /></center></td>"; 
 
	print "\n\t<td><center><input type=\"radio\" name=\"id[$ID]\" 
value=\"Ban\" /></center></td>"; 
} 
 
foreach($row as $data) 
 
	print "\n\t<td> {$data} </td>"; 
 
	print "\n</tr>"; 
 
} 
print "\n</table>\n"; 
echo("<input type=\"submit\" name=\"submit\" 
value=\"Go\"></td></form>"); 
} 
//function closed 
 
 
 
 
if (isset($_POST['submit'])) { 
 
//this is where the code i need should go :) 
 
	foreach ($_POST['id'] as $key => $value) { 
	switch ($value) { 
		case "Approve": 
		submission_approve($key); 
		case "Delete": 
		submission_approve($key); 
		break; 
		case "Ban": 
		submission_ban($key); 
		break; 
		default: 
		echo"hi key = $key and value = $value"; 
		break; 
	} 
	} 
 
 
 
 
//Well, that `submission_delete_or_whatever_it_was` is a function that 
deletes (or something else) the submission of the id $key. 
 
 
	//close connection 
	mysql_close($connection); 
 
function submission_approve($key) 
{ 
	// create query 
	$query = "UPDATE ideas SET Approved = 1 WHERE ID = $key"; 
 
	//replace sites with your table name 
	//replace address and description with the filed name 
 
	// execute query 
	$result = mysql_query($query) or die ("Error in query: $query. 
".mysql_error()); 
 
	// print message with ID of inserted record 
	echo ("Idea $id has been approved!<BR>"); 
 
} 
 
 
 
 
 
function submission_delete($key) 
{ 
	// create query 
	$query = "DELETE FROM ideas WHERE ID = $key"; 
 
	//replace sites with your table name 
	//replace address and description with the filed name 
 
	// execute query 
	$result = mysql_query($query) or die ("Error in query: $query. 
".mysql_error()); 
 
	// print message with ID of inserted record 
	echo ("Idea $id has been deleted!<BR>"); 
 
} 
 
 
 
 
 
function submission_ban($key) 
{ 
	// create query 
	$query = "INSERT INTO temp (ID, type) VALUES ('$key','banned')"; 
 
	//replace sites with your table name 
	//replace address and description with the filed name 
 
	// execute query 
	$result = mysql_query($query) or die ("Error in query: $query. 
".mysql_error()); 
 
	// print message with ID of inserted record 
	echo ("The IP address that submitted idea $id has been banned!<BR>"); 
} 
 
 
} 
 
?>
 
  
Navigation:
[Reply to this message] 
 |