Jump to content

ckdoublenecks

Members
  • Posts

    36
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ckdoublenecks's Achievements

Member

Member (2/5)

0

Reputation

  1. this may be a problem? below is the code for "getinvno.php - the code is used in other programs but I added the rate to it . I use the code echo "tax rate: $rate</b><br />"; to display the # <?php mysql_connect('localhost','root',""); mysql_select_db('numbersdb') or die( "Unable to select database"); if(!empty($_POST["submit"])) { $invno = $_POST['invno']; [b]$rate = $_POST['rate'];[/b] } mysql_query("UPDATE numbdata SET invno=invno+1"); $result=mysql_query("select invno, rate from numbdata") or die ("Error - could not retrieve invoice# from database"); $data=mysql_fetch_assoc($result); mysql_close(); ?>
  2. I used the code as you suggested but now I get no values from either table. Below is my code: <?php include("getinvno.php"); $rate = $row['rate']; mysql_connect("localhost", "root", ""); mysql_select_db(posdb) or die("Unable to select database"); $query = "SELECT * FROM saledata AS t1 INNER JOIN postable AS t2 WHERE t1.itemno = t2.itemno AND t2.itemno = '{$itemno}'"; $result=mysql_query($query); $num=mysql_numrows($result); echo "<center><font size=+2><b> Kirk Pawn, Gun & Archery</font><br />"; echo "9921 Old Bearskin Rd<br />"; echo "Hunters Den, Alabama 32145<br /></center>"; echo "customer# ".$data['invno']; echo ".. </b><br />"; echo "tax rate ".$data['rate']; echo ".. </b><br />"; echo "<table cellspacing=1 cellpadding=1 border=0> <tr> <th>Qty</th> <th></th> <th></th> <th>Unit</th> <th>Amt</th> <tr> <th>Sold</th> <th>item#</th> <th>item</th> <th>Price</th> <th>Due</th> <tr> <TH colspan=5>---------------------------------------------------------------------------------------------</TH> </tr>"; while($row = mysql_fetch_array($result)) { $tax = $sellprice * $rate; $taxtotal = $taxtotal + $tax; $amtdue = $sellprice * $sellqty; $amtdue = $amtdue + $tax; $total = $total + $amtdue; $onhand - $onhand - $sellqty; echo "<tr>"; echo "<td>" . $row['sellqty'] . "</td>"; echo "<td>" . $row['itemno'] . "</td>"; echo "<td>" . $row['itemdescr'] . "</td>"; echo "<td align=right>" . $row['sellprice'] . "</td>"; echo "<td align=right>" . $row['amtdue'] . "</td>"; } echo "<tr>"; echo "<TH colspan=5>========================================================</TH>"; echo "<tr>"; echo "<td>Tax</td>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td align=right>" . sprintf("%.2f",$taxtotal) . "</td>"; echo "<tr>"; echo "<TH colspan=5>========================================================</TH>"; echo "<tr>"; echo "<td>Total</td>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td align=right>" . sprintf("%.2f",$total) . "</td>"; echo "</tr>"; echo "</table>"; $sql = "UPDATE postable SET onhand = '" . mysql_real_escape_string($onhand) . "' WHERE itemno='".$_POST["itemno"]."'"; mysql_query($sql) or die("Update query failed."); echo "<b>We thank you for your business</b><br />"; ?>
  3. I'm trying to create a printout using data from two database tables( saledata & postable)(when itemno matches) and update one field(onhand) in one of the databases(postable). I'm sure there's a simple way to do this but I haven't determined how, yet? below is my current effort: <?php include("getinvno.php"); $rate = $row['rate']; mysql_connect("localhost", "root", ""); mysql_select_db(posdb) or die("Unable to select database"); $query = "SELECT * FROM saledata "; $result=mysql_query($query); $num=mysql_numrows($result); while($row = mysql_fetch_array($result)) { $itemno = $row['itemno']; $sellqty = $row['sellqty']; // mysql_connect("localhost", "root", ""); // mysql_select_db(posdb) or die("Unable to select database"); $query = "SELECT * FROM postable WHERE itemno='$itemno'"; $result=mysql_query($query); $num=mysql_numrows($result); echo "customer# ".$data['invno']; echo ".. </b><br />"; echo "tax rate ".$data['rate']; echo ".. </b><br />"; echo "<table cellspacing=1 cellpadding=1 border=0> <tr> <th>Sold</th> <th>item#</th> <th>item</th> <th>Price</th> <th>Due</th> </tr>"; while($row = mysql_fetch_array($result)) { $tax = $sellprice * $rate; $taxtotal = $taxtotal + $tax; $amtdue = $sellprice * $sellqty; $amtdue = $amtdue + $tax; $total = $total + $amtdue; $onhand - $onhand - $sellqty; echo "<tr>"; echo "<td>" . $row['sellqty'] . "</td>"; echo "<td>" . $row['itemno'] . "</td>"; echo "<td>" . $row['itemdescr'] . "</td>"; echo "<td align=right>" . $row['sellprice'] . "</td>"; echo "<td align=right>" . $row['amtdue'] . "</td>"; } echo "<tr>"; echo "<td>Tax</td>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td align=right>" . sprintf("%.2f",$taxtotal) . "</td>"; echo "<tr>"; echo "<td>Total</td>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td align=right>" . sprintf("%.2f",$total) . "</td>"; echo "</tr>"; echo "</table>"; $sql = "UPDATE postable SET onhand = '" . mysql_real_escape_string($onhand) . "' WHERE itemno='".$_POST["itemno"]."'"; mysql_query($sql) or die("Update query failed."); } ?>
  4. I'm trying to read the taxrate from the database table and use it with values from another table. the database and table are correct as is the field (taxrate) from the table, value is 0.06. Then I'm trying to multiply that value by the value of a field from another table (charges) then update the table . since it doesn't update, I tried echoing the two values but 0 is displayed for both. Will someone advise me? <?php mysql_connect("localhost","root",""); mysql_select_db(numbersdb) or die( "Unable to select database"); $query = "SELECT taxrate FROM numbdata "; mysql_fetch_assoc(mysql_query($query)); $result=mysql_query($query); // include("getpercent.php"); $taxrate = $_POST['taxrate']; echo "taxrate ".$data['taxrate']; mysql_connect(localhost,root,""); mysql_select_db(oodb) or die( "Unable to select database"); $query = "SELECT id, tax,charges,datediff(curdate(),duedate) AS dayslate FROM oocust WHERE pd = ' '"; mysql_fetch_assoc(mysql_query($query)); $result=mysql_query($query); while($row=mysql_fetch_array($result)) { $id=$row['id']; $amtdue = $row['amtdue']; $shipamt = $row['shipamt']; $charges = $row['charges']; $tax = $charges * $taxrate; $amtdue = $charges + $tax + $shipamt; echo "tax is $tax <br /><br />"; $days_late = ($row['dayslate'] > 0)?$row['dayslate'] : 0; $sql = "UPDATE oocust SET tax = " . $tax . ", amtdue = " . $amtdue . ", dayslate = " . $days_late . " WHERE id='$id'"; mysql_query($sql) ; $err=mysql_error(); if($err!="") { echo "Error in $sql: $err\n"; } } echo "Invoice Prep completed"; ?>
  5. thanks, that got rid of the error message. Still not printing the values ?
  6. - I've trimmed this way down trying to resolve. The only fields that print out are invnum and ordernum and I get this message: <?php?> <HTML><HEAD> <script type="text/javascript"> var monthNames = [ "January","February","March","April","May","June", "July", "August","September","October","November","Decembe r" ]; var today = new Date(); var date = monthNames[today.getMonth()] + " - " + today.getDate() + " - " + today.getFullYear(); </script> </HEAD><BODY> </center><div align=right> <script type="text/javascript">document.write(date);</script> </div> <?php mysql_connect(localhost,root,""); mysql_select_db(numbersdb) or die( "Unable to select database"); if(!empty($_POST["submit"])) { $invnum = $_POST['invnum']; } mysql_query("UPDATE numbdata SET invnum=invnum+1"); $result=mysql_query("select invnum from numbdata") or die ("Error - could not retrieve invoice number from database"); $data=mysql_fetch_assoc($result); echo "Invoice No: ".$data['invnum']; mysql_close(); mysql_connect(localhost,root,""); mysql_select_db(oodb) or die( "Unable to select database"); if(!empty($_POST["submit"])) { $ordernum = $_POST['ordernum']; $query=" SELECT * FROM oocust"; $result=mysql_query($query); if(mysql_num_rows($result)) { $bname = $_POST['bname']; $sname = $_POST['sname']; $terms = $_POST['terms']; echo "<form action='#' method='post'> while ($row = mysql_fetch_assoc($result) ) { echo '<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5 background='oldorchard.jpg'> <TD> <TABLE BORDER=0 CELLPADDING=10 CELLSPACING=10 background='oldorchard.jpg'> <TD> <TABLE BORDER=0 CELLPADDING=1 CELLSPACING=1 background='oldorchard.jpg'> <TD> <input type=text size=25 value=Plumbing'><br> <input type=text size=25 value='210 E. Road'><br> <input type=text size=25 value=38063'><br> </TD> <TR> <td> <input type=text size=4 value='Bill To:'><br> <input type=text size=25 value='$bname'><br> <tr> <td> <input type=text size=5 value='Ship To:'><br> <input type=text size=25 value='$sname'><br> </TR> </TABLE> </TD> <TD> <input type=text size=5 value='Terms: '> <input type=text size=12 value='$terms'><br> <input type=text size=10 value='$ordernum'><br> </TD> </TABLE> </TD> <TD align=center><img src='dave pic.jpg' width=250 height=350></td> </TABLE> <tr> </tr> </table>"; echo "</form>"; } else{echo "No listing for order no. $ordernum.<br />Select another?<br />";} } ?> <form method="post" action="#"> <br /> <input type="text" name="ordernum"/> <p> <input type="submit" name="submit" value="+"/> </form>
  7. all my dates I'm reading from a database are formatted mm/dd/yyyy and I want to find the number of days difference from the duedate and the datepaid (dayslate) . ?
  8. I felt good that I was almost done so I added a little selection code but then got this error: <?php?> <HTML><HEAD> <script type="text/javascript"> var monthNames = [ "January","February","March","April","May","June","July", "August","September","October","November","December" ]; var today = new Date(); var mmyy = monthNames[today.getMonth()] + " / " + today.getFullYear(); </script> </HEAD><BODY bgcolor="#CCCC99" background="oldorchard.jpg"><b><center> <font size=+2><b> <script type="text/javascript">document.write(mmyy);</script></center> <?php mysql_connect(localhost,root,""); mysql_select_db(oodb) or die( "Unable to select database"); if(!empty($_POST["submit"])) { $invnum = $_POST['invnum']; $query=" SELECT * FROM oocust"; $result=mysql_query($query); $num=mysql_numrows($result); { echo "<form action='#' method='post'><b>"; echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5'> <TD> <TABLE BORDER=0 CELLPADDING=10 CELLSPACING=10> <TD> <TABLE BORDER=0 CELLPADDING=1 CELLSPACING=1> <TD> <input type=text size=25 value='Old Orchard Plumbing'><br> <input type=text size=25 value='2210 E. Hogan Hollow Road'><br> <input type=text size=25 value='Margate, Fl 33063'><br> </td> <tr> <td> <input type=text size=3 value='Bill To:'><br> <input type=text size=25 value='$bname'><br> <input type=text size=25 value='$bstreet'><br> <input type=text size=25 value='$bcity'><br> <input type=text size=25 value='$contact'><br> </TD> <tr> <td> <input type=text size=3 value='Ship To:'><br> <input type=text size=25 value='$sname'><br> <input type=text size=25 value='$sstreet'><br> <input type=text size=25 value='$scity'><br> </TR> </TABLE> </TD> <TD> <input type=text size=3 value='Invoice No: '> <input type=text size=25 value='$invnum'><br> <input type=text size=3 value='Terms: '> <input type=text size=25 value='$terms'><br> <input type=text size=3 value='Due Date: '> <input type=text size=25 value='$duedate'><br> <input type=text size=3 value='Order No: '> <input type=text size=25 value='$ordernum'><br> </TD> </TABLE> </TD> <td align=center><img src='dave pic.jpg' width=250 height=350></td> </table> echo '<tr>'; <hr> </tr>'; </table>'; echo '</form>'; } else{echo "No listing for invoice no.$invnum.<br />Select another?<br />"; } ?> <form method="post" action="#"> <br /> <input type="text" name="invnum"/> <p> <input type="submit" name="submit" value="+"/> </form>
  9. thanks guys, I'm getting close. the problem now is that > just prints not the vale of the terms field
  10. I made these changes: <?php mysql_connect(localhost,root,""); mysql_select_db(oodb) or die( "Unable to select database"); $query=" SELECT * FROM oocust"; $result=mysql_query($query); $num=mysql_numrows($result); ?> <HTML><HEAD> <script type="text/javascript"> var monthNames = [ "January","February","March","April","May","June","July", "August","September","October","November","December" ]; var today = new Date(); var mmyy = monthNames[today.getMonth()] + " / " + today.getFullYear(); </script> </HEAD><BODY bgcolor="#CCCC99"><b><center> <font size=+2><b>Old Orchard Invoice</font> <script type="text/javascript">document.write(mmyy);</script></center> <?php while ($row = mysql_fetch_assoc($result) ) { echo "<TABLE BORDER="0" CELLPADDING=5 CELLSPACING=5>"; <TD> <TABLE BORDER="0" CELLPADDING=10 CELLSPACING=10> <TD> <TABLE BORDER="0" CELLPADDING=1 CELLSPACING=1> <TD> Old Orchard Plumbing<br> 2210 E. Hogan Hollow Road<br> Margate, Fl 33063<br></TD> <TR> <td> <input type=text size=3 value="Bill To:"><br> <input type=text size=25 value="<?php echo($bname);?>"><br> <input type=text size=25 value="<?php echo($bstreet;?>:">><br> <input type=text size=25 value="<?php echo($bcity);?>"><br> <input type=text size=25 value="<?php echo($contact)?>"><br></TD> <tr> <td> <input type=text size=3 value="Bill To:"><br> <input type=text size=25 value="<?php echo($sname);?>"><br> <input type=text size=25 value="<?php echo($sstreet;?>:">><br> <input type=text size=25 value="<?php echo($scity);?>"><br> </TR> </TABLE> </TD> <TD> <input type=text size=3 value="Bill To: "> <input type=text size=25 value="<?php echo($invnum);?>"><br> <input type=text size=3 value="Date: "> <input type=text size=10 value="<?php echo($mm/dd/yyyy);?>:">><br> <input type=text size=3 value="Terms: "> <input type=text size=25 value="<?php echo($terms);?>"><br> <input type=text size=3 value="Due Date: "> <input type=text size=25 value="<?php echo($duedate);?>"><br> <input type=text size=3 value="Order No: "> <input type=text size=25 value="<?php echo($ordernum);?>"><br> </TD> </TABLE> </TD> <TD align=center><img src="dave pic.jpg" width=250 height=350></td> </TABLE> echo "<tr>"; </tr>"; echo "</table>";mysql_close(); } ?> </b></BODY></HTML> and I got this error:
  11. I want to read records from the database and print out in this table and I need help with the code. <?php mysql_connect(localhost,root,""); mysql_select_db(oodb) or die( "Unable to select database"); $query=" SELECT * FROM oocust"; $result=mysql_query($query); $num=mysql_numrows($result); ?> <HTML><HEAD> <script type="text/javascript"> var monthNames = [ "January","February","March","April","May","June","July", "August","September","October","November","December" ]; var today = new Date(); var mmyy = monthNames[today.getMonth()] + " / " + today.getFullYear(); </script> </HEAD><BODY bgcolor="#CCCC99" background="oldorchard.jpg"><b><center> <font size=+2><b> Old Orchard Invoice </font>Date: <script type="text/javascript">document.write(mmyy);</script></center> echo "<TABLE BORDER="0" CELLPADDING="5" CELLSPACING="5" background="oldorchard.jpg"> <TD> <TABLE BORDER="0" CELLPADDING="10" CELLSPACING="10" background="oldorchard.jpg"> <TD> <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="1" background="oldorchard.jpg"> <TD> <input type=text size=25 value="Old Orchard Plumbing"><br> <input type=text size=25 value="2210 E. Hogan Hollow Road"><br> <input type=text size=25 value="Margate, Fl 33063"><br></TD> <TR> <td> <input type=text size=3 value="Bill To:"><br> <input type=text size=25 value="$bname"><br> <input type=text size=25 value="$bstreet:">><br> <input type=text size=25 value="$bcity"><br> <input type=text size=25 value="$contact"><br></TD> <tr> <td> <input type=text size=5 value="Ship To:"><br> <input type=text size=25 value="$sname:"><br> <input type=text size=25 value="$street"><br> <input type=text size=25 value="$scity"></td> </TR> </TABLE> </TD> <TD> <input type=text size=25 value="Invoice No: $invnum"><br> <input type=text size=25 value="Date: $mm/dd/yyyy"><br> <input type=text size=25 value="Terms: $terms"><br> <input type=text size=25 value="Due Date: $duedate"><br> <input type=text size=25 value="Order No: $ordernum"><br> <input type=text size=25 value="Territory:"><br> <input type=text size=25 value="Salesperson:"><br> </TD> </TABLE> </TD> <TD align=center><img src="dave pic.jpg" width=250 height=350></td> </TABLE> echo "</tr>"; <hr> echo "</table>";mysql_close(); ?> </b></BODY></HTML>
  12. This program is to be used at the end of each month to begin the month with fresh values. When executed there are no errors, the message "Records have been updated" is displayed, but no records are changed? <?php $stat = mysql_connect("localhost","root",""); $stat = mysql_select_db("prerentdb"); $query = "SELECT name FROM payments Where apt='$apt'"; $stat = @mysql_fetch_assoc(mysql_query($query)); echo $stat["name"]; $result= mysql_query("select * from payments"); while($row=mysql_fetch_array($result)) { $id=$row['id']; $paidsum=$row['paidsum']; $rentdue=$row['rentdue']; $prevbal=$row['prevbal']; $latechg=$row['latechg']; // if no payment or partial payment, add $10 to latechg field // and amount not paid to prevbal field if ($paidsum < $rentdue) { $latechg = $latechg + 10; $owe = $rentdue - $paidsum; $prevbal = $prevbal + $owe; } // if over-payment and late field not "L", subtract over-payment // from prevbal field if ($paidsum > $rentdue && $late |= 'L') { $sub = $paidsum - $rentdue; $prevbal = $prevbal - $sub; } // refresh every record - give every record the below values $amtpaid = 0; $hudpay = 0; $tentpay = 0; $datepaid = ' '; $late = ' '; $paidsum = 0; $comments = ' '; $sql = "UPDATE payments SET $amtpaid, $prevbal, $hudpay, $tentpay, $datepaid, $late, $comments, $paidsum"; mysql_query($sql) ; } echo "Records have been updated"; ?>
  13. this code works fine it I take out the checkboxes(repair & replace) in the html & PHP ? <form name="form" action="<?php $_SERVER[php_SELF] ?>" method="post"> <input type="text" size="2" name="apt" id="apt" onkeyup="getResults();if(this.value.length==this.size)document.form.datereceived.focus();" />Apt<br /> <input type="text" size="25" name="name" id="name" />Name<br /> <INPUT TYPE="text" size=10 name="datereceived" onKeyUp="if(this.value.length==this.size)document.form.time.focus();">Date Received<br /> <INPUT TYPE="text" size=7 name="time">Time Received<br /> <br>Kitchen <select name="item"> <option value="kitchen blinds" selected>kitchen blinds</option> <option value="kitchen bifolds">kitchen bifolds</option> <option value="kitchen lights">kitchen light fixtures</option> <option value="kitchen bulbs">kitchen light bulbs</option> <option value="kitchen tile">kitchen tile/linoleum</option> <option value="kitchen countop">kitchen counter top</option> <option value="kitchen cabinets">kitchen cabinets</option> <option value="kitchen drawers">kitchen drawers</option> <option value="fridge">refidgerator</option> <option value="stove">stove</option> <option value="range hood">stove hood</option> <option value="kitchen sink">kitchen sink</option> <option value="under kitchensink">under kitchen sink</option> <option value="kitchen faucet">kitchen faucet</option> <option value="kitchen drain">kitchen drain</option> <option value="kitchen screens">kitchen windows & screens</option> <option value="fire extinguisher">fire extinguisher</option> <option value="kitchen wall plates">kitchen switch plates</option> <option value="kitchen outlets">kitchen electrical outlets</option> <option value="kitchen ceilings">kitchen ceiling paint</option> <option value="kitchen wallpaint">kitchen wall paint</option> </select> <br> repaired <input type=checkbox name="repair" value="Y"> replaced <input type=checkbox name="replace" value="Y"><br> </p> action<INPUT TYPE="text" size=100 name="action"><br /> <INPUT TYPE="text" size=2 name="compday" MAXLENGTH=2 onKeyUp="if(this.value.length==this.size)document.form.compmoyr.focus();"> <INPUT TYPE="text" size=7 name="compmoyr" MAXLENGTH=7 Date Completed - <font color=red>day then mm/yyyy</font <br /><br /> cost<INPUT TYPE="text" size=4 name="cost"> charge<INPUT TYPE="text" size=4 name="charge"> Order#<INPUT TYPE="text" size=4 name="ordno"> - If Insp <p> <INPUT type="submit" value="submit data" /> </p> </form> <?php if (isset( $_POST['apt']) ) { $apt=$_POST['apt']; $name=$_POST['name']; $datereceived=$_POST['datereceived']; $time=$_POST['time']; $item=$_POST['item']; $repair=$_POST['repair']; $replace=$_POST['replace']; $action=$_POST['action']; $compday=$_POST['compday']; $compmoyr=$_POST['compmoyr']; $cost=$_POST['cost']; $charge=$_POST['charge']; $ordno=$_POST['ordno']; $stat = mysql_connect("localhost","root","") or die('Unable to connect to database: ' . mysql_error()); $stat = mysql_select_db("maintdb") or die('Unable to select database: ' . mysql_error()); $query = " INSERT INTO maintdata (apt,name,datereceived,time,item,repair,replace,action,compday,compmoyr,cost,charge,ordno) VALUES('$apt','$name','$datereceived','$time','$item','$repair','$replace','$action','$compday','$compmoyr','$cost','$charge','$ordno')"; echo "apt $apt data inserted</font><br /><br />"; $stat = mysql_query($query) or die('Query failed: ' . mysql_error()); mysql_close(); } ?>
  14. how do I use a connection file (connection.php) in multiple programs? I think include?
×
×
  • 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.