Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-11-2004, 09:56 PM
Novice Webmaster
 
Join Date: Feb 2003
Location: JB
Posts: 26
Rep Power: 0
koisempoi is on a distinguished road
Send a message via Yahoo to koisempoi
Multiple data

alloo gang. aku nak tanya macamana nak generate multiple data daripada checkbox.macam dalam hotmail tu.bagaimana nak paparkan atau delete data yang dipilih melalui checkbox dalam satu form.ini kod page pilih data.macamana kod papar atau delete data pula ?

PHP Code:
<?php 
include 'dbase.php';

$query="SELECT * FROM ahli";
$result=mysql_db_query($dbname,$query);
$num=mysql_num_rows($result);
//$row=mysql_fetch_array($r);
//$username=$row['username'];

?>

<?php while($row=mysql_fetch_array($result)) { 
$username=$row['username'];
?>
<form name="form1" method="post" action="test2.php">
 <input name="pilih" type="checkbox" id="pilih">
 <?php echo $username?>
  <br>
  <?php ?>
  <input type="submit" name="Submit" value="Submit">
</form>

Last edited by koisempoi; 04-11-2004 at 10:02 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 10-11-2004, 09:40 PM
zaimlah's Avatar
Inspired Webmaster
 
Join Date: Jul 2001
Location: ttdi
Posts: 129
Rep Power: 91
zaimlah is on a distinguished road
ok. first of all, aku rasalah, code yg di-post-kan tu ada salah sikit; the <form...> tag kena letak sebelum while loop, kalau tak nanti dia keluar banyak2.

utk jawab soalan. kalau aku betul2 paham la, macam ni:
PHP Code:
<?php 
include 'dbase.php';
$query="SELECT * FROM ahli";
$result=mysql_db_query($dbname,$query);
$num=mysql_num_rows($result);
//$row=mysql_fetch_array($r);
//$username=$row['username'];
?>
<form name="form1" method="post" action="test2.php">
<?php while($row=mysql_fetch_array($result)) { 
$username=$row['username'];
?>
 <input name="pilih[]" type="checkbox" id="pilih" value="<?=$username?>">
 <?php echo $username?>
  <br>
  <?php ?>
  <input type="submit" name="Submit" value="Submit">
</form>
notice: <form> tag sebelum while loop, dalam <input> tag, name="pilih[]" dan ada value="<?=$username?>".

so dalam script test2.php, boleh access variable $_POST['pilih'] ... iaitu satu array yg ada semua username2 yg user check.
__________________
blog:zaim_bakar_blog | biz:box
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 13-11-2004, 12:10 AM
Novice Webmaster
 
Join Date: Feb 2003
Location: JB
Posts: 26
Rep Power: 0
koisempoi is on a distinguished road
Send a message via Yahoo to koisempoi
ok...

maaflah, tapi masalah sebenar aku untuk buat array tu lah.aku tak tau camana nak identify name dan value setiap checkbox dan memaparkan mengikut array yang telah dibina. boleh x kau tolong tunjukkan contohnya ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 24-11-2004, 10:05 PM
zaimlah's Avatar
Inspired Webmaster
 
Join Date: Jul 2001
Location: ttdi
Posts: 129
Rep Power: 91
zaimlah is on a distinguished road
Re: ok...

oh, ok... sorry lah, saya still tak faham lah, especially ayat ni:
Quote:
Originally posted by koisempoi
...nak identify name dan value setiap checkbox dan memaparkan mengikut array yang telah dibina...
possible ke untuk explain dgn lebih-lebih lanjut?
__________________
blog:zaim_bakar_blog | biz:box
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 27-11-2004, 11:26 AM
heterozigot's Avatar
Novice Webmaster
 
Join Date: Jan 2003
Location: PJ
Posts: 51
Rep Power: 71
heterozigot is on a distinguished road
Send a message via ICQ to heterozigot Send a message via Yahoo to heterozigot
macam ni:

if(isset($_POST['namaButtonSubmit'])){

$pilih=$_POST['pilih'];

for($i=0; $i<count($pilih); $i++){
echo $pilih[$i].'<br>';
$query1="delete from HEHE where id=".$pilih[$i];
mysql_query($query1);
}

}


btol tak apa aku maksudkan ni. Ke lain ko nak?
__________________
Try and Support Malaysia Product.
http://foto.home.net.my
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 06-12-2004, 10:51 AM
Novice Webmaster
 
Join Date: Feb 2003
Location: JB
Posts: 26
Rep Power: 0
koisempoi is on a distinguished road
Send a message via Yahoo to koisempoi
yap betulll

betullahtu heterozigot.ni penyelesaian dia

test1.php
PHP Code:
<?php 
include 'dbase.php';

$query="SELECT * FROM test";
$result=mysql_db_query($dbname,$query);
$num=mysql_num_rows($result);
//$row=mysql_fetch_array($r);
//$username=$row['username'];

?>

<form action="test2.php" method="post" name="form" id="form">
<?php while($row=mysql_fetch_array($result)) { 
//$username=$row['username'];
$nama=$row['nama'];
$id_ahli=$row['id_ahli'];
?>
 <input name="pilih[]" type="checkbox" id="$pilih[];" value="<?php echo $id_ahli?>">
 <?php echo $nama?>
  <?php echo $id_ahli;?><br><?php ?>
  <input type="submit" name="Submit" value="Submit">
</form>
test2.php
PHP Code:
<?php
include 'dbase.php';

if (isset(
$_POST['Submit'])) {
$pilih=$_POST["pilih"];
for(
$i=0;$i<count($pilih);$i++) {
echo 
$pilih[$i].'<br>';
$query="DELETE FROM test WHERE id_ahli=".$pilih[$i];
$result=mysql_db_query($dbname,$query);
}
}

?>

dah banyak tempat aku tanya benda ni tapi xda yg dapat jawab.korang mmg tererlah.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
insert data into multiple table azmaliya Website Programming 18 06-08-2005 11:02 AM
checking multiple emails from multiple domain mrbadak Mamak Stall 4 28-06-2005 08:59 PM
hosting with multiple domain jawa Paid Hosting Discussion Forum 14 23-11-2004 05:39 PM
Multiple database class hajime Website Programming 4 02-09-2004 02:58 PM
insert multiple data vash Website Programming 4 28-04-2004 02:48 PM



All times are GMT +8. The time now is 10:21 AM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59