Jump to content
nuar07

Tolong!

Recommended Posts

ak dh wat coding tuk delete tp guna lam php4 tp bila ak run lam php5 dia xjalan..nie ak bg coding tuk korang tolong tgk, kalo ade masalah bg tau r..

// Check if delete button active, start this

if($delete){

for($i=0;$i<$count;$i++){

$del_id = $checkbox[$i];

$sql = "DELETE FROM $tbl_name WHERE id_lokasi='$del_id'";

$result = mysql_query($sql);

}

// if successful redirect to feedback/FeedBackDeleteLokasi.php

if($result){

echo "<meta http-equiv=\"refresh\" content=\"0;URL=feedback/FeedBackDeleteLokasi.php\">";

}

}

mysql_close();

?>

</table>

</body>

</html>

<?php

mysql_free_result($Recordset1);

?>

ak suspek part delete nie je problem...database blueh retrive, bila nk delete x jln. kalo run kat pc laen blueh guna apache php4 tp run kat computer ak guna wamp php 5 xjln pelik...harap dpt bantu :(

Edited by nuar07

Share this post


Link to post
Share on other sites

$submit==$HTTP_POST_VARS["submit"];
if($submit=="Delete")

  {
	if(isset($HTTP_POST_VARS["id"]))
	{ // create the query

	  $id=$HTTP_POST_VARS["id"];
	  $sql="SELECT * FROM  tbl_name WHERE id='$id'";

	// execute query
	$result=mysql_query($sql) or die("SQL select statement failed");

if($submit=="confirm??")
{  $id=$HTTP_POST_VARS["id"];


     $sql = "DELETE FROM tbl_name WHERE id='$id'";
     $result = mysql_query($sql);

     echo "<hr><H3>RECORD DELETED</H3><hr><br>"; 



}

Kite pun xtau sgt..

tp awk try la goreng2 coding tu.

ada satu cr lg..

tp tgh bingung2 ni x leh nk ingt ar.. :wacko:

Edited by GeeIra

Share this post


Link to post
Share on other sites

code yg ko bg tidak penuh

btw aku rasa masalah register global

Register Global(register_globals) adalah salah satu konfigurasi yg terdapat dlm php. Konfigurasi register_globals merupakan ciri di dalam PHP di mana kesemua pembolehubah global boleh dicapai secara automatik sekiranya register_globals di pasang (on). Namun pencapaian pembolehubah secara global boleh menyebabkan risiko keselamatan. Konfigurasi register_globals boleh diubah di dalam fail php.ini. PHP 4.2.0 dan keatas secara defaultnya menutup register_globals untuk tujuan keselamatan.

http://www.ejoe.net/forum/tutorial_view.ph...e=php&id=76

Share this post


Link to post
Share on other sites

$submit==$HTTP_POST_VARS["submit"];
if($submit=="Delete")

  {
	if(isset($HTTP_POST_VARS["id"]))
	{ // create the query

	  $id=$HTTP_POST_VARS["id"];
	  $sql="SELECT * FROM  tbl_name WHERE id='$id'";

	// execute query
	$result=mysql_query($sql) or die("SQL select statement failed");

if($submit=="confirm??")
{  $id=$HTTP_POST_VARS["id"];


     $sql = "DELETE FROM tbl_name WHERE id='$id'";
     $result = mysql_query($sql);

     echo "<hr><H3>RECORD DELETED</H3><hr><br>"; 



}

Kite pun xtau sgt.. tp awk try la goreng2 coding tu. ada satu cr lg.. tp tgh bingung2 ni x leh nk ingt ar.. :wacko:
memandangkan skrg dah php5 kena tukar sikit
$submit=$_POST["submit"];
if($submit=="Delete")

  {
	if(isset($_POST["id"]))
	{ // create the query

	  $id=$_POST["id"];
	  $sql="SELECT * FROM  tbl_name WHERE id='$id'";

	// execute query
	$result=mysql_query($sql) or die("SQL select statement failed");

if($submit=="confirm??")
{  $id=$_POST["id"];


     $sql = "DELETE FROM tbl_name WHERE id='$id'";
     $result = mysql_query($sql);

     echo "<hr><H3>RECORD DELETED</H3><hr><br>"; 



}

sekian wasalam

Share this post


Link to post
Share on other sites

$id=$_POST["id"];

mungking juga dia guna method GET

kalo GET

$id=$_GET["id];

or bleh guna

$id=$_REQUEST["id"];
kalo untuk 2-2 GET & POST

Share this post


Link to post
Share on other sites

anyway thanks for helping me..

ni full codingnye

<?php
#	BuildNav for Dreamweaver MX v0.2
#              10-02-2002
#	Alessandro Crugnola [TMM]
#	sephiroth: [email protected]
#	http://www.sephiroth.it
#	
#	Function for navigation build ::
function buildNavigation($pageNum_Recordset1,$totalPages_Recordset1,$prev_Recordset1,$next_Recordset1,$separator=" | ",$max_links=10, $show_page=true)
{
                GLOBAL $maxRows_Recordset1,$totalRows_Recordset1;
	$pagesArray = ""; $firstArray = ""; $lastArray = "";
	if($max_links<2)$max_links=2;
	if($pageNum_Recordset1<=$totalPages_Recordset1 && $pageNum_Recordset1>=0)
	{
		if ($pageNum_Recordset1 > ceil($max_links/2))
		{
			$fgp = $pageNum_Recordset1 - ceil($max_links/2) > 0 ? $pageNum_Recordset1 - ceil($max_links/2) : 1;
			$egp = $pageNum_Recordset1 + ceil($max_links/2);
			if ($egp >= $totalPages_Recordset1)
			{
				$egp = $totalPages_Recordset1+1;
				$fgp = $totalPages_Recordset1 - ($max_links-1) > 0 ? $totalPages_Recordset1  - ($max_links-1) : 1;
			}
		}
		else {
			$fgp = 0;
			$egp = $totalPages_Recordset1 >= $max_links ? $max_links : $totalPages_Recordset1+1;
		}
		if($totalPages_Recordset1 >= 1) {
			#	------------------------
			#	Searching for $_GET vars
			#	------------------------
			$_get_vars = '';			
			if(!empty($_GET) || !empty($HTTP_GET_VARS)){
				$_GET = empty($_GET) ? $HTTP_GET_VARS : $_GET;
				foreach ($_GET as $_get_name => $_get_value) {
					if ($_get_name != "pageNum_Recordset1") {
						$_get_vars .= "&$_get_name=$_get_value";
					}
				}
			}
			$successivo = $pageNum_Recordset1+1;
			$precedente = $pageNum_Recordset1-1;
			$firstArray = ($pageNum_Recordset1 > 0) ? "<a href=\"$_SERVER[PHP_SELF]?pageNum_Recordset1=$precedente$_get_vars\">$prev_Recordset1</a>" :  "$prev_Recordset1";
			# ----------------------
			# page numbers
			# ----------------------
			for($a = $fgp+1; $a <= $egp; $a++){
				$theNext = $a-1;
				if($show_page)
				{
					$textLink = $a;
				} else {
					$min_l = (($a-1)*$maxRows_Recordset1) + 1;
					$max_l = ($a*$maxRows_Recordset1 >= $totalRows_Recordset1) ? $totalRows_Recordset1 : ($a*$maxRows_Recordset1);
					$textLink = "$min_l - $max_l";
				}
				$_ss_k = floor($theNext/26);
				if ($theNext != $pageNum_Recordset1)
				{
					$pagesArray .= "<a href=\"$_SERVER[PHP_SELF]?pageNum_Recordset1=$theNext$_get_vars\">";
					$pagesArray .= "$textLink</a>" . ($theNext < $egp-1 ? $separator : "");
				} else {
					$pagesArray .= "$textLink"  . ($theNext < $egp-1 ? $separator : "");
				}
			}
			$theNext = $pageNum_Recordset1+1;
			$offset_end = $totalPages_Recordset1;
			$lastArray = ($pageNum_Recordset1 < $totalPages_Recordset1) ? "<a href=\"$_SERVER[PHP_SELF]?pageNum_Recordset1=$successivo$_get_vars\">$next_Recordset1</a>" : "$next_Recordset1";
		}
	}
	return array($firstArray,$pagesArray,$lastArray);
}
?>
<?php require_once('../Connections/db.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
  $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO lokasi (nama_lokasi) VALUES (%s)",
                       GetSQLValueString($HTTP_POST_VARS['nama_lokasi'], "text"));

  mysql_select_db($database_db, $db);
  $Result1 = mysql_query($insertSQL, $db) or die(mysql_error());

  $insertGoTo = "lokasi baru.php";
  if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

$maxRows_Recordset1 = 20;
$pageNum_Recordset1 = 0;
if (isset($HTTP_GET_VARS['pageNum_Recordset1'])) {
  $pageNum_Recordset1 = $HTTP_GET_VARS['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_db, $db);
$query_Recordset1 = "SELECT * FROM lokasi";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $db) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($HTTP_GET_VARS['totalRows_Recordset1'])) {
  $totalRows_Recordset1 = $HTTP_GET_VARS['totalRows_Recordset1'];
} else {
  $all_Recordset1 = mysql_query($query_Recordset1);
  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<html>
<head>
<title>Daftar Lokasi</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel=stylesheet type="text/css" href="image/style.css">
</HEAD>
<script language="JavaScript" type="text/JavaScript">
<!--
function tmt_confirm(msg){
	document.MM_returnValue=(confirm(unescape(msg)));
}
//-->
</script>
</head>

<body background="image/logo.gif">
<table width="100%" border="0">
  <tr> 
    <td width="20%">&nbsp;</td>
    <td width="52%"><table width="100%" border="0">
        <tr> 
          <td>&nbsp;</td>
        </tr>
        <tr> 
          <td><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="adminpage.php">&lt;&lt;Kembali</a></strong></font></td>
        </tr>
        <tr> 
          <td><p><font size="2" face="Arial, Helvetica, sans-serif"></font></p></td>
        </tr>
        <tr> 
          <td><form action="<?php echo $editFormAction; ?>" name="form1" method="POST">
              <p><strong><font size="2" face="Geneva, Arial, Helvetica, sans-serif">Lokasi 
                baru :</font> 
                <input name="nama_lokasi" type="text" id="nama_lokasi3">
                <input type="submit" name="Submit" value="Submit">
                <font size="2"> </font></strong><a href="Senarai%20lokasi.php"><font size="2" face="Arial, Helvetica, sans-serif"> 
                </font></a></p>
              <input type="hidden" name="MM_insert" value="form1">
            </form></td>
        </tr>
        <tr> 
          <td height="21">&nbsp;</td>
        </tr>
      </table></td>
    <td width="28%" valign="top">&nbsp;</td>
  </tr>
  <tr> 
    <td height="154">&nbsp;</td>
    <td><form name="frm1"   method="POST" onSubmit="return ValidateForm()">
	<?php
$host="localhost"; // Host name 
$username="root"; // Mysql username 
$password=""; // Mysql password 
$db_name="onlinee-aduan"; // Database name 
$tbl_name="lokasi"; // Table name 

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);

$count=mysql_num_rows($result);

?>
        <table width="100%" >
          <tr> 
            <td width="12%" bgcolor="#CC99FF" ><div align="center"><font color="#000000" size="2" face="Arial, Helvetica, sans-serif"><strong>Select</strong></font></div></td>
            <td width="88%" bgcolor="#CC99FF" ><div align="center"><strong><font size="2" face="Arial, Helvetica, sans-serif">SENARAI 
                LOKASI</font></strong></div></td>
          </tr>
          <?php do { ?>
          <tr> 
            <td  bgcolor="#9999CC"><div align="center"><font size="2" face="Geneva, Arial, Helvetica, sans-serif"> 
                <input name="checkbox[]" type="checkbox" id="checkbox[]2" value="<?php echo $row_Recordset1['id_lokasi']; ?>">
                </font></div></td>
            <td  bgcolor="#9999CC"> <div align="left"><font size="2" face="Geneva, Arial, Helvetica, sans-serif"><?php echo $row_Recordset1['nama_lokasi']; ?></font></div></td>
          </tr>
          <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
          <tr> 
            <td>&nbsp;</td>
            <td> <div align="left"></div></td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td><div align="center"> 
                <?php 
# variable declaration
$prev_Recordset1 = "« previous";
$next_Recordset1 = "next »";
$separator = " | ";
$max_links = 4;
$pages_navigation_Recordset1 = buildNavigation($pageNum_Recordset1,$totalPages_Recordset1,$prev_Recordset1,$next_Recordset1,$separator,$max_links,true); 

print $pages_navigation_Recordset1[0]; 
?>
                <?php print $pages_navigation_Recordset1[1]; ?> <?php print $pages_navigation_Recordset1[2]; ?> 
              </div></td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td><div align="center"><font color="#000000"> 
                <input name="delete" type="submit" id="delete" onClick="tmt_confirm('HAPUSKAN%20DATA');return document.MM_returnValue" value="Padam">
                <input type="reset" name="Reset" value="Kosongkan">
                </font> </div></td>
          </tr>
        </table>
      </form></td>
    <td valign="top">&nbsp;</td>
  </tr>
  <tr> 
    <td colspan="3">&nbsp; </td>
  </tr>
      <?
// Check if delete button active, start this 
if($delete){
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM $tbl_name WHERE id_lokasi='$del_id'";
$result = mysql_query($sql);
}

// if successful redirect to feedback/FeedBackDeleteLokasi.php.php
if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=feedback/FeedBackDeleteLokasi.php\">";
}
}
mysql_close();
?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
[/code]

ak dah try gune post method tp tak berhasil gak

tak tau r nak wat cmne lg

ak suspect pon de prob kt register global

tp ak pon tak tau nak tgk cmne..

thanks

laaa.. ingatkan saper tadi kena rogol

sape yg kne rogol?? :blink:

get n post ad different ke??

yg ak tau post lbey secure n unlimited data

Share this post


Link to post
Share on other sites

aku dah mula confius ngan checkbox ko tu

ni delete semua data or delete 1-1?

btw kalo taknak ubah coding bleh gak ubah php.ini

klik icon wamserver > php > php.ini

cari register_globals = Off tukarkan kepada register_globals = On

Share this post


Link to post
Share on other sites

aku dah mula confius ngan checkbox ko tu

ni delete semua data or delete 1-1?

btw kalo taknak ubah coding bleh gak ubah php.ini

klik icon wamserver > php > php.ini

cari register_globals = Off tukarkan kepada register_globals = On

ak nk delete 1-1 data,ak dh on kn php.ini kat wamp5 tetap xblueh gak tukar bnde tu ade affect ke..time kasih eh ko nk tgk system nie ke..sbnrnye ak pn altersystem org laen gak nie..dulu dia pakai apache version2 gan php 4...pas 2 transfer msuk wamp5

register global leh di "off"kan dengan menggunakan php flag pada .htaccess... :lol:

php_flag register_globals off
atau
php_flag register_globals off
Order allow,deny
Allow from all

php_flag register_globals tu kat mana lam wamps ke

Share this post


Link to post
Share on other sites

Hello nak mencelah sikit mcm mana nak delete 2 table secara serentak

1. table transaksi_baucar (id[amik id dari transaksi_baucarxlo],no_baucar)

2.table transaksi_baucarxlo (id,id_xlo,kod_syarikat,no_akaun,amaun)

ni contoh coding aku delete dari satu table

<?

session_start();

include 'dbase.inc.php';

include 'config.inc.php';

$userid = $_REQUEST["uid"];

$queDel = "DELETE FROM transaksi_baucarxlo WHERE id = '$userid'";

$resDel = mysql_db_query(_DBDB, $queDel);

if($resDel == 1) {

errTrap("Transaksi baucar telah dibuang");

echo "<meta http-equiv=\"refresh\" content=\"0;URL=menu.php?t=3&opt=senaraibaucartanpalo\">";

}

?>

Edited by edzal79

Share this post


Link to post
Share on other sites

Hello nak mencelah sikit mcm mana nak delete 2 table secara serentak

1. table transaksi_baucar (id[amik id dari transaksi_baucarxlo],no_baucar)

2.table transaksi_baucarxlo (id,id_xlo,kod_syarikat,no_akaun,amaun)

ni contoh coding aku delete dari satu table

<?

session_start();

include 'dbase.inc.php';

include 'config.inc.php';

$userid = $_REQUEST["uid"];

$queDel = "DELETE FROM transaksi_baucarxlo WHERE id = '$userid'";

$resDel = mysql_db_query(_DBDB, $queDel);

if($resDel == 1) {

errTrap("Transaksi baucar telah dibuang");

echo "<meta http-equiv=\"refresh\" content=\"0;URL=menu.php?t=3&opt=senaraibaucartanpalo\">";

}

?>

tambah je code delete satu lagi :)

Share this post


Link to post
Share on other sites

mcm ni ker? tapi ada error lah -> Parse error: syntax error, unexpected T_BOOLEAN_OR

<?
session_start();
include 'dbase.inc.php';
include 'config.inc.php';

$userid = $_REQUEST["uid"];

$queDel2 = "DELETE FROM transaksi_baucar WHERE id = '$userid'";
$resDel2 = mysql_db_query(_DBDB, $queDel2);

$queDel = "DELETE FROM transaksi_baucarxlo WHERE id = '$userid'";
$resDel = mysql_db_query(_DBDB, $queDel);

if($resDel == 1)||($resDel2 == 1))  {
    errTrap("Transaksi baucar telah dibuang");
    echo "<meta http-equiv=\"refresh\" content=\"0;URL=menu.php?t=3&opt=senaraibaucartanpalo\">";
}

?>

Edited by edzal79

Share this post


Link to post
Share on other sites

line ni problem

if($resDel == 1)||($resDel2 == 1)) {

sepatutnya

if(($resDel == 1)||($resDel2 == 1)) {

tp aku rasa better camni

if ( (!$resDel) || (!$resDel2))

{ echo "tak dpt delete"; }

else

{ echo "berjaya delete"; }

sebab salah satu atau semua takleh delete akan keluar error

Edited by ejoe

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...