Jump to content

lanceox

Members
  • Posts

    41
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

lanceox's Achievements

Member

Member (2/5)

0

Reputation

  1. Thanks for your help in all but I may have confused you. what I would like Everything outputs great but can a table be included within the for loop so that no matter how many or few fields are printed; the size and availability will have its own row and column <table> Column 1 (simply to explain) Column2 (simply to explain) Size (own box) Availability 8-10 (own box) 34 (own box) 12-14 (own box) 34 (own box) 16-18 (own box) 34 (own box) 20-22 (own box) 34 (own box) </table> Thanks and again, sorry for confusion
  2. When I use this code it prints out array information. I changed it slightly (i.e. variables) and it only prints one size. The code is use is: <?php { echo'<pre>'; var_export($option_value['name'].' '.$option_value['quantity']); echo '</pre>'; } ?> The output i get is: '16 - 18 34' Thanks
  3. Hi, thanks for your answer. what I mean is that, at the moment the array prints out a products sizes (which can vary and also availability). So when considering the following code: <?php foreach ($option['option_value'] as $key => $option_value) { print ( '<pre>' ) ; print_r ($option_value['name'] .' '.$option_value['quantity']) ; print ( '</pre>' ) ; } ?> The for loop will print out all whatever the sizes and quantities are listed, however I would like it to add another row for any additional sizes. I think this should be within the for loop and print <new row> everytime $option_value['name'] is printed and then <new column then new row> everytime $option_value['quantity']). Size Availability 8-10 34 12-14 34 16-18 34 20-22 34 Hope this helps more Thanks guys
  4. Hi Thanks for the helps. This has put them in columns which i would like. Is there anyway that a table with rows and columns could be output aswell. For example below I have entered information (I know its wrong but just to try and explain what I mean) <table> <?php foreach ($option['option_value'] as $key => $option_value) { <tr> print ( '<pre>' ) ; print_r ($option_value['name'] .' '.$option_value['quantity']) ; print ( '</pre>' ) ; </tr> } ?> </table> I would like it to be output like this with cells, etc. Any form of really, just so that it will be output results in a table Size Availability 8-10 34 12-14 34 16-18 34 20-22 34 Thanks for all help so far
  5. Hey, I currently display the product options and the available quantity and everything works fine however I would like this information to be displayed in a table automatically (array form). This currently works using an array and outputs the information below. At the moment it looks like this: 8 - 10 12 - 14 16 - 18 34 34 34 However I would like it in table form, for example: Size Availability 8 - 10 34 12 - 14 34 16 - 18 34 <?php foreach ($option['option_value'] as $option_value) { print ( '<pre>' ) ; print_r ($option_value['name']); print ( '</pre>' ) ; } ?> <?php foreach ($option['option_value'] as $option_value) { print ( '<pre>' ) ; print_r ($option_value['quantity']); print ( '</pre>' ) ; } ?> If anyone could help that would be great. I have tried everything. If you need any further details please let me know
  6. it works there was a problem with the form and the it wasnt sending correct values. I echo'd out the values to see what wasnt working and corrected them Thanks for your help Lance
  7. Hey, i tried the way you said, however it still wont work, No errors occur however it just doesnt update the values in the database. Can someone have a look at see where i am going wrong. The form section <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>stock manager</title> </head> <body> <center> <table> <td> <table> <td> <form action='stockview.php' method='POST'> Please Enter a Stock Name and Stock Value <table> <tr> <td> Stock Name: </td> <td> <input name="stockname" type="text" /><BR /> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stockqty" type="text" /> </td> </tr> </table> <input name="submit1" type="submit" value="Add New Stock Items" /> </form> </td> </table> </td> <td> <table> <td> <form action='stockview.php' method='POST' enctype="multipart/form-data"> Please Select from the list the item you wish to update <table> <tr> <td> Stock Name: </td> <td> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); ?> <select name="stock"><option>Select Stock From List</option>";<?php while($row = mysql_fetch_array($result)) { echo "<option value=\"".$row[id]."\">".$row[stockname]."</option>"; } ?> </select> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty1" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Update stock items" /> </form> </td> </table> </td> </table> <BR /><BR /> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT stockname, stockqty FROM stocks"); $result = mysql_query ($query); echo "<table border='1'>"; echo "<tr><th>Stock Name</th> <th>Stock Quantity</th></tr>"; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<tr><td>"; echo $row['stockname']; echo "</td>"; echo "<td>"; echo $row['stockqty']; echo "</td>"; } ?> </center> <table> <tr> <td> </td> <td> </td> </tr> </body> </html> The form handler section <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>stock</title> </head> <body> <?php $submit1 =&$_POST['submit1']; $stockname =&$_POST['stockname']; $stockqty =&$_POST['stockqty']; $submit =&$_POST['submit']; $stockqty1 =&$_POST['stock_qty1']; $id =&$_POST['stock']; if(isset($submit1)) { if(isset($stockname) && ($stockqty)) { $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query = mysql_query("SELECT * FROM stocks WHERE stockname='$stockname'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { echo("Item already exists!");?><BR /><BR /><?php echo("Please Add A non-existent Item!");?> <a href="stockmanager.php">Try again!</a><?php } else { $queryreg = mysql_query("INSERT INTO `stocks` (stockname, stockqty) VALUES ('$stockname','$stockqty')"); echo("Stock has been added"); } } else { echo("Please fill in all fields to add stock!"); } } if(isset($submit)) { $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); $sql = mysql_query("SELECT * FROM stocks WHERE id='$id'"); $numrows = mysql_num_rows($sql); $update = mysql_query("UPDATE stocks SET stockqty=$stockqty1 WHERE id=$id'"); echo("Item has been updated");?><BR /><BR /> <?php echo("Click here to return to stock manager!");?> <a href="stockmanager.php">Click Here!</a><?php } ?> </body> </html> Thanks Lance
  8. Hi guys, is it possible to update a field ina a database using a select box. So far i have populated the select box with database values and it works fine, however i dont know how to update the field properly in a database. have a look at the code and tell me what you think. <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>stock manager</title> </head> <body> <center> <table> <td> <table> <td> <form action='stockview.php' method='POST'> Please Enter a Stock Name and Stock Value <table> <tr> <td> Stock Name: </td> <td> <input name="stockname" type="text" /><BR /> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stockqty" type="text" /> </td> </tr> </table> <input name="submit1" type="submit" value="Add New Stock Items" /> </form> </td> </table> </td> <td> <table> <td> <form action='stockview.php' method='POST' enctype="multipart/form-data"> Please Select from the list the item you wish to update <table> <tr> <td> Stock Name: </td> <td> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); echo "<select name=stock value=''>Edit Stock QTY</option>"; while($nt=mysql_fetch_array($result)) { //Array or records stored in $nt echo "<option value=$nt[id]>$nt[stockname]</option>"; /* Option values are added by looping through the array */ } ?> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty1" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Update stock items" /> </form> </td> </table> </td> </table> <BR /><BR /> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT stockname, stockqty FROM stocks"); $result = mysql_query ($query); echo "<table border='1'>"; echo "<tr><th>Stock Name</th> <th>Stock Quantity</th></tr>"; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<tr><td>"; echo $row['stockname']; echo "</td>"; echo "<td>"; echo $row['stockqty']; echo "</td>"; } ?> </center> <table> <tr> <td> </td> <td> </td> </tr> </body> </html> Here is the page that handles the form <?php session_start(); $_SESSION['nt']; $sn = $_SESSION['nt']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>stock</title> </head> <body> <?php $submit1 =&$_POST['submit1']; $stockname =&$_POST['stockname']; $stockqty =&$_POST['stockqty']; $submit = &$_POST['submit']; $stockqty1 = &$_POST['stock_qty1']; if(isset($submit1)) { if(isset($stockname) && ($stockqty)) { $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query = mysql_query("SELECT * FROM stocks WHERE stockname='$stockname'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { echo("Item already exists!");?><BR /><BR /><?php echo("Please Add A non-existent Item!");?> <a href="stockmanager.php">Try again!</a><?php } else { $queryreg = mysql_query("INSERT INTO `stocks` (stockname, stockqty) VALUES ('$stockname','$stockqty')"); echo("Stock has been added"); ?><BR /><BR /> <?php echo("Click here to return to stock manager!");?> <a href="stockmanager.php">Click Here!</a><?php } } else { echo("Please fill in all fields to add stock!"); } } if(isset($submit)) { $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); while($nt=mysql_fetch_array($result)) { //Array or records stored in $nt echo "<option value=$nt[id]>$nt[stockname]</option>"; /* Option values are added by looping through the array */ } $queryreg = mysql_query("SELECT * FROM stocks WHERE stockqty='$stockqty1'"); $numrows = mysql_num_rows($queryreg); $update = mysql_query("UPDATE stocks SET stockqty=$stockqty1 WHERE stockname=$sn'"); echo("Item has been updated"); } ?> </body> </html> Any help woul;d be really great, i ahve tried everything for days on end now Thanks Lance
  9. Everything works fine and the select box appears and i can choose options from the database, however when i enter a new quantity the values are not modified.... So is there something wrong with the actual insert statements Im not sure how to choose the value from the select field. Hope this makes more sense Thanks Lance
  10. Hi guys, i have a select box which has been populated with values from the database however i would like to be able to select the value from the select box and change the qty. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>stock manager</title> </head> <body> <?php $stockqty =&$_POST['stock_qty1']; ?> <center> <table> <td> <table> <td> <form action='stockview.php' method='POST'> Please Enter a Stock Name and Stock Value <table> <tr> <td> Stock Name: </td> <td> <input name="stock_name" type="text" /><BR /> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Add New Stock Items" /> </form> </td> </table> </td> <td> <table> <td> <form action='stockmanager.php' method='POST' enctype="multipart/form-data"> Please Select from the list the item you wish to update <table> <tr> <td> Stock Name: </td> <td> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); echo "<select name=stock value=''>Edit Stock QTY</option>"; while($nt=mysql_fetch_array($result)) { //Array or records stored in $nt echo "<option value=$nt[id]>$nt[stockname]</option>"; /* Option values are added by looping through the array */ } $queryreg = mysql_query("SELECT * FROM stocks WHERE stockqty='$stockqty'"); $numrows = mysql_num_rows($queryreg); $update = mysql_query("UPDATE stocks SET stockqty='$stockqty' WHERE stockname = '$stockname'"); echo("Its updated"); ?> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty1" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Update stock items" /> </form> </td> </table> </td> </table> </center> </body> </html> Any help would be greatly appreciated... ive been working on this for a while and cant seem to find the answer. Thanks Lance
  11. Hi guys, Im developing a stock system and so far new stock and can be added with the quantity, however im trying to update the stock by using a select box and selecting the type of stock and inputting a new qty. the form and everything is set up and i can select files from the database, however i dont know how to update files from a select box The code i got so far is <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>stock manager</title> </head> <body> <?php $stockqty =&$_POST['stock_qty1']; ?> <center> <table> <td> <table> <td> <form action='stockview.php' method='POST'> Please Enter a Stock Name and Stock Value <table> <tr> <td> Stock Name: </td> <td> <input name="stock_name" type="text" /><BR /> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Add New Stock Items" /> </form> </td> </table> </td> <td> <table> <td> <form action='stockmanager.php' method='POST' enctype="multipart/form-data"> Please Select from the list the item you wish to update <table> <tr> <td> Stock Name: </td> <td> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); echo "<select name=stock value=''>Edit Stock QTY</option>"; while($nt=mysql_fetch_array($result)) { //Array or records stored in $nt echo "<option value=$nt[id]>$nt[stockname]</option>"; /* Option values are added by looping through the array */ } $queryreg = mysql_query("SELECT * FROM stocks WHERE stockqty='$stockqty'"); $numrows = mysql_num_rows($queryreg); $update = mysql_query("UPDATE stocks SET stockqty='$stockqty' WHERE stockname = '$stockname'"); echo("Its updated"); ?> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty1" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Update stock items" /> </form> </td> </table> </td> </table> </center> </body> </html> Any help would be greatly appreciated. Thanks Lance
  12. ive checked to see if it exists but for example when i got to add exactly the same stock name it just adds a new one rather than echoing an error message saying item already exists, please updata existing values. Thanks Lance
  13. thanks it worked better than the way i done it. Thanks Is there a way i can check if stock exists then print message otherwise add to db. This is the kind of thing i mean.... where am i going wrong ? $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query = mysql_query("SELECT * FROM stocks WHERE stockname=$stockname, stockqty=$stockqty"); $numrows = mysql_num_rows($query); if ($numrows!=0) { echo("Item already exists! Try Updating the items instead!"); } else { $queryreg = mysql_query("INSERT INTO `stocks` (stockname, stockqty) VALUES ('$stockname','$stockqty')"); echo("stock added!"); }
  14. hi guys hope some1 can help. im creating a system that will allow stock to be added to a database and modifed. However on the add section, nothing adds it only inputs a new id row in the database and the other fields are blank. Can anyone have a look for me This sections is the form handler once the user has input a stockname and stock qty <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>stock</title> </head> <body> <?php $stockname = &$_POST['stockname']; $stockqty = &$_POST['stockqty']; $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query = mysql_query("SELECT * FROM stocks WHERE stockname=$stockname, stockqty=$stockqty"); $numrows = mysql_num_rows($query); if ($numrows!=0) { echo("Item already exists! Try Updating the items instead!"); } else { $queryreg = mysql_query("INSERT INTO `stock` . `stocks` (`id`, `stockname`, `stockqty`) VALUES (NULL,'$stockname','$stockqty')"); echo("stock added!"); } ?> <center><table> <tr> <td> Stock_id </td> <td> Stock_name </td> <td> Stock_Qty </td> </tr> </table></center> </body> </html> Thanks Lance
  15. Thanks for advice. With a bit of shuffling the pages around it worked. Thanks for all the advice. Lance P.s my project is done now.... thanks to you
×
×
  • 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.