Jump to content

markymark

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

markymark's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yes the code runs in separate php files. For example the Total is 900 and it is generated through the 1st php code via $Total = $Total + $Amount; so the total can Generate freely in the 1st form. By saving it i couldn't get the value of the $Total via saving it into the database. Ah well please look at my codes orderproduct.php <html> <?php $db = mysql_connect("localhost", "root", ""); mysql_select_db("vinnex",$db); $sql = "SELECT * from temptransaction"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $TransNo = $row['TransNo']; $Username = $row['Username'] ; $Firstname = $row['Firstname'] ; $Date = $row['Date'] ; } ?> <!--<meta http-equiv="" content="0;URL=orderproduct.php"/>--> <body background="palered.jpg"> <form action="save.php" method="post" target="BottomRightFrame"> <table border="1" cellspacing="3"cellpadding="5" align="center"> <tr> <th colspan="6"><h2>Order Form</h2></th> </tr> <tr> <td align="Right">TransNo</td> <td><input type="Text" name="TransNo" maxlength = "11" value="<?php echo $TransNo; ?>" readonly></td> <td align="right">Date</td> <td><input type="Text" name="Date" value="<?php echo $Date; ?>" readonly></td> </tr> <tr> <td align="right">Username</td> <td><input type="Text" name="Username" value="<?php echo $Username; ?>" readonly></td> <td align="right">Name</td> <td><input type="Text" name="name" value="<?php echo $Firstname; ?>" readonly></td> </tr> <tr> <td align="center">Trans Details ID</td> <td align="center">Product Code</td> <td align="center">Per Cubic Meter</td> <td align="center">Amount</td> </tr> <tr> <?php $db = mysql_connect("localhost", "root", ""); mysql_select_db("vinnex",$db); $sqlresult = mysql_query("Select * From temptransdetails"); while($myrow = mysql_fetch_array($sqlresult)) { $TransDetailsID = $myrow['TransDetailsID']; $ProductCode = $myrow['ProductCode'] ; $PerCubicMeter = $myrow['PerCubicMeter'] ; $Amount = $myrow['Amount']; ?> <tr align="center"> <td><?php echo $TransDetailsID;?></td> <td><?php echo $ProductCode;?></td> <td><?php echo $PerCubicMeter;?></td> <td><?php echo number_format($Amount,2);?></td> <td valign="center"> <?php echo"<a href=\"OrderEdit.php?orderdetailcodes=",$myrow[orderdetailcode]."\">Edit</a>"; ?> </td> <td valign = "center"> <?php echo"<a href=\"orderdelete.php?orderdetailcodes=",$myrow[orderdetailcode]."\">Delete</a>"; ?> </td> </tr> <?php $Total = $Total + $Amount; } ?> </tr> <tr> <td colspan="3" align="Right">Total</td> <td align ="Center"><?php echo number_format($Total,2);?></td> </tr> <tr> <td colspan="6" align="Center"><input type="Submit" name="submit" value="Save"> <input type="Reset" name="reset" value="Reset"></td> </tr> </form> <tr> <form action="Order&Delivery.php" method="post" target="BottomRightFrame"> <td colspan="6" align="Center"><INPUT TYPE="Submit" name ="Submit" value="Select Product"> </tr> </table> </form> </body> </html> save.php <html> <?php $db = mysql_connect("localhost", "root", ""); mysql_select_db("vinnex",$db); $TransNo = $_POST['TransNo']; $Username = $_POST['Username']; $Date = $_POST['Date']; $Total = $_GET['Total']; echo $Total; $sqltransaction = " INSERT INTO transaction (TransNo, Username, Date, Total) VALUES ('$TransNo', '$Username', '$Date', '$Total')"; $resulttransaction = mysql_query($sqltransaction); $TransDetailsID = $_POST['TransDetailsID']; $TransNo = $_POST['TransNo']; $ProductCode = $_POST['ProductCode']; $PerCubicMeter = $_POST['PerCubicMeter']; $Amount = $_POST['Amount']; $sql1 = "SELECT from temptransdetails where TransDetailsID = '$TransDetailsID'"; $result1 = mysql_query($sql1); while($row1 = mysql_fetch_array($result1)) { $TransDetailsID = $row1['TransDetailsID']; $TransNo = $row1['TransNo']; $ProductCode = $row1['ProductCode']; $PerCubicMeter = $row1['PerCubicMeter']; $Amount = $row1['Amount']; } $sqltransdetails = " INSERT INTO transdetails (TransDetailsID, TransNo, ProductCode, PerCubicMeter, Amount) VALUES ('$TransDetails', '$TransNo', '$ProductCode', '$PerCubicMeter', '$Amount')"; $resulttransdetails = mysql_query($sqltransdetails); ?> <!--<meta http-equiv="refresh" content="1;url=home.html"/>--> </html>
  2. The 1st php code it can generate the total amount but it isn't save in the database therefore i need to get the value of the $total in the 1st php code to the 2nd php code so that i could insert the value into the database. But i couldn't get it's value. =(
  3. This php file cant echo in the 2nd php code, can anyone help me about this? 1st php code to connect into the 2nd php code <?php $Total = $Total + $Amount; } ?> </tr> <tr> <td colspan="3" align="Right">Total</td> <td align ="Center"><?php echo number_format($Total,2);?></td> </tr> 2nd php code <?php $db = mysql_connect("localhost", "root", ""); mysql_select_db("vinnex",$db); $TransNo = $_POST['TransNo']; $Username = $_POST['Username']; $Date = $_POST['Date']; $Total = $_GET['Total']; echo $Total; $sqltransaction = " INSERT INTO transaction (TransNo, Username, Date, Total) VALUES ('$TransNo', '$Username', '$Date', '$Total')"; $resulttransaction = mysql_query($sqltransaction); ?>
  4. 1st the log in code: Code <form method ="post" action="cartnisya.php"> <table border="0"align="right"> <td>Username:</td> <td><input type="Text" name="Username"></td> <td>&nbsp </td> <td>&nbsp </td> <td>Password:</td> <td><input type="Password" name="Password"></td> <td>&nbsp </td> <td colspan="2" align="center"><input type="Submit" name=submit" value="Submit"></td> </table> <img src="Vinnex1.jpg"> </form> it will then go the php code: CODE: <html> <?php $db = mysql_connect("localhost", "root",""); mysql_select_db("vinnex",$db); $Username = $_POST['Username']; echo $Username; $result = mysql_query("Select TransNo From transaction", $db); $myrow = mysql_fetch_array($result); if ($myrow=='') { $TransNo='1000'; $sql = mysql_query("Select * From customer where Username='$Username'", $db); $myrow1 = mysql_fetch_array($sql); $Username = $myrow1['Username']; $Firstname = $myrow1['Firstname']; $Lastname = $myrow1['Lastname']; $name = $Firstname. " ".$Lastname; $Date = date('m/d/y'); $sql1 = "INSERT INTO temptransaction (TransNo, Username, Firstname, Date) VALUES ('$TransNo', '$Username', '$Firstname', '$Date')"; $result = mysql_query($sql1); //or die(mysql_error()); } else { $sql = mysql_query("Select max(TransNo) maxTransNo From transaction", $db); $myrow1 = mysql_fetch_array($sql); $orderno = $myrow1['maxTransNo']+1; $sql = mysql_query("Select * From customer where Username='$Username'", $db); $myrow1 = mysql_fetch_array($sql); $Username = $myrow1['Username']; $Firstname = $myrow1['Firstname']; $Lastname = $myrow1['Lastname']; $name = $Firstname. " ".$Lastname; $Date = date('m/d/y'); $sql1 = " INSERT INTO temptransaction (TransNo, Username, Firstname, Date) VALUES ('$TransNo', '$Username', '$Firstname', '$Date')"; $result = mysql_query($sql1) or die(mysql_error()); } ?> <meta http-equiv="refresh" content="0;url=orderproduct.html"/> </html> once this is open it will go the selected it wont display the matched echo for the text field. once i call the database when using username and password it wont filter and it wont call for a firstname and username to be saved in the database please help
  5. Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\New\cartnisya.php on line 15 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\New\cartnisya.php on line 74 CODE $db = mysql_connect("localhost", "root",""); mysql_select_db("vinnex",$db); mysql_query("Delete From temptransaction",$db); //mysql_query("Delete From temporderdetails",$db); $Username = $_POST['Username']; $Password = $_POST['Password']; $result = mysql_query("Select TransNo From transaction", $db); $myrow = mysql_fetch_array($result); if ($myrow=='') { $TransNo='1000'; $q = mysql_query("Select Username, Lastname, Firstname From customer where Username=$Username, Lastname=$Lastname, Firstname=$Firstname "); $myrow1 = mysql_fetch_array($q); $Username = $myrow1['Username']; $Firstname = $myrow1['Firstname']; $Lastname = $myrow1['Lastname']; $name = $Firstname. " ".$Lastname; $sql1 = " INSERT INTO temptransaction (TransNo, Username, Firstname, Date) VALUES ('$TransNo', '$Username', '$Firstname', '$Date')"; $result = mysql_query($sql1) or die(mysql_error()); } else { $sql = mysql_query("Select max(TransNo) maxTransNo From transaction", $db); $myrow1 = mysql_fetch_array($sql); $orderno = $myrow1['maxTransNo']+1; $sql = mysql_query("Select Username, Lastname, Firstname From customer where Username=$Username, Lastname=$Lastname, Firstname=$Firstname"); $myrow1 = mysql_fetch_array($sql); $Username = $myrow1['Username']; $Firstname = $myrow1['Firstname']; $Lastname = $myrow1['Lastname']; $Date = date('m/d/y'); $sql1 = " INSERT INTO temptransaction (TransNo, Username, Firstname, Date) VALUES ('$TransNo', '$Username', '$Firstname', '$Date')"; $result = mysql_query($sql1) or die(mysql_error()); } please help masters im just newbie in php.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.