473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to pass a numeric value as $9 = $_POST["Queensland"];

4
Hi
I am having a bizarre problem with something so simple.

I have a form that has a variables with numbers "9", "12" and "13" etc.. I can't seem to post the value using
Expand|Select|Wrap|Line Numbers
  1.    $9 = $_POST["Queensland"]; 
etc. as PHP not accepting << $9 >> as the variable.

What I need once the form posts the value, on the second page I want to be able to display the one of the selected value as Queensland or New South Wales or ACT .

Now the second problem I can see because numbers entered as the "value" represents the Freight in Dollars and some of the values are the same. In view of this I want to display the correct STATE names when they are selected on my second page following my form.

So if someone selects "Queensland" then I want to be able to pass this as "Queensland" to the second page. I don't want to change the numerical values because they are working at the moment to calculate the freight user selects depending on the STATE they select.

I would very much appreciate a solution to this.Please if you don't my give me the complete solution as I am not much of an expert in PHP or java.

Thanks


In the form I have STATE names as follows -
Expand|Select|Wrap|Line Numbers
  1.   <select name="freight_fee_($)" class="field select medium" id="freight_fee_($)"  tabindex="14" >
  2.     <option value="9">Queensland</option>
  3.     <option value="12">New South Wales</option>
  4.     <option value="12">ACT</option>
  5.     <option value="13">Victoria</option>
  6.     <option value="14">South Australia</option>
  7.     <option value="16">Western Australia</option>
  8.     <option value="15">Northern Territory</option>
  9.     <option value="15">Tasmania</option>
  10.   </select>
Jul 22 '10 #1
5 1774
TheServant
1,168 Expert 1GB
You cannot name your variables starting with numbers.
You may start with an underscore if you are morally opposed to letters: $_9

For you second problem, let me give another suggestion. You don't really want to tie your state with the freight like that. If that is where you are defining your freight and I do some very easy manipulation, I think that I could make your program register to send me something for $0 freight. You also cannot send two values as one (atleast without using arrays).

Another approach would be to give a number to each state, or have the state codes (QLD, NSW, SA, etc) as your values, which is further processed in your processing script which keeps the $'s away from your users. With regards to showing users the freight, either have a static HTML list which they can look at, or write a simple javascript which will change the value of a uneditable input box, or even a HTML text block to the freight depending on the state selected.

Hope that helps.
Jul 22 '10 #2
oavs
4
Thanks I know I have done it the wrong way but took me a whole week to get it to work and I am not going to change unless someone shows me in detail. I am not opposed to under scores $_9 but if I do that on my first form then it will not do the calculation.

Have a look at the site first before you comment to see how it works. http://www.photooncanvas.com.au/step-1.php


Those STATE values are part of the on screen calculation. Not sure how else I could achieve what I have so far.

Thanks you for your advise
Jul 22 '10 #3
zorgi
431 Expert 256MB
Thanks I know I have done it the wrong way but ...
My teacher would say: "No buts. Go back and fix it than."

:)

..took me a whole week to get it to work and I am not going to change unless someone shows me in detail...
Its simple really. $9 is wrong as TheServant already pointed out and its not going to work.

Looking at your code I would first change this:

Expand|Select|Wrap|Line Numbers
  1. <select name="freight_fee_($)"...
  2.  
into somethin like this:

Expand|Select|Wrap|Line Numbers
  1. <select name="freight_fee" ...
  2.  
and this:

Expand|Select|Wrap|Line Numbers
  1. <option value="9">Queensland</option>
  2.  
into something like this:

Expand|Select|Wrap|Line Numbers
  1. <option value="Queensland">Queensland</option>
  2. .
  3. .
  4. .
  5. <option value="ACT">ACT</option>
  6. .
  7. .
  8.  
So when your user selects lets say "Queensland" and submits the form your $_POST['freight_fee'] would be "Queensland" or if your user selects "ACT" your $_POST['freight_fee'] would be "ACT". Basicly whatever is selected now is stored in $_POST['freight_fee']. Now you can use some if else or switch blocks or maybe some other ways to find out costs.
Jul 22 '10 #4
oavs
4
Ok Thanks. But ..but.. that's not going to work as I have calculations on the first form based on the STATE selection which adds to the final amount before it is posted to the next page.

I understand what you are saying in regards to matching the value with the name and that is how I would have done it normally but because the freight depends on which STATE it is selected that is why I ended up doing the way it is now.

Now you can use some if else or switch blocks or maybe some other ways to find out costs.
that is the answer I am looking for.

Thanks
Jul 22 '10 #5
dlite922
1,584 Expert 1GB
@oavs

that is the answer I am looking for.
What? if and else statements? He's just saying that you should use logic to control flow of your program.

Those are like bricks, not the solution, the solution depends on what you need it to do.

Dan
Jul 22 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Iona | last post by:
okay.. this should be long.. I made up a table in database with access consists of columns with text type. Some of them I put in data with numeric value and some of them I put in "Unlimited" as...
5
by: ief | last post by:
hi all, i'm trying to check the length of a numeric value in a string. this is what i need to do: I have a string "Mystring (253)" and a string "SecondString (31548745754)" Now i have to...
1
by: Luigi Ida' via SQLMonster.com | last post by:
Hi, I have a php application connected through odbc to a sqlserver database. When I try to execute select queries on a smalldatetime table field I receive this message: Warning: Numeric value...
3
by: eric_caron_31 | last post by:
Here's my problem, I read numeric value and I want to display this value like this : 123 678. Value read : 123678 Value display : 123 678 I want space for separator thanks for your help
5
by: Reny | last post by:
can any one tell how can i restrict my user to type just numeric character in the textbox.I am using VS.NET 2003 (VB.NET)
1
by: pchadha20 | last post by:
How to single numeric values from a field in a table which has multiple numeric value in a field of a table.And that table contains thousands of records. Suppose we have a table customer having...
13
by: nishit.gupta | last post by:
Is their any fuction available in C++ that can determine that a string contains a numeric value. The value cabn be in hex, int, float. i.e. "1256" , "123.566" , "0xffff" Thnx
1
by: karthik2423 | last post by:
Hi, Please let me know how I can accomplish the following task - "Ask the user to enter a number". Check whether the user has entered only numeric values. If he/she enters any character other...
6
by: frohlinger | last post by:
Hi, I need to perform some numeric calculations on a numeric float value, that is received as wstring. I would like to perform a check before converting the wstring to float, checking that indeed...
2
by: tron_23 | last post by:
hi, we use Toplink (TopLink - 4.6.0 (Build 417) with a DB2 Database 7.2. i know really old versions, but we could change to e newer one ;-) Sometimes we got some problems with update or insert...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.