Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 10-30-2011, 07:30 AM
kontrol's Avatar
kontrol kontrol is offline
Contributing Member
 
Join Date: 02-10-10
Posts: 223
iTrader: 0 / 0%
sorting variables

i have a for with 5 text fields. A user can fill at least 0 fields and proceed. What i want to is i want to sort these text fields and retrieve those ones the user filled and use them in an query.

PHP Code:
$_POST['fiield1'];
$_POST['field2'];
$_POST['field3'];
$_POST['field4'];
$_POST['field5'];
if(isset(
$_POST['submit'])){
// code to sort here 
//result here
//then work with it from here

 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 10-30-2011, 08:15 AM
ScriptMan's Avatar
ScriptMan ScriptMan is online now
Super Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 13,275
iTrader: 4 / 100%
Quote:
Originally Posted by kontrol View Post
i have a for with 5 text fields. A user can fill at least 0 fields and proceed. What i want to is i want to sort these text fields and retrieve those ones the user filled and use them in an query.

PHP Code:
$_POST['fiield1'];
$_POST['field2'];
$_POST['field3'];
$_POST['field4'];
$_POST['field5'];
if(isset(
$_POST['submit'])){
// code to sort here 
//result here
//then work with it from here


Remember that I only dabble in PHP.

Why bother to sort them?

PHP Code:
// initialize var 1-5 to 0 before starting 
// If $_POST['fieldX'] is not an empty string
// then $_POST['fieldx'] == var1;

Repeat for each $_POST

// Remove the vars that still == 0

// build the query with the remaining vars 

This may be a convoluted way to do this but it should work
 
Reply With Quote
  #3  
Old 10-30-2011, 11:33 AM
kontrol's Avatar
kontrol kontrol is offline
Contributing Member
 
Join Date: 02-10-10
Posts: 223
iTrader: 0 / 0%
thanks so much this will surely help me
 
Reply With Quote
  #4  
Old 10-30-2011, 02:03 PM
ScriptMan's Avatar
ScriptMan ScriptMan is online now
Super Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 13,275
iTrader: 4 / 100%
That initial var setting might be better set to an empty string instead of 0. Either should work. Initialization is not absolutely necessary with PHP but I like to do it anyway.
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
php: long variables with other variables which needs to be sent by email imadam Coding Forum 1 09-27-2011 06:14 PM
$variables... Midwifery Online Coding Forum 4 11-07-2010 11:41 PM
Sorting Through Old Pictures Cricket Digital Photography Forum 6 03-28-2010 11:37 PM
ASP File Sorting SN3 Web Design Lobby 9 09-12-2005 11:58 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 03:51 PM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC