Jump to content

Kano

Members
  • Posts

    76
  • Joined

  • Last visited

    Never

Everything posted by Kano

  1. Here is the php that builds the form: $sqlqry_getwsi = "select * from tbl_wsi"; $sqlres_getwsi = mysql_query($sqlqry_getwsi) or die ("Could not execute getwsi query"); $num = 1; while($row_getwsi = mysql_fetch_array($sqlres_getwsi)) { extract($row_getwsi); echo "<tr><td>$wsi_tn</td><td>$wsi_id</td><td>$wsi_desc</td><td>$wsi_dim</td><td>$wsi_cm</td><td>$wsi_price</td><span id = 'A$num'><td>$wsi_qty</td></span><td>$wsi_nextshiparr</td><td><input type='text' value='$remember_qty[$num]' id='A$num' name='$wsi_id' /></td><td><input = 'text' name='total$num' onchange='calc()' /></td></tr>"; $num++; }
  2. OK I understand. The grand total is easy but because I want each sub total to mulitply the quantity by the price as the user inputs the quantity how does javascript know how many rows there are? Here is some javascript: function calc() { var elements = document.getElementsByTagName("input"); for(var i = 0; i < elements.length; i++) { if(elements.type == 'text') { if(elements.id.indexOf("qty") != '-1') { document.form.qty????????????.value = (document.form.****span id*****.value) * (document.form.*****qty input box.value) } Question: How can I get javascript to include after the qty, the number of the count? (where the ??????? are) Thanks.
  3. OK <span id= could it just be <td id = And also the javascript, how does it make sure the sub totals get the correct numbers For example, the php that build the form is in a loop and because the number of rows is unknown each id (for the <td> and <input>) will equal a count, so how does javascript do this without the number of rows known? Thanks.
  4. onBlur, thanks. Also, how does Javascript calculate a <td> * <input> thanks.
  5. Hi there, for example each row has the product description including price and an input box, the user inputs the quantity and then we will have another input box which states the total price for that order. Then at the bottom of the order it will have sub totals and totals of the entire order. Thanks.
  6. Hi there, I was wondering if anyone new of some good scripts that calculate the input (quantity) with the price of the produce. The price of the product is a <td> and the quantity is an <input = 'text>. But, each <td> and <input> is built from a loop in php where it gets the product details, because we don't the exact number of rows on the page how do we calculate each row? I have search the internet and found scripts but none seem to take into account that the form is built using php/MySQL loops. The script is so the use can keep a running total when inputting quantities, Thanks.
  7. Hi there, Here is the code I have been putting together this morning and its driving me round the bend (2 files -php and inc): update_stockqty_ck.php <?php if(@$_GET['update_stockqty'] == "yes") { for($cnt = 0;$cnt<$getstock_cnt;$cnt++) { if(!ereg("^[0-9]{1,4}$", ${"addqty$cnt"})) { unset($_GET['update_stockqty']); $ErrMsg = "$addqty$cnt is not a valid amount to add!"; include("update_stock.inc"); exit(); } } for($cnt = 0;$cnt<$getstock_cnt;$cnt++) { if(!ereg("^[0-9]{1,4}$", ${"subqty$cnt"})) { unset($_GET['update_stockqty']); $ErrMsg = "$subqty$cnt is not a valid amount to subtract!"; include("update_stock.inc"); exit(); } } $dbusername = ""; $hostserver = "localhost"; $dbpass = ""; $db = "db_mosley_trading"; $makeconn = mysql_connect($hostserver, $dbusername, $dbpass) or die ("Could not connect to server."); $conndb = mysql_select_db($db, $makeconn) or die ("Could not connect to database."); $update = date("Y-m-d"); for($cnt = 0;$cnt<$getstock_cnt;$cnt++) { $item_qty = $i_qty[$cnt] + ${"addqty$cnt"} - ${"subqty$cnt"}; $sqlquery_addstock = "insert into tbl_wsi (wsi_qty,wsi_lastupdated) values ('$item_qty','$update') where wsi_id = '$i_id[$cnt]'"; mysql_query($sqlquery_addstock) or die ("could not execute add stock query!"); } } else { include("update_stock.inc"); } ?> <?php $dbusername = ""; $hostserver = "localhost"; $dbpass = ""; $db = "db_mosley_trading"; $makeconn = mysql_connect($hostserver, $dbusername, $dbpass) or die ("Could not connect to server."); $conndb = mysql_select_db($db, $makeconn) or die ("Could not connect to database."); ?> <body> <form action = "update_stockqty_ck.php?update_stockqty=yes" onsubmit = "return validate_update_stockqty(this)" method = "POST"> <table> <tr> <td> <?php if(isset($ErrMsg)) { echo"<hr></td></tr><tr><td>"; $ErrMsg=stripslashes($ErrMsg); echo"$ErrMsg"; } ?> </td> </tr> <tr> <td> <hr> </td> </tr> <tr><td> <table><tr><td>Item Ref</td><td>Item Description</td><td>Stock Qty</td><td>Qty to Add</td><td>Qty to Subtract</td><td>Last Updated</td></tr> <?php $sqlquery_getstock = "select wsi_id, wsi_desc, wsi_qty from tbl_wsi"; $sqlres_getstock = mysql_query($sqlquery_getstock) or die ("Could not execute getstock query"); $getstock_cnt = 0; $i_id = ""; $i_desc = ""; $i_qty = ""; $i_lastupdated = ""; while($row_getstock = mysql_fetch_array ($sqlres_getstock)) { extract($row_getstock); $i_id[$getstock_cnt] = $wsi_id; $i_desc[$getstock_cnt] = $wsi_desc; $i_qty[$getstock_cnt] = $wsi_qty; $i_lastupdated[$getstock_cnt] = $wsi_lastupdated; $getstock_cnt++; } for($cnt=0;$cnt<$getstock_cnt;$cnt++) { echo "<tr><td>$i_id[$cnt]</td><td>$i_desc[$cnt]</td><td>$i_qty[$cnt]</td><td><select name = 'addqty$cnt'>"; for($selectcnt=0;$selectcnt<=99;$selectcnt++){ echo "<option value = '$selectcnt'"; if($selectcnt < 1) {echo "selected = 'selected'"; } echo ">$selectcnt";} echo "</select></td><td><select name = 'subqty$cnt'>"; for($selectcnt2=0;$selectcnt2<=99;$selectcnt2++){ echo "<option value = $selectcnt2>$selectcnt2";} echo "</select></td><td>$i_lastupdated[$cnt]</td></tr>"; } ?> </table></td></tr><tr><td> <input type = "submit" value = "Process" /> </td></tr></table></form></body></html> thanks.
  8. Hi all, My prob is that i have a form for employees to input stock quantitys. Each stock has a drop down select menu for the quantity to update. Each select has a name = addqty$cnt ($cnt being the number in the loop that lists the stock followed by the drop down menu). Now, when I go to update the database and call the $addqty$cnt it does not like it? can anyone help please. thanks.
  9. Dude, just an opinion but Dreamweaver should only be used for prototypes, you should really code using notepad (or similar) as Dreamweaver produces nasty code
  10. Your problem my lie in this script - compatabilityResults.php
  11. Mate, what is the reason for this statement - if ($max_width && $max_height)
  12. sorry for my first posting I did not realise that there was a horizontal scroll for the code you submitted
  13. Jasen dude, xhtml is so simple man, its worth looking at someday when you get chance. www.htmldog.com explains how to code in xhtml and css in a way that even george bush could grasp it! I apologize in advance to all the yanks, not!
  14. Maybe you should change your charset to utf-8 Not sure these things will help your problem but they are good practice
  15. The first font tag inside the body tag has not been closed? You should really rewrite this in xhtml (see www.htmldog for advice) and css.
  16. yes, thanks guys.
  17. What and how is short tags turned on ? thanks
  18. does <? work the same as <?php
  19. try getting rid of all your spaces between lines and replacing it with \n for each line
  20. select * from table where members_id != '1';
  21. <?php echo "$table_row[name]" ?>
  22. Thanks onlyican, That is what i needed to know, this would then prevent the problem of only allowing loggin from one ip address per user (which is not helpful) and also prevent users from passing their details because of the situation where they cannot get into the system whilst someone is using their account. One problem is if someone aquired someone elses account details but then this can be overcome be using an admin contact link if there are problems with the account, i would assume. thanks for your help
  23. I think SemiApocalyptic means different priorities like in maths times is calculated before add and brackets is done first etc...
  24. Hi all, I have a general question that has been bugging me for a while. I am wondering whether it is possible in php that a script can prevent members from sharing accounts. I am thinking that we could prevent people logging in to a system under a username when that username is already logged in to the system but are there any otherways? I am not after any code as such, just some general advice and opinions on how to go about this task. Thanks for any advice
  25. Yes OK thank-you, I would anyway, I just thought that someone may know of any good articles giving a good argument for and against PHP (or open source)
×
×
  • 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.