Categories And Automatic Sorting - without using SQL
moldboy
Jun 29 2005, 10:59 PM
Despite what you might think I don't want to have SQL involved in the solution, just a heads up.
So let's say I had a page with a table and 4 rows, on each row there was a dropdown box with the options A, and B, there was also a text box, with the option to type (obvously)
Now lets say I wanted the user to choose either A or B and enter a number in the box, then when they pressed submit on the next page the readout would be a: ______, and b:_____ where in the _______ there would be another number, infact the sum of the numbers on the other page.
So if they choose A) 3, a) 5 A) 8 3 then the results would be A: 16, and B: 3. The script added the two catagories independantly.
I laready know how to do input and output, just can't figure out how to tell the srcipt only to add the numbers of the individual catagories. This script would of corse need to be expanded for my purpose to hold many more numbers and several more catagories. Any thoughts?
Notice from BuffaloHELP & snlildude87:
BuffaloHELPE: Eited topic title (corrected a spelling) and added description.
So if they choose A) 3, a) 5 A) 8 b ) 3 then the results would be A: 16, and B: 3. The script added the two catagories independantly.
How is it that they can choose 3 different values for A and only 1 for B? And which is the number they're s'posed to have entered in the text box? I don't understand what you're trying to do here. I'm not too familiar with PHP syntax yet cos I usually code in ASP, but I woulda thought if you're adding the value of the dropdown to the value of what they've typed and then printing it on the next page that it would be: value of the dropdown form variable + value of the text form variable. That sounds pretty obvious so I'm guessing maybe you're asking something else but I can't figure that out.
Sorry for double posting but just been thinking about it a bit more and didn't notice the 4 rows in the table thing which means that there's 4 dropdowns and the values of all 4 get added together - is that right? If that's the case you could do it one of two ways: 1. Give each dropdown the same name and then the form value would become a comma-delimited string (eg 3,5,8). Then you could split the string into an array and then add the values. 2. Give each dropdown the same name but add 01, 02, 03 to the end of the names (eg form01, form02 etc.). Then you could use a loop where your counter equals the number at the end of the form name to add the values.
The above was just (what I thought to be) a simple example.
Yes there are four rows, and in each row there is a dropdown, and a textbox. For each row the dropdown would contain A, and B. These would be the catagories. Each text box would have a number, defined by the user. Now after entering (or before) the drop down would be choosen. All the numbers assigned to catagorie A would be added, and then independantly all the numbers assigned to catagorie B would be added. In the above example there would be only number assigned with B so there would be no adding, however there are three numbers assigned to catagorie A so there would be three numbers. My question was how to add them when there would be no predefined order, like we will do all the A's and then all the B's, there could be a few A's and a few B's scatered randomly. I was asking for insight simply because I want to do something simmilar, but rather then trying to explain that project to come up with a simple one.
You say that you are more into ASP, just for intrest, which would you say is better? How about learning curve?
You say that you are more into ASP, just for intrest, which would you say is better? How about learning curve?
I haven't done too much in depth with PHP yet but one thing I noticed pretty soon was how annoying it is if you missing out { or ; from your lines of code. It's easier to see when you've missed stuff out in ASP cos you're typing things like 'then' and 'end if' etc and the error messages tell you what's missing from the line that's wrong whereas PHP error messages tend to flow to the line where there is a closing ; or { which may not necessarily be the line that's wrong. I have no particular allegiance to either: had to learn ASP cos that's what our company's website is hosted on.
There probably is some kind of function that makes this alot easier, foreach won't work because you will need to create an array, wich in this case is not possible i think.
If you'are lazy people like me. This script may help u. This script is to automated our login to
some site. You must have cURL installed to use this script. CODE <?php // INIT CURL
$ch = curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch,
CURLOPT_URL, 'http://www.external-site.com/Members/Login.php'); // ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH
FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'fieldname1=fieldvalue1&fieldna...
hey ppl, u seem to have real gud knowledge about php, i just wanted a little help...i designed this
website, but i want that if i click on certain page, it should open for some few seconds and then
browser should automatically redirect me to some other page....i tried this with header() function
but i couldnt do the wait n redirect part, ... so somebody plz help.... -thanx in advance!...
This is what the script does: when a file is uploaded from a form, this script checks what directory
it should go into. So before the upload occurs, the alphanumeric directories are created ( only
once, of course). Here it is in code (Please note that this just example code): CODE
UPLOAD.PHP <?php echo "<form action='upload-sort.php' method='get'
enctype='multipart/form-data'>"; echo "Upload a file: <input
type='file' name='upload'>"; echo "</form>"; ?>
UPLOAD-SO...
Looking for categories, automatic, sorting, sql
Searching Video's for categories, automatic, sorting, sql
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE
forum, Create your own topics, Ask Questions, track topics, setup
subscriptions & notifications and Get a Free Website w/ Email and FTP.