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

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-09-2003, 11:43 PM
miss_tlot's Avatar
Novice Webmaster
 
Join Date: Jun 2003
Location: Terengganu
Posts: 10
Rep Power: 0
miss_tlot is on a distinguished road
cara nak delete data

Assalamualaikum...

ada sesapa tau nak delete pakai checkbox tak? atau delete cam style kat phpmyadmin tu... saya buat dua-dua tu, tapi dia tak nak kenal id, so dia tak delete...

nie coding yang saya buat untuk delete style kat phpmyadmin tu...

viewall.php
<HTML>
<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("sppjibw",$db);
$result = mysql_query("SELECT * FROM personnel",$db);
echo "<TABLE BORDER=2>";

echo"<TR><TD><B>Nama</B><TD><B>Email</B><TD><B>Pilihan</B></TR>";
while ($myrow = mysql_fetch_array($result))
{
echo "<TR><TD>".$myrow["nama"]." ".$myrow["email"]."<TD>".$myrow["negeri"];
echo "<TD><a href=\"view.php?id=".$myrow[id]."\">View</a>";
echo "<TD><a href=\"delete.php?id=".$myrow[id]."\">Delete</a>";

}
echo "</TABLE>";
?>
</HTML>

delete.php
<HTML>
<?php
$db = mysql_connect("localhost", "", "");
mysql_select_db("sppjibw",$db);
mysql_query("DELETE FROM personnel WHERE id=$id",$db);
echo "Information Deleted";
?>
</HTML>

please somebody tolong betulkan/tambah apa yang patut...

tima kasih
__________________
Tlot
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 08-09-2003, 01:26 PM
zaimlah's Avatar
Inspired Webmaster
 
Join Date: Jul 2001
Location: ttdi
Posts: 129
Rep Power: 91
zaimlah is on a distinguished road
waalaikumsalam...

follow up questions:
1) kalau run script tu, ada keluar error tak? kalau ada, apa error yang dikeluarkan?
2) version PHP apa yg anda gunakan?

daripada coding yg telah di-copy-paste-kan, saya tidak dapat mengenal pasti sebarang error atau masalah besar (masalah2 kecil adalah). mungkin ada tapi tak nampak...

ini dia pembetulan kepada beberapa masalah kecil:

viewall.php:
PHP Code:
<HTML>
<?php
$db 
mysql_connect("localhost""""");
mysql_select_db("sppjibw",$db);
$result mysql_query("SELECT * FROM personnel",$db);
echo 
"<TABLE BORDER=2>";

echo
"<TR><TD><B>Nama</B><TD><B>Email</B><TD><B>Pilihan</B></TR>";
while (
$myrow mysql_fetch_array($result))
{
echo 
"<TR><TD>".$myrow["nama"]." ".$myrow["email"]."<TD>".$myrow["negeri"];
echo 
"<TD><a href=\"view.php?id=".$myrow["id"]."\">View</a>";
echo 
"<TD><a href=\"delete.php?id=".$myrow["id"]."\">Delete</a>";

}
echo 
"</TABLE>";
?>
</HTML>
tukarkan $myrow[id] kepada $myrow["id"]


delete.php:
PHP Code:
<HTML>
<?php
$id 
$_GET["id"]; //atau $id = $HTTP_GET_VARS["id"] utk PHP version sebelum 4.1.0
$db mysql_connect("localhost""""");
mysql_select_db("sppjibw",$db);
mysql_query("DELETE FROM personnel WHERE id=$id",$db);
echo 
"Information Deleted";
?>
</HTML>
tambahkan:
$id = $_GET["id"]; (untuk PHP 4.1.0 ke-atas), atau
$id = $HTTP_GET_VARS["id"]; (untuk PHP 4.1.0 ke-bawah)
__________________
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 08-09-2003, 01:39 PM
zaimlah's Avatar
Inspired Webmaster
 
Join Date: Jul 2001
Location: ttdi
Posts: 129
Rep Power: 91
zaimlah is on a distinguished road
beberapa tips...

masalah2 kecil ni mungkin tak ada kena-mengena langsung dengan kenapa dia tak delete... tapi try dulu, mana tau

kpd sesiapa yg berminat, ini dia beberapa tips kalau script anda tak berjalan dgn lancar:[list=1][*]tengok kalau ada apa-apa mysql/php error [*]pastikan semua reference kepada assiociative array di-quote-kan (cth: $myrow["id"], bukan $myrow[id])[*]guna $_GET["??"] atau $HTTP_GET_VARS["??"] utk access variable dari 'luar', cth: form atau url(delete.php?id=xx).[*]periksa semua ejaan dan case(huruf besar/kecil) mysql table/field[/list=1]
__________________
blog:zaim_bakar_blog | biz:box
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-09-2003, 10:12 PM
MHR's Avatar
MHR MHR is offline
Senior Webmaster
 
