saya ade senarai data dlm satu table,saya nak move kan salah satu data ke dalam lg satu table.
contoh:
table waiting list yg tunggu utk di approve kan.bila saya click approve, data yg di approved tu akan masuk ke dlm table lain.so data dlm table yg pertama td dah takde.
please tolong saya..saya dh dapat cari coding die.tp tak tau pulak mane nak letak coding tu.
if($_GET['a'] == 'process' && $_POST['approve']){
$idlist = $_POST['approve'];
if($_POST['approve_sub']){
$action = 'approve';
}elseif($_POST['reject']){
$action = 'reject';
}
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>?a=<?php echo $action; ?>" method="post">
<center>
You are about to <?php echo $action; ?> the following applications:<br />
<table border="5" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#808080" width="90%" id="AutoNumber2" bgcolor="#C0C0C0">
<tr>
<td width=17.7% align=center bgcolor="#FFFFCC"><b>Name</b></td>
<td width=14.8% align=center bgcolor="#FFFFCC"><b>Country</b></td>
<td width=8.1% align=center bgcolor="#FFFFCC"><b>Location</b></td>
</tr>
<?php
foreach( $idlist as $key => $value){
$row = mysql_fetch_array(mysql_query("SELECT * FROM `apps` WHERE `id`='" . $value . "'")) or die(mysql_error());
echo " <tr>";
echo " <td align=center><input type=\"hidden\" value=\"" . $row['id'] . "\" name=\"approve[]\" />" . $row['alias'] . "</td>";
echo " <td align=center>" . $row['Name'] . "</td>";
echo " <td align=center>" . $row['Country'] . "</td>";
echo " <td align=center>" . $row['Location'] . "</td>";
echo " </tr>";
}
?>
<tr>
<td align=center bgcolor="#FFFFCC" colspan='5'><input type="submit" value="Confirm" name="confirm" /> <input type="submit" value="Cancel" name="cancel" /></td>
</tr>
</table>
</center>
</form>
<?php
}elseif($_GET['a'] == 'approve' && $_POST['approve']){
$idlist = $_POST['approve'];
if($_POST['cancel']){
$cancel = 'true';
}elseif($_POST['confirm']){
foreach( $idlist as $key => $value){
$copy = mysql_fetch_array(mysql_query("SELECT * FROM `apps` WHERE `id`='" . $value . "'")) or die(mysql_error());
// ^^ SELECT THE DATA TO BE COPIED ^^
@mysql_query("INSERT INTO `approved` (`Name`, `Country`, `Location`) VALUES('" . $copy['Name'] . "', '" . $copy['Country'] . "', '" . $copy['Location'] . "')") or die(mysql_error());
// ^^ COPY THE DATA ^^
//CHANGE 'approved' INTO THE NAME OF THE TABLE CONTAINING THE APPROVED APPLICATIONS
//ADD ANY OTHER FIELDS THAT ARE NECESSARY TO THE LISTS
@mysql_query("DELETE FROM `apps` WHERE `id`='" . $value . "'") or die(mysql_error());
// ^^ DELETE THE OLD DATA ^^
}
echo "Applications successfully approved.";
}
}elseif($_GET['a'] == 'reject' && $_POST['approve']){
$idlist = $_POST['approve'];
if($_POST['cancel']){
$cancel = 'true';
}elseif($_POST['confirm']){
foreach( $idlist as $key => $value){
@mysql_query("DELETE FROM `apps` WHERE `id`='" . $value . "'") or die(mysql_error());
// ^^ DELETE THE REJECTED APPLICATION DATA ^^
}
echo "Applications successfully rejected.";
}
}
if(!$_GET['a'] || $cancel || !$_POST['approve']){
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>?a=process" method="post">
<center>
<table border="5" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#808080" width="90%" id="AutoNumber2" bgcolor="#C0C0C0">
<tr>
<td align=center bgcolor="#FFFFCC"></td>
<td width=17.7% align=center bgcolor="#FFFFCC"><b>Name</b></td>
<td width=14.8% align=center bgcolor="#FFFFCC"><b>Country</b></td>
<td width=8.1% align=center bgcolor="#FFFFCC"><b>Location</b></td>
</tr>
<?php
$result = mysql_query("SELECT * FROM `apps`") or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo " <tr>";
echo " <td align=center><input type=\"checkbox\" value=\"" . $row['id'] . "\" name=\"approve[]\" /></td>";
echo " <td align=center>" . $row['Name'] . "</td>";
echo " <td align=center>" . $row['Country'] . "</td>";
echo " <td align=center>" . $row['Location'] . "</td>";
echo " </tr>";
}
?>
<tr>
<td align=center bgcolor="#FFFFCC" colspan='6'><input type="submit" value="Approve" name="approve_sub" /> <input type="submit" value="Reject" name="reject" /></td>
</tr>
</table>
</center>
</form>
<?php
}
contoh:
table waiting list yg tunggu utk di approve kan.bila saya click approve, data yg di approved tu akan masuk ke dlm table lain.so data dlm table yg pertama td dah takde.
please tolong saya..saya dh dapat cari coding die.tp tak tau pulak mane nak letak coding tu.
if($_GET['a'] == 'process' && $_POST['approve']){
$idlist = $_POST['approve'];
if($_POST['approve_sub']){
$action = 'approve';
}elseif($_POST['reject']){
$action = 'reject';
}
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>?a=<?php echo $action; ?>" method="post">
<center>
You are about to <?php echo $action; ?> the following applications:<br />
<table border="5" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#808080" width="90%" id="AutoNumber2" bgcolor="#C0C0C0">
<tr>
<td width=17.7% align=center bgcolor="#FFFFCC"><b>Name</b></td>
<td width=14.8% align=center bgcolor="#FFFFCC"><b>Country</b></td>
<td width=8.1% align=center bgcolor="#FFFFCC"><b>Location</b></td>
</tr>
<?php
foreach( $idlist as $key => $value){
$row = mysql_fetch_array(mysql_query("SELECT * FROM `apps` WHERE `id`='" . $value . "'")) or die(mysql_error());
echo " <tr>";
echo " <td align=center><input type=\"hidden\" value=\"" . $row['id'] . "\" name=\"approve[]\" />" . $row['alias'] . "</td>";
echo " <td align=center>" . $row['Name'] . "</td>";
echo " <td align=center>" . $row['Country'] . "</td>";
echo " <td align=center>" . $row['Location'] . "</td>";
echo " </tr>";
}
?>
<tr>
<td align=center bgcolor="#FFFFCC" colspan='5'><input type="submit" value="Confirm" name="confirm" /> <input type="submit" value="Cancel" name="cancel" /></td>
</tr>
</table>
</center>
</form>
<?php
}elseif($_GET['a'] == 'approve' && $_POST['approve']){
$idlist = $_POST['approve'];
if($_POST['cancel']){
$cancel = 'true';
}elseif($_POST['confirm']){
foreach( $idlist as $key => $value){
$copy = mysql_fetch_array(mysql_query("SELECT * FROM `apps` WHERE `id`='" . $value . "'")) or die(mysql_error());
// ^^ SELECT THE DATA TO BE COPIED ^^
@mysql_query("INSERT INTO `approved` (`Name`, `Country`, `Location`) VALUES('" . $copy['Name'] . "', '" . $copy['Country'] . "', '" . $copy['Location'] . "')") or die(mysql_error());
// ^^ COPY THE DATA ^^
//CHANGE 'approved' INTO THE NAME OF THE TABLE CONTAINING THE APPROVED APPLICATIONS
//ADD ANY OTHER FIELDS THAT ARE NECESSARY TO THE LISTS
@mysql_query("DELETE FROM `apps` WHERE `id`='" . $value . "'") or die(mysql_error());
// ^^ DELETE THE OLD DATA ^^
}
echo "Applications successfully approved.";
}
}elseif($_GET['a'] == 'reject' && $_POST['approve']){
$idlist = $_POST['approve'];
if($_POST['cancel']){
$cancel = 'true';
}elseif($_POST['confirm']){
foreach( $idlist as $key => $value){
@mysql_query("DELETE FROM `apps` WHERE `id`='" . $value . "'") or die(mysql_error());
// ^^ DELETE THE REJECTED APPLICATION DATA ^^
}
echo "Applications successfully rejected.";
}
}
if(!$_GET['a'] || $cancel || !$_POST['approve']){
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>?a=process" method="post">
<center>
<table border="5" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#808080" width="90%" id="AutoNumber2" bgcolor="#C0C0C0">
<tr>
<td align=center bgcolor="#FFFFCC"></td>
<td width=17.7% align=center bgcolor="#FFFFCC"><b>Name</b></td>
<td width=14.8% align=center bgcolor="#FFFFCC"><b>Country</b></td>
<td width=8.1% align=center bgcolor="#FFFFCC"><b>Location</b></td>
</tr>
<?php
$result = mysql_query("SELECT * FROM `apps`") or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo " <tr>";
echo " <td align=center><input type=\"checkbox\" value=\"" . $row['id'] . "\" name=\"approve[]\" /></td>";
echo " <td align=center>" . $row['Name'] . "</td>";
echo " <td align=center>" . $row['Country'] . "</td>";
echo " <td align=center>" . $row['Location'] . "</td>";
echo " </tr>";
}
?>
<tr>
<td align=center bgcolor="#FFFFCC" colspan='6'><input type="submit" value="Approve" name="approve_sub" /> <input type="submit" value="Reject" name="reject" /></td>
</tr>
</table>
</center>
</form>
<?php
}