Jump to content

searls03

Members
  • Posts

    907
  • Joined

  • Last visited

Everything posted by searls03

  1. I am not very knowledgeable on join queries but this is what i have: $sql=mysql_query("select cat.id, cat.subcategory, cat.category, prod.product, prod.price, prod.id, prod.category, prod.subcategory from categories cat left join products prod on cat.category = prod.category where prod.prodcut='$prodcut' and prod.category='$category' "); What I need is for a query to run through the database table"categories" picking out all the categories, then based on the category, it picks from "products" with the same category in the column "category". here is the problem though, I need all the results to display, so there are like 10 categories, I need to see all those categories, then there are multiple products for each category, and I would like all those to display. anyhelp here? Am i even remotely close?
  2. OK, so I am currently working on building an ONLINE POS system. This POS has buttons with each item in them. What I would like to do is have each of the buttons in their own form, and each button is a submit. but what I would like is for the submitted items to be stored, but displayed onscreen with a delete option, for later submission into database. so currently they are being stored client side, but later will be submitted server-side. so I could click on t-shirt and it would show in a checkout area "t-shirt" with a delete option by it, so if I have to delete it, it won't be submitted to database. but when I click the button that says checkout, all the items in the shopping cart area(the display area) will then be submitted to the database. Currently I have it so that they are submitted first, then a div refreshes to show after they were put into the database, I do not want this, cause it can be very slow at responding at times, or refresh before it was submitted. any help is greatly appreciated. I don't really have anywhere to start, so if someone could help me with that, that would be what is best!
  3. so something like: $sql = mysql_query("SELECT * FROM products WHERE city='$city' && package='Breaking'"); while($row = mysql_fetch_array($sql)){ $id=array(); $category = array(); $price = array(); $product = array(); $order = array(); $id[]=$row['id']; $category[] = $row['category']; $price[] = $row['price']; $product[] = $row['product']; $order[] = $row['orderable']; } foreach($product AS $key => $val) { $product = $val; $category1 = $category[$key]; $price1 = $price[$key]; $id1 = $id[$key]; $order1 = $order[$key]; $sql = "INSERT INTO cart (price, product123, quantity, cart_id, product_id, academy, orderable, category) VALUES('$price1', '$product', '1', '".$_SESSION['complete']."', '$id1', '".$_SESSION['academy']."', '$order1', '$category1')"; $rs = mysql_query($sql) or die ("Problem with the query: $sql <br />" . mysql_error());} this only takes one query and inserts it.
  4. it's as it loops through the database, an array will be formed with all the records. so lets say it queries column named numbers and it makes it into an array with values "1,2,3,4,5". does this make sense?
  5. Eventually I will be adding an insert query for every time something is pulled. How do I make it so that they are arrays and not strings?
  6. THis isn't working right now, but how would I do a foreach loop inside a while loop. so for every $product that is returned from the while, the foreach will run for it? $sql = mysql_query("SELECT * FROM products WHERE city='$city' && package='Breaking'"); while($row = mysql_fetch_array($sql)){ $id=$row['id']; $category = $row['category']; $price = $row['price']; $product = $row['product']; $order = $row['orderable']; foreach($product AS $key => $val) { $product = $val; $category1 = $category[$key]; $price1 = $price[$key]; $id1 = $id[$key]; $order1 = $order[$key];
  7. ok, how do I add an auto incremented value to another table at the same time the value is created. so I will do a query to insert into db, and it creates auto incremented value of 1, then I need this value to also be put into another table just as text. how do I go about doing this? I need this all in one query.
  8. then I need a way to combine all the arrays to make one variable for posting to the spreadsheet.
  9. so I would need to make $_POST['label1/name1'] $_POST['label2/name2'] $_POST['label3/name3'] $_POST['label4/name4'] or as many that are as needed. then they need to combine all of those into one string for submissions.
  10. ok.....so the original code that makes the field boxes <?php // Query member data from the database and ready it for display $sql4 = mysql_query("SELECT * FROM labels where item_id='".$pid."'"); $num_rows = mysql_num_rows($sql4); echo $num_rows; $counter = 0; while($row = mysql_fetch_array($sql4)){ $label =$row["label"]; $lid=$row['id']; $counter = $counter + 1; print $counter . "<BR>"; ?> <input type="text" name="label<?php echo $counter; ?>" value="<?php echo $label; ?>" /> <select name="name<?php echo $counter; ?>"> this makes <input type="text" name="label1" value="<?php echo $label; ?>" /> <input type="text" name="label2" value="<?php echo $label; ?>" /> <input type="text" name="label3" value="<?php echo $label; ?>" /> <input type="text" name="label4" value="<?php echo $label; ?>" /> <select name="name1"> <select name="name2"> <select name="name3"> <select name="name4"> these could go on forever and never end. So then in the code that posts, I need to figure out a way to make all the post variables with the correct names using a counter. then I need to combine all the post variables that were made to make a string that submits the string to one box in google docs. does this make more sense?
  11. I could do it using if isnot empty statements....but then I would have to limit options. I don't want to do this.
  12. so in one row, I want all the looped results to be in one string so that it posts properly. In one code: <?php // Query member data from the database and ready it for display $sql4 = mysql_query("SELECT * FROM labels where item_id='".$pid."'"); $num_rows = mysql_num_rows($sql4); echo $num_rows; $counter = 0; while($row = mysql_fetch_array($sql4)){ $label =$row["label"]; $lid=$row['id']; $counter = $counter + 1; print $counter . "<BR>"; ?> <input type="text" name="label<?php echo $counter; ?>" value="<?php echo $label; ?>" /> <select name="name<?php echo $counter; ?>"> <?php this is making a multitude of text boxes. named label1(2,3,4,etc.) and same for name1(2,3,4, etc.). The problem is I need to make post variable for all this inside the posting code, but then all of those post variables combine to make one string for one insert. does this make a little bit more sense now? so I need to make as many as the loop runs through.
  13. If I do that, it would insert multiple rows. I only want one row,
  14. so what would be the best way to go about this? I suck at writing arrays and I need advice on them
  15. no I don't want to post an array like that. it would insert multiple rows. I only want one row.
  16. btw, this is what I am trying to post: <input type="text" name="item" value="T-Shirt: Dry Fit" /> 31<BR> <input type="text" name="label1" value="Size" /> <select name="name1"> Size <option value="YS"> YS</option> <option value="YM"> YM</option> <option value="YL"> YL</option> <option value="AS"> AS</option> <option value="AM"> AM</option> <option value="AL"> AL</option> <option value="AXL"> AXL</option> <option value="AXXL"> AXXL</option> </select> </br> 2<BR> <input type="text" name="label2" value="Color" /> <select name="name2"> Color <option value="Black"> Black</option> <option value="Red"> Red</option> </select> </br> 3<BR> <input type="text" name="label3" value="Chevrons" /> <select name="name3"> Chevrons <option value="5"> 5</option> <option value="4"> 4</option> <option value="3"> 3</option> <option value="2"> 2</option> <option value="1"> 1</option> <option value="0"> 0</option> </select> </br> so When the string is done.....it would look like item label1 name1 label2 name2 label3 name3. and there could be as many as needed....so it could go all the way to label100 name100
  17. this is nowhere near correct, but how would I do a string like so: $item = "". $_POST['item']."".{$_POST['name']}." ".{$_POST['name']}."";
  18. hope this helps a bit. this is the problem area: $sql4 = mysql_query("SELECT * FROM labels where item_id='".$pid."'"); $counter = 0; while($row = mysql_fetch_array($sql4)){ $label =$row["label"]; $lid=$row['id']; $counter = $counter + 1; print $counter . "<BR>"; $item = $_POST['item']; } $date1234= date('m-d-y'); if($item ==''){$item=$dri;} // create row content $row = array( "date" => $date1234, "name" => $name, "item" => $item, "quantity" => $qty, "academy" => $academy, "paid" => 'yes' ); // insert new row $entryResult = $service->insertRow($row, $ssKey, $wsKey); } catch (Exception $e) { die('ERROR: ' . $e->getMessage()); }
  19. why is $item not submitting to google docs like it is supposed to? does it have something to do with how it is in a loop? <?php session_start(); require_once "connect.php"; if(isset($_SESSION['logged'])){ // Query member data from the database and ready it for display $cid = $_SESSION['complete']; $academy = $_SESSION['academy']; if($academy=="Old_Cheney"){$city= "Lincoln";}else if($academy=="Yankee_Hill"){$city= "Lincoln";}else if($academy=="Holdrege"){$city= "Lincoln";}else if($academy=="Maple"){$city= "Omaha";} else if($academy=="Center"){$city= "Omaha";} else if($academy=="PNS"){$city= "Pensacola";} $sql = mysql_query("SELECT * FROM login where academy ='$academy'"); while($row = mysql_fetch_array($sql)){ $date =$row["date"]; if ($date !=="".date('m-d-Y')){echo '<meta http-equiv="REFRESH" content="0;url=login.php">'; exit(); } } }else{ echo '<meta http-equiv="REFRESH" content="0;url=login.php">'; exit(); } echo $cid; echo $academy; echo $city; ?> <?php // load Zend Gdata libraries require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata_Spreadsheets'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); // set credentials for ClientLogin authentication $user = "blahb"; $pass = "password"; try { // connect to API $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME; $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); $service = new Zend_Gdata_Spreadsheets($client); // set target spreadsheet and worksheet $ssKey = '0AoUMgja4GxpJdFZwbn4444444XRU5pUlE'; $wsKey = 'od6'; $sql4 = mysql_query("SELECT * FROM labels where item_id='".$pid."'"); $counter = 0; while($row = mysql_fetch_array($sql4)){ $label =$row["label"]; $lid=$row['id']; $counter = $counter + 1; print $counter . "<BR>"; $item = $_POST['item']; } $date1234= date('m-d-y'); if($item ==''){$item=$dri;} // create row content $row = array( "date" => $date1234, "name" => $name, "item" => $item, "quantity" => $qty, "academy" => $academy, "paid" => 'yes' ); // insert new row $entryResult = $service->insertRow($row, $ssKey, $wsKey); } catch (Exception $e) { die('ERROR: ' . $e->getMessage()); } ?>
  20. one more quick question, how do I do this with proper syntax? $_POST['name$counter']
  21. thank you, I didn't even think about that! it is exactly what I want!
  22. how do I make $counter add one evertime it runs through the loop: <?php // Query member data from the database and ready it for display $sql4 = mysql_query("SELECT * FROM labels where item_id='".$pid."'"); $num_rows = mysql_num_rows($sql4); echo $num_rows; while($row = mysql_fetch_array($sql4)){ $label =$row["label"]; $lid=$row['id']; $counter = 0; $counter = $counter + 1; print $counter . "<BR>"; ?> <select name="name<?php echo $counter; ?>"> <?php echo $label; ?> currently, it says counter is 1 everytime
  23. so something like this is what would result $result= name[] name1[] name2[] name1[] name2[] name1[] name2[]
×
×
  • 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.