Join Date: Sep 2001
Location: epox
Posts: 435
Rep Power: 95
MHR is on a distinguished road
Send a message via ICQ to MHR Send a message via Yahoo to MHR
aku rasa elok lagi kalau guna single quote or whatever its called

i) $_GET['bleh']
ii) $_GET["bleh"]
laju lagi i)

$foo = 'yay';
i) and string $var = "hoo $foo";
ii) and string $var = 'hoo'.$foo;

laju lagi ii) sebab " akan parse kan string tu. tak silap aku aa


i may be wrong
__________________
Munzir + "/^[Hh](a)(z)\1\2[iI]$/"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-09-2003, 08:51 PM
hymns's Avatar
Senior Webmaster
 
Join Date: Nov 2001
Location: Johor
Posts: 768
Rep Power: 100
hymns is on a distinguished road
Send a message via ICQ to hymns Send a message via Yahoo to hymns
kalau nak laju lagi guna 'Output Buffering'

<?php
ob_start();

echo ("Hue heuhwew ewewuehwe");

ob_end_flush();
?>

hik hik... more better speed use cache scheme! =)
__________________
I hate when:

vBulletin Message:
Sorry! The administrator has specified that users can only post one message every 60 seconds
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 24-09-2003, 04:00 PM
white_neck's Avatar
Senior Webmaster
 
Join Date: Jan 2003
Location: dreamland
Posts: 240
Rep Power: 75
white_neck is on a distinguished road
Send a message via Yahoo to white_neck
aku dah test..
tak der error pun...
tp yg zaimlah ckp tu btul...

penggunaan " samaer jer
kalau ko dah pakai "
so dalam " " ko kena la pakai '' plak

btul ker? :P
__________________
^_^ <== stay happy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 24-09-2003, 04:48 PM
Ben-davis's Avatar
Senior Webmaster
 
Join Date: Jan 2002
Location: SoObHanG JhaYa
Posts: 501
Rep Power: 93
Ben-davis is on a distinguished road
Send a message via ICQ to Ben-davis Send a message via Yahoo to Ben-davis
aku rasa html lagi laju.... ... melawak je....

apa yang zaimlah ngan MHR taip tu betul... nampak mudah je, padahal kalau silap sket yang tu, habis la...
__________________
<form name="jump">
<select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" style="border:1px #393F31 solid;color:#393F31;font:10px Verdana;font-weight:bold;" >
<option value="0" style="background: #9CC8FE" selected>*SELECT-LINKS</option>
<option value="http://www.gengturbo.org/" style="background: #FF0000">GENGTURBO</option>
<option value="http://www.phixelgrafix.com/" target="new" style="background: #C6D607">PHIXELGRAFIX</option>
<option value="http://dailydigital.phixelgrafix.com/" style="background: #FCBC45">OLD-BLOG</option>
<option value="http://www.mesrahosting.net/" style="background: #FF99CC">WEBHOSTING</option>
</select>
</form>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 25-09-2003, 11:10 AM
white_neck's Avatar
Senior Webmaster
 
Join Date: Jan 2003
Location: dreamland
Posts: 240
Rep Power: 75
white_neck is on a distinguished road
Send a message via Yahoo to white_neck
a ah... html lagi laju.... kalau php pakai echo tuh lambat skit jer la... sbb nak process kan... tak perasan pun... tp kalau dah satu page ko pakai echo tu... agak kedaung skit
__________________
^_^ <== stay happy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 25-09-2003, 12:16 PM
DingDang's Avatar
Normal User
 
Join Date: Jul 2001
Location: eRakan.Net
Posts: 118
Rep Power: 91
DingDang is on a distinguished road
Send a message via ICQ to DingDang Send a message via Yahoo to DingDang
urm.. kalau guna satu sahaja echo untuk printkan kesemua nilai2 tadi?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 25-09-2003, 12:25 PM
white_neck's Avatar
Senior Webmaster
 
Join Date: Jan 2003
Location: dreamland
Posts: 240
Rep Power: 75
white_neck is on a distinguished road
Send a message via Yahoo to white_neck
boleh gak... tp still samer... php kena proses... alaaa.. takde per2
samer jer... korang buat jer mana2 pun..
bg aku kalau seperate lg elok...
sbb kalau bukak fail php dlm dreamweaver ker golive ker.... kiter bleh tgk interface web kiter.. tu jer..
tp kalau pakai echo print semua..
kalau bukak php guna dreamweaver, nanti kat interface tu cam kosong jer..
so lambat skit development

any way result biler run benda tuh still the same...
__________________
^_^ <== stay happy
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
Add, Update and Delete using ASP prompter46 Website Programming 6 25-04-2007 06:12 PM
Cara.com.my & Cara Local - Malaysian Web & Local Search caracom Websites Review and Suggestion 0 30-11-2006 02:02 PM
Disable Delete & upload? how? Zapgirl Webmaster Tools 2 19-11-2005 12:21 AM
kalau insert or delete lak camner adique_7 Website Programming 2 03-05-2002 12:28 AM



All times are GMT +8. The time now is 03:06 PM. 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