fezzik
Members-
Posts
42 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
fezzik's Achievements
Member (2/5)
0
Reputation
-
Can anyone list a link or resource with a good/correct tutorial about creating a session for a site with multiple users. I'm interested in also being able to manage the session length. Any help is appreciated. Cheers, Fezzik
-
Ignore this request. Issue solved. Thanks though!
-
I've been looking for help with creating a automatic popup for a page. Most resources I've found only show how to implement a popup window with a link/button. I would like to have the popup launch depending on the state of a session variable. The session variable would be either true or false. I appreciate any assistance or information about other possible resources. Cheers, Fezzik
-
This works: for ( $preloadCnt = 1; $preloadCnt <= 10; $preloadCnt ++ ) { $_SESSION['preloaded_name_'.$preloadCnt] = $_POST['preloaded_name'.$preloadCnt]; $_SESSION['preloaded_num_'.$preloadCnt] = $_POST['preloaded_num'.$preloadCnt]; }
-
Is it possble to use a for loop to create a series of variables and assign values to them? The below loop is incorrect. I'm attempting to assign $_SESSION['preloaded_name_X] = $preloaded_numX. X is equal to 1 thru 10. for ( $preloadCnt = 1; $preloadCnt <= 10; $preloadCnt ++ ) { $_SESSION['preloaded_name_'.$preloadCnt] = $preloaded_name.$preloadCnt; $_SESSION['preloaded_num_'.$preloadCnt] = $preloaded_num.$preloadCnt; } Any help is appreciated. Fezzik
-
Thanks! I just discovered this! Cheers, Fezzik
-
Thanks for the response. I believe that $_SESSION[$id] is not correct. I need to keep the $numbers[$id] as an array.
-
I need help with correctly rewriting the below script as a session variable, primarily the correct way to write $numbers[$id] as a session array: if (isset($numbers[$id])) { $numbers[$id] += $another_count; } else { $numbers[$id] = $another_count; } foreach($numbers as $key => $val) echo $key . ' : ' . $val . "<br />\r\n"; Thank you for any assistance! Fezzik
-
I need some help with creating a method to manage information from a form. The form has 2 input fields. The 1st field accepts a number similar to a sku or product code. The 2nd field accepts a number as a quantity. I think using a multidimensional array is a possible solution to store this data but I'm uncertain as to how to create the array and give it the desired functionality. One of the issues I'm trying to work out is that the form needs to allow the user to input the same product code multiple times. Since there is a count associated with each product code I would like matching product codes to have their count updated rather than being recorded as new entries. So there needs to be some sort of validation to see if the product code has already been entered. Sample data is as follows: Product Code(count) ------------------- 111222333(2) 444555666(1) 777888999(3) 111222333(2) I would like to store the data in the array as: Product Code(count) ------------------- 111222333(4) 444555666(1) 777888999(3) Any help is appreciated. If you need more information please let me know. A friend has helped by creating a untested ASP script that I'm trying to convert to PHP and test but I have been unsuccessful. [code] <% CONST COL_PNUM = 0 CONST COL_QTY = 1 Dim products Sub AddProduct( prodnum ) Dim row products = Session("Products") If Not IsArray(products) Then ReDim products( 1, 10 ) ' arbitrary size For row = 0 To 10 : products(COL_QTY,row) = 0 : Next End If ' See if we already have a product by that number For row = 0 To UBound(products,2) If products( COL_PNUM, row ) = prodnum Then ' found match...bump quantity products( COL_QTY, row ) = products( COL_QTY, row ) + 1 Session("products") = products ' save updated array Exit Sub ' and we are done End If Next ' no match found, so find an empty slot in array For row = 0 To UBound(products,2) If products( COL_QTY, row ) = 0 Then products( COL_PNUM, row ) = prodnum products( COL_QTY, row ) = 1 Session("products") = products ' save updated array Exit Sub ' and we are done End If Next ' no empty slot found...expand array newslot = UBDOUND(products,2) + 1 ReDim Preserve products( 1, newslot + 9 ) ' allow extra space ' zap the quantities in the new elements For row = newslot To UBOUND(products,2) : products(COL_QTY,row) = 0 : Next ' use the first slot for our new product products( COL_PNUM, newslot ) = prodnum products( COL_QTY, newslot ) = 1 Session("products") = products ' save updated array End Sub %> [/code] Cheers, Fezzik
-
I'm looking for assistance with creating a method that displays a total on a page without requiring form submission. Basically I have a list of items that are populated from a db query using php. I list the item name, quantity field, item price, item total and grand total. Similar to: Mishra's Workshop [INPUT QUANTITY] $250.00 [TOTAL] -------------------------------------------------------------- [GRAND TOTAL] When you change the quantity I would like the total to reflect the change without having to submit the form. I would also like the grand total to behave the same as total. Is it possible to use javascript to accomplish this? If so, can you please give me an example or a link with more details. If you need more information let me know. Cheers, Fezzik
-
Thanks sasa! This function is splendid! I've been trying to modify your function so that it lists all the $data_key's associated with the $group_key but have been unsuccessful. Is this easily accomplished with the function you provided? Cheers, Fezzik
-
Thanks for the responses. I'll see what I can come up with using your example.
-
Sure! So I have a multidimensional array of many rows and 5 columns per row. The data is similar to: $myArray[0][0] = "Autobots"; $myArray[0][1] = "Bumblebee"; $myArray[0][2] = "VW Bug"; $myArray[0][3] = "Yellow"; $myArray[0][4] = "Smog Check"; $myArray[0][0] = "Autobots"; $myArray[0][1] = "Jazz"; $myArray[0][2] = "Porsche"; $myArray[0][3] = "White"; $myArray[0][4] = "Steering Realignment"; $myArray[0][0] = "Autobots"; $myArray[0][1] = "Optimus Prime"; $myArray[0][2] = "Diesel"; $myArray[0][3] = "Red and Blue"; $myArray[0][4] = "Catalytic Converter"; $myArray[0][0] = "Decepticons"; $myArray[0][1] = "Starscream"; $myArray[0][2] = "Flying Machine"; $myArray[0][3] = "Red"; $myArray[0][4] = "Girly Voice"; $myArray[0][0] = "Decepticons"; $myArray[0][1] = "Megatron"; $myArray[0][2] = "Pea Shooter"; $myArray[0][3] = "Purple and Black"; $myArray[0][4] = "Everything"; I would like to create a function that will cycle through the array and print something similar to (grouping every row by the value of the 1st column): Autobots ----------------- Bumblebee Jazz Optimus Prime Decepticons ----------------- Megatron Starscream Thus grouping and ordering the information that is printed by the value of the first column of the row. Here is my coding attempt: [code] // region $previousRegion = ""; $currentRegion = ""; // company $currentCompany = ""; $previousCompany = ""; // counter $tradeCounter = 0; foreach ($tradeInfo as $book) { foreach ($book as $key => $value){ // region if ( $key == 0 ) { $currentRegion = $value; if ( $currentRegion != $previousRegion ) { if ( $tradeCounter != 0 ) { echo "<br />"; } echo "<strong>".$value."</strong><br /><br />"; $previousCompany = ""; } } // company if ( $key == 1 ) { $currentCompany = $value; if ( $currentCompany != $previousCompany ) { echo "<span style=\"font-weight:bold;color:#5d5d5d;\">".$value."</span><br /><br />"; } } if ( !empty($value) && $key != 0 && $key != 1) { echo "$value <br />\n"; } if ( $key == 0 ) { $previousRegion = $value; } if ( $key == 1 ) { $previousCompany = $value; } if ( $key == 4 ) { echo "<br />"; } $tradeCounter ++; } } [/code] The variable names in my code do not reflect the sample data which I provided in this post. This code is just a reflection of my attempt to sort the array using foreach() and print the information how I would like it arranged. I hope this is clearer. Please let me know if you need additional details. Thanks for your response. Cheers, Fezzik
-
I need help with how to accomplish the following... I have a multidimesional array with an unlimited number of rows and 5 columns called $myArray.The array is created from a database query. I would like to create 2 different displays from this array that are printed to a page. The first display would be grouping all rows which share the same value for a specified column (i.e. $myArray[$row][0]) and then printing them. Similar to: // array data $myArray[1][0] = "sifl"; $myArray[1][1] = "apple"; $myArray[2][0] = "olly"; $myArray[2][1] = "orange"; $myArray[3][0] = "sifl"; $myArray[3][1] = "pear"; $myArray[4][0] = "sifl"; $myArray[4][1] = "banana"; // printed output would look like sifl apple pear banana olly orange The second display would be similar but it would group rows which shared the same values for specified 2 columns. If anyone has the time to help me possibly create 2 functions to accomplish this task I would appreciate it. Any information is appreciated. Best, Fezzik