Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

check boxes and php!! :O

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

check boxes and php!! :O

Postby php-punk » Mon Feb 24, 2003 3:38 am

can somebody give me some idea on how i would create the code for a admins settings page for a guest book, were when logged in, the admin is abe to select certain posts and delete?!

any help on check boxes and PHP would be gratly appreciated!!
php-punk
New php-forum User
New php-forum User
 
Posts: 60
Joined: Sun Feb 02, 2003 2:10 am
Location: Leeds, Uk

Postby Oleg Butuzov » Mon Feb 24, 2003 5:03 am

if(isset($checkbox['$i']))
{
//Delete query
}
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby xlordt » Mon Feb 24, 2003 5:55 am

if($delete == '1'){
//delete from db
}else{
//what ever
}

<INPUT TYPE=\"checkbox\" NAME=\"delete\" VALUE=\"1\">
User avatar
xlordt
New php-forum User
New php-forum User
 
Posts: 34
Joined: Thu Dec 12, 2002 9:00 pm
Location: NJ

Postby php-punk » Mon Feb 24, 2003 6:04 am

thx pejone, but how would i apply that with multiple check boxes?

and how would i display it using the variables?|
php-punk
New php-forum User
New php-forum User
 
Posts: 60
Joined: Sun Feb 02, 2003 2:10 am
Location: Leeds, Uk

Postby Oleg Butuzov » Mon Feb 24, 2003 6:12 am

whan you will generate admin page

while($query=mysql_fetch_array($query))
{
echo "<input type=chackbox value=array[$data[id]]">;
}
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby php-punk » Mon Feb 24, 2003 8:05 am

ahh i think i get it now.. but how wud i removed only the checked values?
php-punk
New php-forum User
New php-forum User
 
Posts: 60
Joined: Sun Feb 02, 2003 2:10 am
Location: Leeds, Uk

Postby Redcircle » Mon Feb 24, 2003 8:10 am

they are put into the array if and only if they are checked
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby php-punk » Mon Feb 24, 2003 8:50 am

well i still dont get it, i'll look around for a script tha uses check boxes and learn from it, but thx n e way!!
php-punk
New php-forum User
New php-forum User
 
Posts: 60
Joined: Sun Feb 02, 2003 2:10 am
Location: Leeds, Uk

Postby Redcircle » Mon Feb 24, 2003 9:36 am

Code: Select all
<?php
if(isset($_POST['submit']))
{
  $size = sizeof($_POST['form_checkbox']);
  for($x=0; $x<$size); $x++)
  {
    echo $_POST['form_checkbox'][$x].'<br>';
  }
}
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="checkbox" name="form_checkbox[]" value="one"><br>
<input type="checkbox" name="form_checkbox[]" value="two"><br>
<input type="checkbox" name="form_checkbox[]" value="three"><br>
<input type="checkbox" name="form_checkbox[]" value="four"><br>
<input type="submit" name="submit" value="submit">

</form>
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot], Google Feedfetcher and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron