Jump to content

Scooby08

Members
  • Posts

    244
  • Joined

  • Last visited

Everything posted by Scooby08

  1. OH my goodness!! So simple.. That's all I was missing.. Thanks a bunch zanus!!
  2. Yes that is where I am stuck at.. I can get all but the tax into the query.. I do get a tax array, but I'm not sure how to break that apart to get the value for that field because its already in a loop.. I can do a separate loop, but dont know how to combine them.. Here is my code and query echoed: <?php if (isset($_POST['item_qty'])) { $item_qty = $_POST['item_qty']; $item_tax = $_POST['item_tax']; foreach ($item_qty as $key => $value) { if (!empty($value)) { $q = "INSERT INTO order_items (item_id, item_qty, item_tax) VALUES ('$key', '$value', '$item_tax') "; echo $q."<br />"; } } } ?> the echo: So I get the item_id, item_qty, but cannot figure out how to display the tax??
  3. I'm not really sure how to even explain this, but here goes.. I have a form dynamically built from the database that lists items for one to choose from.. Here is the part of the form I am having troubles writing an INSERT query for.. <form action="" method="post"> <label>Item 1 - </label> Qty <input type="text" name="item_qty[1]" width="35" /> Tax <select name="item_tax[1]"> <option value="">---</option> <option value="10">10%</option> </select><br /> <label>Item 2 - </label> Qty <input type="text" name="item_qty[2]" width="35" /> Tax <select name="item_tax[2]"> <option value="">---</option> <option value="10">10%</option> </select><br /> <label>Item 3 - </label> Qty <input type="text" name="item_qty[3]" width="35" /> Tax <select name="item_tax[3]"> <option value="">---</option> <option value="10">10%</option> </select><br /><br /> <input type="submit" name="submit" /> </form> The "1" in "item_qty[1]" is the item_id, and same for the others; "item_qty[2]", "item_qty[3]".. The thing is I need to loop through all items and find only ones with a quantity entered and insert those into the database, otherwise do nothing with them.. This is what the query eventually needs to be for only items with a quantity entered: $q = "INSERT INTO order_items (item_id, item_qty, item_tax) VALUES ('$item_id', '$item_qty', '$item_tax') "; Any ideas out there I can try?
  4. this line maybe?? <? include ('includes/thacofooter.php')?> needs a semi-colon?? <? include ('includes/thacofooter.php');?>
  5. Well I finally got something to work.. I had to add a slash and my domain name to the cookies like so: <?php /*SET COOKIE*/ setcookie("TestCookie[txt_user_name]", $txt_user_name, time() + 3600, "/", "domain_name.com"); setcookie("TestCookie[txt_user_password]", $txt_user_password, time() + 3600, "/", "domain_name.com"); /*EXPIRE COOKIE*/ setcookie("TestCookie[txt_user_name]", "", time() - 3600, "/", "domain_name.com"); setcookie("TestCookie[txt_user_password]", "", time() - 3600, "/", "domain_name.com"); ?>
  6. Yes that seems like it should work perfectly, but I'm still having no luck.. Is there anything else I could try to delete these cookies with??
  7. I have a simple user/login with remember me feature and everything seems to work except for when I log it, I believe it is supposed to remove the cookies, but I'm really not too sure if that is correct.. Need advice.. I create the cookies like so: <?php setcookie("TestCookie[txt_user_name]", $txt_user_name, time() + 3600); setcookie("TestCookie[txt_user_password]", $txt_user_password, time() + 3600); ?> My cookies array is like so: Array ( [TestCookie] => Array ( [txt_user_name] => admin [txt_user_password] => admin ) [phpSESSID] => 04m88l0st6c327njr3apu4fa16 ) Then for my logout code I am using this code: <?php session_unset(); session_destroy(); if (isset($_COOKIE['TestCookie'])) { $time = time(); setcookie("TestCookie[txt_user_name]", $time - 3600); setcookie("TestCookie[txt_user_password]", $time - 3600); } ?> Is this correct?? And if so, what is supposed to be happening?? I would assume that if I logged out I would then be directed to the login form, but this is not happening.. It always stays logged in..
  8. Excellent idea.. I do have a couple of problems with this still.. First, I get this error: Has something to do with this line: <?php $sql .= "$k = '" . mysql_real_escape_string($v) . "',"; ?> And the other problem is that there are a few different sections of fields on this page that need to be separate from each other.. Example, I have customer information that goes into the customers table, then company information that goes into another table, and a couple others as well.. How do I split up those $_POST into sections on this line: <?php foreach ($_POST as $k => $v) // need for each customer information fields value ?>
  9. I have a dynamically generated form from the database.. How can I write a dynamically generated update query using the database fieldnames? Here is what I have to select the fieldnames: <?php $query_field_ci = "SELECT field_form_name FROM dw_fields WHERE field_category = 'Customer Information' "; $result_field_ci = mysql_query($query_field_ci) or die(mysql_error()); while ($row_field_ci = mysql_fetch_array($result_field_ci)) { $customer_field_names[] = $row_field_ci['field_form_name']; } ?> The $customer_field_names array is like so: Array ( [0] => customer_firstname [1] => customer_lastname [2] => customer_address1 [3] => customer_address2 [4] => customer_city [5] => customer_state [6] => customer_zip [7] => customer_phone [8] => customer_email ) Now I just need to figure out how to put those into this update query: <?php $query_ci = "UPDATE dw_customers "; $query_ci .= "SET "; $query_ci .= " "; // lost here??? $query_ci .= "WHERE customer_id = '$_POST[customer_id]' "; ?> The final output would be something like so: <?php $query_ci = "UPDATE dw_customers "; $query_ci .= "SET "; $query_ci .= "customer_firstname = '$_POST[customer_firstname]',customer_lastname = '$_POST[customer_lastname]', ....... "; // like this, but not hardcoded.. to be pulled from database $query_ci .= "WHERE customer_id = '$_POST[customer_id]' "; ?> Hope this makes sense cuz I'm outta ideas.. Thanks
  10. I'm having a hard time figuring out how I can accomplish this.. I have a form that is dynamically generated from the database and has a foreach loop to display each field.. Now I'm working on the edit information form.. The problem is that I cannot figure out how to get the field values inserted into the dynamically generated form.. Below is the snipplet I'm working with: <?php // select values in database to display in the field values $query_ci = "SELECT firstname, lastname, email FROM dw_customers WHERE customer_id = '$customer_id' "; $result_ci = mysql_query($query_ci) or die(mysql_error()); while ($row_ci = mysql_fetch_array($result_ci)) { $field_values = $row_ci; // array of info I need inserted into the form values for each field } // select fieldnames to build dynamic form $query_fields = "SELECT * FROM dw_fields "; $result_fields = mysql_query($query_fields) or die(mysql_error()); $set_fields = array(); while ($row_fields = mysql_fetch_object($result_fields)) { $set_fields[$row_fields->field_category][] = $row_fields; } foreach ($set_fields as $field_category => $records) { ?> <fieldset class="fieldsetForm"> <legend><?=$field_category;?></legend> <div class="centerFormInfoWrap"> <?php foreach ($records as $row_fields) { ?> <label><?=$row_fields->field_name;?></label> <input type="<?=$row_fields->field_form_type;?>" name="<?=$row_fields->field_form_name;?>" value="" id="<?=$row_fields->field_form_name;?>" maxlength="<?=$row_fields->field_form_maxlength;?>" /><br /> <?php } ?> </div> <div class="clear"></div> </div> </fieldset> <?php } ?> From that first SELECT I made a foreach like so to display the values: <?php foreach ($field_values as $field_value) { echo $field_value; } ?> Works great by itself, but if I put that into the foreach that displays all the fields, then I get multiple displays of each field and values where as I just need one of each.. What might I need to do here??
  11. Yes you are correct.. My head was in the gutter.. Thanks for getting it out!
  12. I'm trying to trim this line: <?php $customer_field_values[] = '\'$_POST['.$row_customer_fields['field_form_name'].']\''; ?> Something like so: <?php $customer_field_values[] = trim('\'$_POST['.$row_customer_fields['field_form_name'].']\''); ?> Here is more of the code it's in if needed: <?php if (isset($_POST['submit'])) { $query_customer_fields = "SELECT field_form_name FROM dw_fields WHERE field_category = 'Customer Information' "; $result_customer_fields = mysql_query($query_customer_fields) or die(mysql_error()); while ($row_customer_fields = mysql_fetch_array($result_customer_fields)) { $customer_fields[] = $row_customer_fields['field_form_name']; $customer_field_values[] = '\'$_POST['.$row_customer_fields['field_form_name'].']\''; // trim these } $query_customers = "INSERT INTO dw_customers (".implode(",",$customer_fields).") "; $query_customers .= "VALUES (".implode(",",$customer_field_values).") "; $result_customers = mysql_query($query_customers) or die(mysql_error()); } ?> Not sure if it will work like this.. If not, what do I need to change??
  13. Thank you for that information.. It was exactly what I was looking for..
  14. This seems so simple, but I'm not coming up with anything.. On a form they have a choice to either choose an existing category that is in the database or create a new category.. For the existing categories I have a select dropdown list, and for the new category I just have a input text field.. The part I can't figure out how to do is this.. I named the select dropdown of all the categories "category".. Then I named the input field for the new category "new_category".. Like so.. <select name="category"> <option value="" selected="selected">Categories...</option> <option value="All categories in database loop">All categories in database loop</option> </select> <input type="text" name="new_category" /> Then I need to put which ever one they choose to use into this query: $query = "INSERT INTO dw_items (item_category) "; $query .= "VALUES ('$_POST[the category selected or created]') "; Also, how would I make it so they can only use one or the other? (select or input) Just looking for suggestions here.. Thank you much..
  15. Well I originally had it like so: <?php $date = $_POST['wedding_date']; $time = $_POST['wedding_time']; $wedding_date_time = date('Y-m-d H:i:s', strtotime ($date.' '.$time)); ?> but I just don't know how to get this to work into the array and thought it might be easier having them separately.. I will use any way that this can work.. The overall process of what I am trying to do might be able to be done differently??? I'm not sure, but this is the only way that I can think to get what I need done to work as of now: <?php if (isset($_POST['submit'])) { $query_weddings_columns = "SHOW COLUMNS FROM dw_weddings "; $result_weddings_columns = mysql_query($query_weddings_columns) or die(mysql_error()); while ($row_weddings_columns = mysql_fetch_object($result_weddings_columns)) { $wedding_columns .= $row_weddings_columns->Field.","; } foreach ($_POST['weddings'] as $wedding_field_data => $wedding_data) { $wedding_info .= "'".$wedding_data."',"; } $query_weddings = "INSERT INTO dw_weddings (".substr($wedding_columns,'',-1).") "; $query_weddings .= "VALUES ('','$customer_id',".substr($wedding_info,'',-1).") "; mysql_query($query_weddings) or die(mysql_error()); } ?> In the end I'm trying to have all my fields on the page totally editable and dynamic, so that this will work no matter how many fields there are and no matter what their names are...
  16. Ok so now how would I get that date and time into this array to work with this code? <?php // $_POST['weddings'] is the array from my first post foreach ($_POST['weddings'] as $wedding_field_data => $wedding_data) { $wedding_info .= "'".$wedding_data."',"; } $query_weddings = "INSERT INTO dw_weddings (".substr($wedding_columns,'',-1).") "; $query_weddings .= "VALUES ('','$customer_id',".substr($wedding_info,'',-1).") "; ?> Is it possible??
  17. If I had an array like this: Array ( [0] => Sunday, August 24, 2008 [1] => 2:34 AM [2] => field [3] => field [4] => field [5] => field [6] => field ) Is there a way that I can apply the code below to the date and time fields? $date = date('Y-m-d', strtotime ($date)); $time = date('H:i:s', strtotime ($time)); I'm trying to format those fields for the database like so: `date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', `time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
  18. I have a table in my database for all the field names that is editable, so I never know how many fields there will be.. You can add or delete rows.. I run my SELECT query to display them on the page, but I cannot think how I am supposed to write the INSERT INTO query when I don't know the how many there will be.. This INSERT INTO works right now for me, when I know what all the fields are, but if I add another field to the table this will not have that field in the INSERT INTO query.. <?php $query_customers = "INSERT INTO dw_customers (customer_name, customer_phone, customer_email) "; $query_customers .= "VALUES ('$_POST[customer_name]', '$_POST[customer_phone]', '$_POST[customer_email]') "; ?> How can that be written to insert all the fields information without knowing how many fields there will be, and do I need to create an array out of the fields like so: <input type="text" name="customers[]" /> <input type="text" name="customers[]" /> <input type="text" name="customers[]" /> or do I need to do something like this: <input type="text" name="customers_1" /> <input type="text" name="customers_2" /> <input type="text" name="customers_3" /> Any help getting me pointed into the right direction will be much appreciated.. Thanks..
  19. The array is quite large (115 items) so I'll just post some of it: Array ( [0] => 1 [item_id] => 1 [1] => wedding_packages [item_category] => wedding_packages [2] => Wedding Package Slice of Paradise [item_description] => Wedding Package Slice of Paradise [3] => 845 [item_price] => 845 ) Array ( [0] => 2 [item_id] => 2 [1] => wedding_packages [item_category] => wedding_packages [2] => Wedding Package Barefoot Bliss [item_description] => Wedding Package Barefoot Bliss [3] => 1245 [item_price] => 1245 ) Array ( [0] => 3 [item_id] => 3 [1] => floral_arrangements [item_category] => floral_arrangements [2] => Bridesmaid and Mother of the Bride Bouquet Tropical Large [item_description] => Bridesmaid and Mother of the Bride Bouquet Tropical Large [3] => 75 [item_price] => 75 ) Array ( [0] => 4 [item_id] => 4 [1] => floral_arrangements [item_category] => floral_arrangements [2] => Corsage Tropical [item_description] => Corsage Tropical [3] => 25 [item_price] => 25 ) Let me know if that is enough.. That is 4 items from 2 categories, which Im looking to try to output into 2 tables.. Each category having it's own table..
  20. I'm using a database table full of items that have different categories assigned to them sort of like so.. values are id, category, description, price INSERT INTO `dw_items` VALUES (18, 'wedding_aisle', 'Palm Frond', 50); INSERT INTO `dw_items` VALUES (19, 'wedding_aisle', 'Conch Shell', 75); INSERT INTO `dw_items` VALUES (20, 'wedding_aisle', 'Tropical Flowers', 275); INSERT INTO `dw_items` VALUES (21, 'wedding_circle_of_love', 'Palm Leaves', 195); INSERT INTO `dw_items` VALUES (22, 'wedding_circle_of_love', 'Conch Shells', 75); INSERT INTO `dw_items` VALUES (23, 'wedding_circle_of_love', 'Palm Leaves and Conch Shells', 95); INSERT INTO `dw_items` VALUES (24, 'wedding_arch', 'Palm Fronds and Tropical Flowers', 225); INSERT INTO `dw_items` VALUES (25, 'wedding_arch', 'Rustic Arch', 395); INSERT INTO `dw_items` VALUES (26, 'wedding_arch', 'Rustic Arch decorated with Tulle and Flowers', 495); Is there a way to print out the array and split each category into its own table?? I'm trying to figure this out because right now I have to run a separate query for each category in order to get them into their own tables..
  21. Somebody give this guy a raise!! haha Worked that time! thanks..
  22. Nothing seems to be showing up when trying those last couple of ways by akitchin. Here is all I get: <a href="?letter=A">A</a> <a href="?letter=B">B</a> <a href="?letter=C">C</a>
  23. I did check that.. here is what the code looks like (I just copied the first few): <a href="?letter=A" (A == "A")>A</a> <a href="?letter=B" (A == "B")>B</a> <a href="?letter=C" (A == "C")>C</a>
  24. The page seems to load alright with that code, but it's still not reading the class="current" for some reason??
×
×
  • 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.