Jump to content


checkboxes


  • You cannot reply to this topic
No replies to this topic

#1 Indigo

    Official Alien

  • Members
  • PipPipPip
  • 617 posts
  • Gender:Male
  • Location:Trondheim, Norway
  • Interests:Computing in general, especially design and programming of all kinds.

Posted 06 January 2006 - 06:18 PM

Ok, so I'm coding an adminsystem where the admin should be able to delete news, and not just one news, but more at the same time. So here's my code so far:

The form:
 
function main(){
	print("	<div style='background-color: #aa7aaa; height: 32px; padding: 4px;'>
			<a href='funksjoner.php?do=skrivny'>Legg til nyhet</a><br />
			</div><br />
			
			<form action='funksjoner.php?do=slett' method='post'>
			<table width='500'>");
	
			
	$hent = mysql_query("select * from nyheter");
	while($r=mysql_fetch_array($hent)) { 
		$dato=$r["dato"];
		$nyhet=$r["nyhet"];
		$nyhet=nl2br($nyhet);
		$id=$r["id"];
		print("	<tr> 
					<td width='20' valign='top'><input name='list[]' type='checkbox' id='list' value='$id'></td>
					<td width='480' valign='top'><a href='funksjoner.php?do=rediger&id=\".$id.\"'>$dato</a>: $nyhet</td>
				  </tr>
			");
	}
	print("	</table>
			</form>
		");
}

The Delete function( s):
function slett($id){
	print("	<form action='funksjoner.php?do=fjern' method='post'>
			<span id='overskrift'>ADVARSEL</span><br />
			Ved å trykke knappen under velger du å slette nyheten.
			Vær klar over at du ikke kan gjøre om dette valget, kontroller derfor at du er i ferd med å slette rett nyhet.<br />
			<input name='submit' type='submit' value='Slett nyhet'>
			<input type=hidden name='id' value='.$id.'> 
			</form>");
}

function slettfradb($id){
	$checked= $_POST['list'];
	foreach ($checked as $delete) {
	$hent = "DELETE FROM nyheter WHERE id='$delete'"; 
	$slett = mysql_query($hent); 
	print ("Nyheten har blitt slettet.<br />
	<a href='$dennesiden?'>Tilbake</a>"); 
}
}

Now, I tryed to follow this tutorial: http://www.somacon.com/p117.php, but I do not know how to integrate it into my code.
Any help appreciated ;)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users