Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › Html form problem | Filter
New Posts  All Forums:Forum Nav:

Html form problem | Filter

post #1 of 7
Thread Starter 
Hi basically, im making a filter which is something like a shop would have.
Example: You click on the 1080p valued box and server automatically does filtering/sorting which products have that atribute value and displays them. But the problem im having is that id like the form to work in GET method to display the links that you are filtering. BUT, since the website page system works like this "www.example?page=filter" i cant "Save" it in the url because once user sets values that he/she wants the link changes to "www.example?resolution=1080p" And so im sent to homepage not the filter page.

Or mabey you know where can i learn to make that kind of filter, im open for that aswell.
Edited by Zvejniex - 10/25/13 at 4:21am
 
Old rig
(7 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core 4670k 4.6ghz @ 1.27v Gigabyte Z87-UD3H Nvidia MSI GTX 760 Sli - To be ordered Corsair Vengeance 8gb 1600mhz CL9 Single Channe... 
Hard DriveCoolingOSMonitor
1 TB WD 7200 RPM Hyper Evo 212 Push/Pull Win 8 Pro 64-bit Acer v223w 22 inches 
PowerCase
Corsair TX850 Cooler Master Gladiator 600 
CPUMotherboardGraphicsRAM
Intel E1400 945GCM-S2L Intel HD Junk Kingston 1gb 667mhz 
Hard DriveOSMonitor
Samsung 250gb Windows 7 Ultimate 64-bit HP w1907v 19 inches 
  hide details  
Reply
 
Old rig
(7 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core 4670k 4.6ghz @ 1.27v Gigabyte Z87-UD3H Nvidia MSI GTX 760 Sli - To be ordered Corsair Vengeance 8gb 1600mhz CL9 Single Channe... 
Hard DriveCoolingOSMonitor
1 TB WD 7200 RPM Hyper Evo 212 Push/Pull Win 8 Pro 64-bit Acer v223w 22 inches 
PowerCase
Corsair TX850 Cooler Master Gladiator 600 
CPUMotherboardGraphicsRAM
Intel E1400 945GCM-S2L Intel HD Junk Kingston 1gb 667mhz 
Hard DriveOSMonitor
Samsung 250gb Windows 7 Ultimate 64-bit HP w1907v 19 inches 
  hide details  
Reply
post #2 of 7
First off, there a lots of ways to do this, but I'll present just two for now. Any values in the URL string after a question mark (?) are variables in what's called the query string. The server can read these variables from the request, and can be used to modify the response to the user. If you need more than one variable, just use an ampersand (&) in between the variables and values to send across additional data. For example, if you want the filter page with a resolution of 1080p, you could write the url as such:

"www.example?page=filter&resolution=1080p"

That's the quick and dirty way to fit into your current solution. A better alternative would be to use AJAX with javascript, and then reload the data in the page with the response data.

In the future, you want to be more specific when you ask questions. These answers are the best I can give since I have no idea what language you are using, what your experience is, or why you are trying to solve this problem in the first place. Be as specific as you can, and you will find that people will be more willing to respond.

If you want to learn more, you can start reading the tutorials at http://www.w3schools.com/ and there's also http://www.codecademy.com/, which has excellent tutorials for web programming.

I doubt you will find anything that shows you exactly how to write what you need, at least based on what you are asking. You need to learn the foundations of the technology you are working with before you can really dive into proper solutions. If you start with codecademy.com first, and then go through w3schools, you should start to learn enough to ask better questions more closely related to what you need.
post #3 of 7
Thread Starter 
Hi ty for your answer. I know foundation and im capable writing simple php scripts. And i fully understand what i need to do here. I need to get the variables from the html filter or form if u will.. so that i can post them inside mysql query. The forms does post values that i need but the problem here is that i dont really know how to gather that data. I do understand that i need to use post or get method but i cant use get because i cant get all values it only gets the last value. Example. ?filter&id=1&id=3 get method would retrieve only nr 3. If i understand corretly then post method has the same problem. Ive heard you have to change form name to something like is_checked[] so its an array of values but then i lose the specific form names like resolution. And how will i be able to sort the data? Im sorry if you didnt understand me.. Im on my phone atm and dont have the script to show you. I will show you later.
Edited by Zvejniex - 10/25/13 at 10:40pm
 
Old rig
(7 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core 4670k 4.6ghz @ 1.27v Gigabyte Z87-UD3H Nvidia MSI GTX 760 Sli - To be ordered Corsair Vengeance 8gb 1600mhz CL9 Single Channe... 
Hard DriveCoolingOSMonitor
1 TB WD 7200 RPM Hyper Evo 212 Push/Pull Win 8 Pro 64-bit Acer v223w 22 inches 
PowerCase
Corsair TX850 Cooler Master Gladiator 600 
CPUMotherboardGraphicsRAM
Intel E1400 945GCM-S2L Intel HD Junk Kingston 1gb 667mhz 
Hard DriveOSMonitor
Samsung 250gb Windows 7 Ultimate 64-bit HP w1907v 19 inches 
  hide details  
Reply
 
Old rig
(7 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core 4670k 4.6ghz @ 1.27v Gigabyte Z87-UD3H Nvidia MSI GTX 760 Sli - To be ordered Corsair Vengeance 8gb 1600mhz CL9 Single Channe... 
Hard DriveCoolingOSMonitor
1 TB WD 7200 RPM Hyper Evo 212 Push/Pull Win 8 Pro 64-bit Acer v223w 22 inches 
PowerCase
Corsair TX850 Cooler Master Gladiator 600 
CPUMotherboardGraphicsRAM
Intel E1400 945GCM-S2L Intel HD Junk Kingston 1gb 667mhz 
Hard DriveOSMonitor
Samsung 250gb Windows 7 Ultimate 64-bit HP w1907v 19 inches 
  hide details  
Reply
post #4 of 7
Thread Starter 
Hello again, i managed to figure some stuff out, buti still have the same problem.
Is it possible that html form with get method doesnt reset the link? I need to add the variables the forms sends to the adress bar but it deletes every other variable in the url.
 
Old rig
(7 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core 4670k 4.6ghz @ 1.27v Gigabyte Z87-UD3H Nvidia MSI GTX 760 Sli - To be ordered Corsair Vengeance 8gb 1600mhz CL9 Single Channe... 
Hard DriveCoolingOSMonitor
1 TB WD 7200 RPM Hyper Evo 212 Push/Pull Win 8 Pro 64-bit Acer v223w 22 inches 
PowerCase
Corsair TX850 Cooler Master Gladiator 600 
CPUMotherboardGraphicsRAM
Intel E1400 945GCM-S2L Intel HD Junk Kingston 1gb 667mhz 
Hard DriveOSMonitor
Samsung 250gb Windows 7 Ultimate 64-bit HP w1907v 19 inches 
  hide details  
Reply
 
Old rig
(7 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core 4670k 4.6ghz @ 1.27v Gigabyte Z87-UD3H Nvidia MSI GTX 760 Sli - To be ordered Corsair Vengeance 8gb 1600mhz CL9 Single Channe... 
Hard DriveCoolingOSMonitor
1 TB WD 7200 RPM Hyper Evo 212 Push/Pull Win 8 Pro 64-bit Acer v223w 22 inches 
PowerCase
Corsair TX850 Cooler Master Gladiator 600 
CPUMotherboardGraphicsRAM
Intel E1400 945GCM-S2L Intel HD Junk Kingston 1gb 667mhz 
Hard DriveOSMonitor
Samsung 250gb Windows 7 Ultimate 64-bit HP w1907v 19 inches 
  hide details  
Reply
post #5 of 7
Maybe a hidden field called page and set it's value to filter so that it's always being sent.
Code:
<input type="hidden" name="page" value="filter" />
My System
(16 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 @ Stock Asus P6T ATI HD5870 OCZ 6GB 1333mhz 
Hard DriveHard DriveOptical DriveCooling
Samsung 840 Evo Caviar Black 640GB LG DVD Drive Cm Hyper 212+ 
CoolingOSMonitorPower
Arctic Cooling Accelero Twin Turbo II Windows 7 64bit ASUS VW246H Corsair HX850 
Case
CM 690 II Adavanced 
  hide details  
Reply
My System
(16 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 @ Stock Asus P6T ATI HD5870 OCZ 6GB 1333mhz 
Hard DriveHard DriveOptical DriveCooling
Samsung 840 Evo Caviar Black 640GB LG DVD Drive Cm Hyper 212+ 
CoolingOSMonitorPower
Arctic Cooling Accelero Twin Turbo II Windows 7 64bit ASUS VW246H Corsair HX850 
Case
CM 690 II Adavanced 
  hide details  
Reply
post #6 of 7
Thread Starter 
Ok very good.. Didnt cross my mind.. But is there a way to gather and process same variables with different values? So i can make a query for example these kind of get variables ?id=1&id=2
Basicaly its a filter with check boxes. I migh post pic of the form code and sruff when im on my pc. i know that it can be done if form input name is set as an array but can i set a variable as an array if its already holding a value? I guess not. And mabey you know how can the posted chekboxes stay checked if posted? By doing an if statement it checks if vatiable is set and if its set then input box is checked?
 
Old rig
(7 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core 4670k 4.6ghz @ 1.27v Gigabyte Z87-UD3H Nvidia MSI GTX 760 Sli - To be ordered Corsair Vengeance 8gb 1600mhz CL9 Single Channe... 
Hard DriveCoolingOSMonitor
1 TB WD 7200 RPM Hyper Evo 212 Push/Pull Win 8 Pro 64-bit Acer v223w 22 inches 
PowerCase
Corsair TX850 Cooler Master Gladiator 600 
CPUMotherboardGraphicsRAM
Intel E1400 945GCM-S2L Intel HD Junk Kingston 1gb 667mhz 
Hard DriveOSMonitor
Samsung 250gb Windows 7 Ultimate 64-bit HP w1907v 19 inches 
  hide details  
Reply
 
Old rig
(7 items)
 
 
CPUMotherboardGraphicsRAM
Intel Core 4670k 4.6ghz @ 1.27v Gigabyte Z87-UD3H Nvidia MSI GTX 760 Sli - To be ordered Corsair Vengeance 8gb 1600mhz CL9 Single Channe... 
Hard DriveCoolingOSMonitor
1 TB WD 7200 RPM Hyper Evo 212 Push/Pull Win 8 Pro 64-bit Acer v223w 22 inches 
PowerCase
Corsair TX850 Cooler Master Gladiator 600 
CPUMotherboardGraphicsRAM
Intel E1400 945GCM-S2L Intel HD Junk Kingston 1gb 667mhz 
Hard DriveOSMonitor
Samsung 250gb Windows 7 Ultimate 64-bit HP w1907v 19 inches 
  hide details  
Reply
post #7 of 7
Nope I don't think you can use the same name twice, I'd imagine it would only give the value of either the first or last element with that name.

To get the to stay checked you'd probably want to use ajax at some point. But if you just want the php way to do it:
Code:
<input type="checkbox" name="filter" id="filter" <?php if(isset($_GET['filter'])) echo 'checked="checked"'; ?>  />

So basically that checks if the form element is submitted, if it is it'll check it off.
My System
(16 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 @ Stock Asus P6T ATI HD5870 OCZ 6GB 1333mhz 
Hard DriveHard DriveOptical DriveCooling
Samsung 840 Evo Caviar Black 640GB LG DVD Drive Cm Hyper 212+ 
CoolingOSMonitorPower
Arctic Cooling Accelero Twin Turbo II Windows 7 64bit ASUS VW246H Corsair HX850 
Case
CM 690 II Adavanced 
  hide details  
Reply
My System
(16 items)
 
  
CPUMotherboardGraphicsRAM
i7 920 @ Stock Asus P6T ATI HD5870 OCZ 6GB 1333mhz 
Hard DriveHard DriveOptical DriveCooling
Samsung 840 Evo Caviar Black 640GB LG DVD Drive Cm Hyper 212+ 
CoolingOSMonitorPower
Arctic Cooling Accelero Twin Turbo II Windows 7 64bit ASUS VW246H Corsair HX850 
Case
CM 690 II Adavanced 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › Html form problem | Filter