I need help on following issue
I create a file which contain three portion
1. Select User
2. Add Payment
3. List of existing payment
1. Select User
In this portion a drop-down list which contain list of user-name which got from a MYsql table add-user which snapshot is in attached file addusertable.jpg.
2. Add payment
In this portion add payment of respective user which select from above said drop-down list. Its value store in addpayment table snapshort is in attached file addpaymenttable.jpg.
3. List of existing payment
In this portion a list of existing payment was adding with respective user.
My problem is i think a logic i will select username from dropdown list which is from on table and it will be copy username with payment values in another table than a list will be shown payment withrespect to user
I have create form for all function userlist, add payment and delete payment is working but username is not copying from adduser to addpayment table and i need this username for logical check in view value to respective user.
following is my php code
<?php
session_start();
//require_once("includes/restrict.php");
require_once("includes/config.php");
//include("includes/variables.php");
$msg="";
?>
<?php
$cname=$_POST['cname'];
$amount=$_POST['amount'];
$adate=$_POST['adate'];
$remarks=$_POST['remarks'];
$logname=$_POST['logname'];
//echo $logname;
if($_POST['cname'] == '' || $_POST['amount'] == '')
{
echo "$logname";
echo "Empty Payment not Allowed";
//header("Location: add_payment.php");
} else {
$sql = "insert into addpayment (logname, cname, amount, adate, remarks) values('".$logname."', '".$cname."', '".$amount."', '".$adate."', '".$remarks."')";
$qry = mysql_query($sql);
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo TITLE;?></title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" id="main">
<tr>
<td height="85" colspan="3" align="left" valign="top" bgcolor="#CCCCCC"><?php include("includes/header.php");?></td>
</tr>
<tr>
<td height="5" colspan="3" bgcolor="#000000"><img width="1" height="1"></td>
</tr>
<tr>
<td width="8" height="8" align="left" valign="top"> </td>
<td height="8"><img width="1" height="1"></td>
<td width="8" align="right" valign="top"> </td>
</tr>
<tr>
<td width="8"><img width="1" height="1"></td>
<td width="100%" align="left" valign="top"><table width="100%" height="100%"border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="300" valign="top"><?php include("categories_menu.php");?></td>
<td align="left" valign="top">
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="5" class="heading"></td>
<td class="heading2"><table width="750" border="0" cellspacing="0">
<tr>
<td width="100" class=heading2>Payments</td>
<td>
<?php require_once("includes/pay_summary.php");?>
</td>
</tr>
</table></td>
<td width="3"> </td>
</tr>
</table>
<table width="600" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="4" height="3"><img width="4" height="4"></td>
<td background="images/usr_bg.jpg"><img src="images/x.gif" width="1" height="1"></td>
<td width="4" height="3"><img src="images/corn_2_top.jpg" width="4" height="4"></td>
</tr>
<tr>
<td width="3" valign="top"> </td>
<td valign="top" style="background-repeat:repeat-x; padding-top:10px;">
<table width="713" border="1" cellspacing="0" bordercolor="#666666">
<tr>
<td width="707" height="125" valign="top"><table width="713" border="1" cellspacing="0" bordercolor="#666666">
<tr>
<td width="707" height="125" valign="top"><table class="container" width="650" border="0" cellspacing="0">
<tr>
<td>
<table width="700" border="1" cellspacing="0">
<form name="userlist" method="post" action="">
<tr>
<td width="150" bgcolor="#666666"><div align="center">Marketing Executive</div></td>
<td width="150"><div align="center">
<select name="logname" id="logname" >
<option value="" selected="selected">Select a User</option>
<?php
$user = "SELECT logname from adduser" ;
$resultuser= mysql_query($user);
?>
<?php while ($row = mysql_fetch_array($resultuser)){?>
<option selected><?php echo $row['logname']; ?> </option>
<?php }?>
</select>
</div></td>
<td width="75" bgcolor="#666666"><div align="center"></div></td>
<td width="150"align="right" > </td>
<td width="75" bgcolor="#666666"><div align="center"></div></td>
<td width="100"> </td>
</tr>
</form>
</table></td>
</tr>
<tr>
<td>
<table width="700" border="1" cellspacing="1" bordercolor="#666666">
<form name="addpayment" method="post" action="">
<tr bgcolor="#666666">
<td><div align="center">S.No</div></td>
<td><div align="center">Customer Name</div></td>
<td><div align="center">Amount</div></td>
<td>Date</td>
<td><p align="center">Remarks</p></td>
</tr>
<tr>
<td width="40" height="28"> </td>
<td width="424"><input type="text" name="cname"> </td>
<td width="61"><input type="integer" name="amount" size="6"></td>
<td width="66"><input type="date" name="adate" size="9"></td>
<td width="88"><input type="text" name="remarks" size="6"></td>
</tr>
<tr>
<td colspan="5"><div align="center">
<input type="submit" name="Submit" value="Add Payment" id="submit" >
</div></td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
<tr>
<td>
<table width="700" border="0" cellspacing="0">
<tr>
<td><table width="703" border="1" cellspacing="1" bordercolor="#666666">
<form name="dateentry" action="" method="post" enctype="multipart/form-data">
<tr bgcolor="#666666">
<td> </td>
<td><table width="261" border="0" cellspacing="0">
<tr>
<td width="30">From</td>
<td><input type="text" name="fromdate" size="5"></td>
<td width="35">To</td>
<td><input type="text" name="todate" size="5"></td>
</tr>
</table></td>
<td>All</td>
<td> </td>
<td> </td>
<td><table width="106" border="0" cellspacing="0">
<tr>
<td width="49">Quater</td>
<td width="82"> </td>
</tr>
</table></td>
</tr>
<tr bgcolor="#666666">
<td width="5"><div align="center">S.No</div></td>
<td><div align="center">Customer Name</div></td>
<td><div align="center">Amount</div></td>
<td><div align="center">Date</div></td>
<td><p align="center">Remarks</p></td>
<td><div align="center">Action</div></td>
</tr>
<tr >
<?php
if($_GET['action']=="delete"){
$cname=$_GET['cname'];
$qryChk="select * from addpayment where cname='$cname' limit 1";
$rsChk=mysql_query($qryChk);
//$rowChk=mysql_fetch_array($rsChk);
//if($rowChk['service_img']!=""){
//@unlink('../services/'.$rowChk['service_img']);
//}
$qryDel="delete from addpayment where cname='$cname'";
if(mysql_query($qryDel)){ $msg='<span class="msg_ok">Record has been deleted.</span>';}else{ $msg='<span class="msg_error">There is some error in deleting record. Please try again!</span>';}
}
?>
<?php
$resultentry = ("SELECT * from addpayment ");
$resultdata= mysql_query($resultentry);
?>
<?php
$i=0;
while($rowData=mysql_fetch_array($resultdata)){
$i++;
?>
<td width="5"> <div align="center"><font color="#FF0000"><strong>
<?php echo $i ?>
</strong> </font></div></td>
<td width="350">
<?php echo $rowData['cname']; ?>
</td>
<td width="50">
<?php echo $rowData['amount']; ?>
</td>
<td width="75">
<?php echo $rowData['adate']; ?>
</td>
<td width="100">
<?php echo $rowData['remarks']; ?>
</td>
<td align="center"><a href="<?php echo 'edit_news.php?cname='.$rowData['cname'];?>">Edit</a>
| <a href="<?php echo $_SERVER['PHP_SELF'].'?cname='.$rowData['cname'].'&action=delete';?>" onclick="return confirm('Are you sure you want to delete this record');">Delete</a></td>
</tr>
</form>
<?php }?>
<tr>
<td colspan="3"> </td>
<td>Total</td>
<td> </td>
<td colspan="3"> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td width="3" valign="top" background="images/usr_rit_bg.jpg"> </td>
</tr>
<tr>
<td width="4" height="3"><img src="images/corn_3.jpg" width="4" height="3"></td>
<td background="images/usr_btm_bg.jpg"><img src="images/x.gif" width="1" height="1"></td>
<td width="4" height="3"><img src="images/corn_4.jpg" width="4" height="3"></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="8"><img src="images/x.gif" width="1" height="1"></td>
</tr>
<tr>
<td width="8" height="8" align="left" valign="bottom"><img src="images/x.gif" width="1" height="1"></td>
<td height="8"><img src="images/x.gif" width="1" height="1"></td>
<td width="8" height="8" align="right"> </td>
</tr>
<tr>
<td height="5" colspan="3" bgcolor="#000000"><img src="images/x.gif" width="1" height="1"></td>
</tr>
<tr>
<td height="25" colspan="3" bgcolor="#000000"><?php include("includes/footer.php");?></td>
</tr>
</table>
</body>
</html>
Copy data from one table to anothe table through PHP
Moderator: General Moderators
-
mudassar.rafiq
- Forum Newbie
- Posts: 1
- Joined: Tue Oct 12, 2010 1:34 am
Copy data from one table to anothe table through PHP
- Attachments
-
- addpaymenttable.JPG (97.42 KiB) Viewed 519 times
-
- addusertable.JPG (101.39 KiB) Viewed 519 times