mongoose00318
Members-
Posts
253 -
Joined
-
Last visited
Everything posted by mongoose00318
-
This is the specific code I am talking about...any ideas? // Add Items to New Order & Remove Items from Old Order $new_items = array(); foreach($prod as $p2) { for($i = 0; $i < $p2[0]; $i++) { if(!empty($_POST[$p2[3].'_'.$i])) { $new_items[$p2[3]]++; } } } The if will not recoginize that those checkboxes have been selected. Help!
-
I figured maybe if I post both files it would help more. split_order.php <?php session_start(); if(!isset($_SESSION['admin']) || $_SESSION['admin'] != 1) { //die("HELLOWORLD"); include('scripts/common_top.php'); header('Location: index.php'); die(); } if(empty($_GET['order_id']) || !is_numeric($_GET['order_id'])) { header("Location: admin.php"); die(); } $order_id = $_GET['order_id']; include('includes/header.inc.php'); $get_cust = @mysql_query("SELECT u.first_name, u.last_name FROM orders AS o LEFT JOIN users AS u ON o.customer_id = u.user_id WHERE o.order_id = $order_id"); $get_items = @mysql_query("SELECT oi.qty, oi.product_id, p.name FROM order_items AS oi LEFT JOIN products AS p USING (product_id) WHERE oi.order_id = $order_id"); $get_data = mysql_query("SELECT u.first_name, u.last_name, o.products FROM orders AS o LEFT JOIN users AS u ON o.customer_id = u.user_id WHERE o.order_id = $order_id"); $data = @mysql_fetch_assoc($get_data); $products = $data['products']; //breaking products text down for display $prod = array(); $_products = explode('|', $products); foreach ($_products AS $p) $prod[] = explode(',', $p); $items = array(); while(($row = @mysql_fetch_assoc($get_items)) !== false) { $items[] = $row; } /* $items = array( "qty"=>array( "1","2","3" ), "product_id"=>array( "1","2","3" ), "name"=>array( "Cleveland","Loretta","Junior" ) ); */ ?> <div id="banner_container"><img src="images/banner.jpg" /></div> <div id="wrap"> <div id="left_col"> <div class="title">Split Order</div> <div class="page_text"> <form name="splitOrder" id="splitOrder" action="processSplit.php" method="post"> <div style="width: 99%; height: 300px; overflow: auto; border: solid 1px #000; padding: 1%;"> <p> Split order for <?php echo ucwords($data['first_name'].' '.$data['last_name']); ?>.<br /> Which items go in the new order?<br /><br /> <?php if(!empty($prod)) { foreach($prod as $p2) { for($i = 0; $i < $p2[0]; $i++) { echo '<label><input class="splitOrderCheckbox" type="checkbox" value="1" name="'.$p2[3].'_'.$i.'" /> '.$p2[1].'</label><br />'; } } } ?> </p> </div> <p> <input type="submit" value="Continue" /> <input type="button" id="cancel" value="Cancel" /> <input type="hidden" name="order_id" value="<?php echo $order_id; ?>" /> </p> </form> </div> </div> <div id="right_col"> <?php include('includes/admin_right_menu.inc.php'); ?> </div> </div> <script type="text/javascript"><!-- document.getElementById("cancel").onclick = function() { window.location = 'tracking.php'; } --></script> <?php //include footer include('includes/footer.inc.php'); ?> processSplit.php <?php require('./scripts/common_top.php'); include('./scripts/dbconfig.php'); include('./scripts/get_cus_info.php'); // Get Old Order $get_order = @mysql_query("SELECT * FROM orders WHERE order_id = {$_POST['order_id']}"); $order = @mysql_fetch_assoc($get_order); // Get Old Order Items $products = $order['products']; //breaking products text down for display $prod = array(); $_products = explode('|', $products); foreach ($_products AS $p) $prod[] = explode(',', $p); /*OLD CODE $get_items = @mysql_query("SELECT product_id, qty FROM order_items WHERE order_id = {$order['order_id']}"); $items = array(); while(($row = @mysql_fetch_assoc($get_items)) !== false) { $items[] = $row; } */ if(empty($prod)) { header("Location: tracking.php"); die(); } /* // Create New Order @mysql_query("INSERT INTO orders SET customer_id = {$order['customer_id']}, order_status = {$order['order_status']}, order_date = '{$order['order_date']}', order_date_paid = '{$order['order_date_paid']}', order_shipping = '{$order['order_shipping']}', order_shipping_fee = '{$order['order_shipping_fee']}', order_insurance = '{$order['order_insurance']}', order_insurance_fee = '{$order['order_insurance_fee']}', order_insurance_total = '{$order['order_insurance_total']}', order_grand_total = '{$order['order_grand_total']}', order_date = '{$order['order_date']}', order_filled = '{$order['order_filled']}', order_ship_date = '{$order['ship_date']}'"); $get_new_order = @mysql_query("SELECT MAX(order_id) AS order_id FROM orders"); $new_order_id = @mysql_result($get_new_order, 'order_id', 0); */ // Add Items to New Order & Remove Items from Old Order $new_items = array(); foreach($prod as $p2) { for($i = 0; $i < $p2[0]; $i++) { //if(!empty($_POST[$p2[3].'_'.$i])) { $new_items[$p2[3]]++; //} } } if(isset($_POST['50_4'])) { echo "hi"; } foreach($prod as $p5) { for($j = 0; $j < $p5[0]; $j++) { if(isset($_POST[$p5[3]."_".$j])) { $new_items[$p2[3]]++; } } } echo "<pre>"; print_r($new_items); echo "</pre>"; die(); foreach($new_items as $product_id=>$qty) { @mysql_query("INSERT INTO order_items SET order_id = $new_order_id, product_id = $product_id, qty = $qty"); @mysql_query("UPDATE order_items SET qty = qty - $qty WHERE product_id = $product_id AND order_id = {$order['order_id']}"); } @mysql_query("DELETE FROM order_items WHERE qty = 0"); // Email Customer $get_customer = @mysql_query("SELECT u.email, u.first_name, u.last_name FROM orders AS o LEFT JOIN users AS u ON o.customer_id = u.user_id WHERE o.order_id = $new_order_id"); $customer = @mysql_fetch_assoc($get_customer); $get_old_products = @mysql_query("SELECT oi.qty, p.name FROM order_items AS oi LEFT JOIN products AS p USING (product_id) WHERE order_id = {$order['order_id']}"); $get_new_products = @mysql_query("SELECT oi.qty, p.name FROM order_items AS oi LEFT JOIN products AS p USING (product_id) WHERE order_id = $new_order_id"); //include the sc_send_email function include('includes/functions.inc.php'); //set the email vars $a_from = $admin_from_email; $a_to = $customer['email']; $a_cus_fname = ucfirst($customer['first_name']); $a_cus_lname = ucfirst($customer['last_name']); $a_subject = "Research Chemical | Your Research Chemical Order"; $a_message = " <br><br>Dear ".$a_cus_fname." ".$a_cus_lname.",<br><br>Your order has been split and will be sent in 2 separate shipments.<br><br>Your first shipment will be:<br><br> <b>Qty - Product Ordered</b><br> "; while(($row = @mysql_fetch_assoc($get_old_products)) !== false) { $a_message .= $row['qty'].' - '.$row['name']."<br>"; } $a_message .= "<br>Your second shipment will be:<br><br>"; $a_message .= "<b>Qty - Product Ordered</b><br>"; while(($row = @mysql_fetch_assoc($get_new_products)) !== false) { $a_message .= $row['qty'].' - '.$row['name']."<br>"; } $a_message .= "<br>We apologize for any inconvenience and are working to get your orders out as quickly as possible. You will not be charged for the added shipping cost. We will cover that expense as a gesture of good will.<br><br>"; $a_message .= "Thank You,<br>Customer Service<br>www.researchchemical.org"; $return_url = NULL; //echo $a_cus_lname; //echo $a_message; //send the email and redirect the user with a message sc_send_email($a_from, $a_to, $a_cus_fname, $a_cus_lname, $a_subject, $a_message, $source_url, $return_url); /* $message = "Dear {$customer['first_name']},\n\nYour order has been split and will be sent in 2 separate shipments.\n\nYour first shipment will be:\n\n"; while(($row = @mysql_fetch_assoc($get_old_products)) !== false) { $message .= $row['qty'].' : '.$row['name']."\n"; } $message .= "\nYour second shipment will be:\n\n"; $message .= "<b>Quantity Ordered - Product Ordered</b><br>"; while(($row = @mysql_fetch_assoc($get_new_products)) !== false) { $message .= $row['qty'].' : '.$row['name']."\n"; } $message .= "\nWe apologize for any inconvenience and are working to get your orders out as quickly as possible. You will not be charged for the added shipping cost. We will cover that expense as a gesture of good will.\n\nThank You,\nCustomer Service\nwww.researchchemical.org"; $headers = 'From: '."$admin_email\r\n".'Reply-To: '."$admin_email\r\n" .'X-Mailer: PHP/' . phpversion(); @mail($customer['email'], 'Your Research Chemical Order', $message, $headers); */ // Redirect header("Location: tracking.php"); die(); Please let me know if I can provide anything else
-
Try this : 1) Remove the require_once() 2) Paste your upload file inplace of the require_once() 3) Instead of having if(isset($_POST['submitBtn'])) try this if(isset($_POST)) Let me know if that helps or not
-
Hello all! I have a page that dynamically generates checkboxes in a for() loop if $i<$product_qty, while it is generating the checkboxes the name for them is set like this $product_id_$i. In part of the next page that processes the checkboxes, I have a part that regenerates the names for those checkboxes using a for() loop again and the product_qty and then checks to see whether the checkbox is empty or not. Everything looks right in the for() loop, yet the if() that checks whether it isset or not just ignores the ones that are set. If I make a static if with the actual name of the checkbox the if() comes back as true. I've hit a brickwall, can anyone see any errors in my code? Code is below. // Get Old Order $get_order = @mysql_query("SELECT * FROM orders WHERE order_id = {$_POST['order_id']}"); $order = @mysql_fetch_assoc($get_order); // Get Old Order Items $products = $order['products']; //breaking products text down for display $prod = array(); $_products = explode('|', $products); foreach ($_products AS $p) $prod[] = explode(',', $p); if(empty($prod)) { header("Location: tracking.php"); die(); } /* // Create New Order @mysql_query("INSERT INTO orders SET customer_id = {$order['customer_id']}, order_status = {$order['order_status']}, order_date = '{$order['order_date']}', order_date_paid = '{$order['order_date_paid']}', order_shipping = '{$order['order_shipping']}', order_shipping_fee = '{$order['order_shipping_fee']}', order_insurance = '{$order['order_insurance']}', order_insurance_fee = '{$order['order_insurance_fee']}', order_insurance_total = '{$order['order_insurance_total']}', order_grand_total = '{$order['order_grand_total']}', order_date = '{$order['order_date']}', order_filled = '{$order['order_filled']}', order_ship_date = '{$order['ship_date']}'"); $get_new_order = @mysql_query("SELECT MAX(order_id) AS order_id FROM orders"); $new_order_id = @mysql_result($get_new_order, 'order_id', 0); */ // Add Items to New Order & Remove Items from Old Order $new_items = array(); foreach($prod as $p2) { for($i = 0; $i < $p2[0]; $i++) { if(!empty($_POST[$p2[3].'_'.$i])) { $new_items[$p2[3]]++; } } } if(isset($_POST['50_4'])) { echo "hi"; } TIA! Jonathan
-
taking a delimited list and putting it into an array
mongoose00318 replied to mongoose00318's topic in PHP Coding Help
Mark as solved! -
taking a delimited list and putting it into an array
mongoose00318 replied to mongoose00318's topic in PHP Coding Help
Your a miracle worker simshaun! Thanks so much! I wish I could have figured that out... -
taking a delimited list and putting it into an array
mongoose00318 replied to mongoose00318's topic in PHP Coding Help
foreach($products1 as $p) { $products2 = explode(",", $p); $count = 1; foreach($products2 as $p2) { if($count <= 2) { echo $p2." | "; $count++; } else { echo $p2."<br>"; $count = 1; } } } That code above successfully processes the delimited list I have, is there a way I can modify that to make the array I need? Any advice would be helpful! Thanks alot! -
taking a delimited list and putting it into an array
mongoose00318 posted a topic in PHP Coding Help
Hi all! Ok I am trying to put a delimited list like so , EX. item qty, item name, item price | item qty, item name, item price | item qty, item name, item price | etc. into an array so I can access it like this - $product[0] = qty, $product[1] = name, etc. My code just isnt working. This is what I have so far. $prod = array(); //breaking products text down for display $products1 = explode("|", $products); $num_prod1 = count($products1); $count = 0; foreach($products1 as $p) { $prod[] = $p; $products2 = explode(",", $p); foreach($products2 as $p2) { $prod[$count] = $prod[$count][$p2]; } $count++; } -
yep as long as date is your field in the db that holds the date.
-
ya it turns out the (date_column) was just the database field that you have the date stored in...just for future reference
-
Yes I found that code. I edited it a bit and it is pulling just the certain month from the db. Pretty cool, that is one piece to the puzzle of what I am trying to create. I am going leave it at that for the night heh but thank you, you helped out alot! I will continue on tomorrow.
-
Hm, a thought came to mind. Could you do something like this? $current_month = 1; while($current_month <= 12) { mysql_query = "SELECT * FROM blog WHERE date_entered='$current_month'"; //echo results $current_month++; } Except I don't know how I could compare the $current_month to a timestamps month. Would this work if it was correctly written, if so how would I compare the months?
-
header("Location: /profile.php?id=$profileID"); Does that line of code need to be... header("Location: ../profile.php?id=$profileID"); ..perhaps? It is hard to tell since I can't see your file directory.
-
Lol no problem so are mine, that's why I am in here I appreciate your advice anyways.
-
Hm..interesting I think that would work. I wonder if there is a more efficent way to do it with a loop using the timestamp already in the database?
-
No, that wouldn't work I don't think because say it has been a year from the first post then the newest and oldest ID would be associated with the same month. I have the dates stored with a UNIX timestamp in the database. I am just wondering if there is a way to do something like... if(date(m) == 1) { echo date(); } I don't know?
-
Do I post my questions wrong or something? I seem to get limited or no answers at all when I post
-
Hey all! I was wondering how I would go about categorizing entries from a database by date? Say like this... January -------- Article 1 Article 2 Febuary -------- Article 1 Article 2 etc.. I figure there would be some kind of loop or a conditional statement to make it happen but I have no clue how to do either on a date/timestamp. ??? Any suggestions?
-
I managed to fix it! Thanks for all the help guys. I will be using this forum alot more often.
-
I tryed that and now I am getting a syntax error with a bracket somewhere. I can't even find where the syntax error is now. This is so frustrating.. ??? I always seem to get horrible at coding when I get overwhelmed or have been doing it all day. I guess that is why I am more dominanat as a designer heh. Would it help if you have my whole file? I have .rar'ed it up and put it up if that might help. http://www.tristonehomes.com/inventory.rar And this is the syntax error I am getting... Parse error: syntax error, unexpected '{' in /home/tristone/public_html/inventory.php on line 87 Let me know if that helps. Thanks so much for the help!
-
Not really, I am still kind of confused. I was barely able to make that script..it's pretty complex to me. Is there anyway you could explain in more detail? Sorry, I am still kind of new to php.
-
It is grabbing both. Here is that code. $result = mysql_query("SELECT communities.name, communities.city AS c_city, communities.state AS c_state, communities.price_range AS c_price_range, communities.features AS c_features, communities.id AS c_id, communities.phone AS c_phone, communities.email AS c_email, communities.directions AS c_directions, communities.description AS c_description, listings.title, listings.city AS l_city, listings.id AS l_id, listings.state AS l_state, listings.sq_ft AS l_sq_ft, listings.price AS l_price FROM communities, listings WHERE (communities.id = listings.community_id) && (listings.quick_movein = 'Yes') ORDER BY communities.id ASC"); $number_of_listings = mysql_num_rows($result); if($number_of_listings > 0) { while($row = mysql_fetch_array($result)) { //then the code that I had in my previous code
-
This is part to a dynamic page I made. It retrieves information from a database and then displays it. It retrieves communitys and then it retrieves the listings and puts each listing it pulls with the community it belongs to. The way it should display in a simplified format is below : Community 1 <table starts> <tr> <td>Listing 1</td> <td>Listing 2</td> </tr> </table ends> Community 2 <table starts> <tr> <td>Listing 1</td> <td>Listing 2</td> </tr> </table ends> etc... But it is doing.. Community 1 <table starts> <tr> <td>Listing 1</td> </tr> </table ends> <table starts> <tr> <td>Listing 2</td> </tr> </table ends> Community 2 <table starts> <tr> <td>Listing 1</td> </tr> </table ends> <table starts> <tr> <td>Listing 2</td> </tr> </table ends> I know it is doing this because the echo '</table>'; is inside of the while(); loop. But I can't figure out how to make it put the </table> after it is done echoing all the listings for a community. Any help? I hope I have been specific enough. Thanks! Also, you can view the live script here...http://www.tristonehomes.com/inventory.php while($row = mysql_fetch_array($result)) { if($row['name'] != $current_community) { $current_community = $row['name']; echo(' <br> <span class="community_title">'.ucfirst($current_community).'</span> <span class="location">'.ucfirst($row['c_city']).', '.ucfirst($row['c_state']).'</span> <div class="divider"></div> <span class="general_info">Price Range:</span> <span class="general_values">'.ucfirst($row['c_price_range']).'</span><span class="general_info">Phone:</span> <span class="general_values">'.$row['c_phone'].'</span><span class="general_info">Email:</span> <a href="mailto:'.$row['c_email'].'" class="email_link">'.$row['c_email'].'</a> <div class="general_links_container"> <a href="community_features/'.$row['c_features'].'" class="general_links">Standard Features</a> | <a href="view_inventory.php?community_id='.$row['c_id'].'" class="general_links">View Current Inventory</a> | <a href="directions/'.$row['c_directions'].'" class="general_links">Community Details / Directions</a> </div> <span class="general_info">Community Summary</span> <br /> <span class="community_summary">'.ucfirst($row['c_description']).'</span> <div class="divider"></div> <span class="floorplan_title">Floorplans</span> <span class="general_info">click on plan name for details</span> <br /> <table border="0" cellspacing="0" cellpadding="0"> '); $tracker = 0; } $title = strtolower($row['title']); $tracker = 1 - $tracker; echo '<tr class="row'.$tracker.'"><td class="cell_spacing"><a href="view_listing.php?listing_number='.$row['l_id'].'" class="specfic_info">'.ucfirst($title).'</a></td>'; echo '<td class="cell_spacing"><span class="specfic_info">Square Footage : '.ucfirst($row['l_sq_ft']).'</span><br></td>'; echo '<td class="cell_spacing"><span class="specfic_info">Base Price : $'.ucfirst($row['l_price']).'</span><br></td></tr>'; echo '</table>'; }