Forum Moderators: coopster

Message Too Old, No Replies

column headers

         

triangulum

3:37 pm on Jun 13, 2006 (gmt 0)

10+ Year Member



I've set up a table in mysql using numbers as column headers, mysql will let me query and edit the table using the column numbers as reference but from php all i get is a syntax error. I've tried every escape sequence i can think of.

any suggestions.

eelixduppy

4:31 pm on Jun 13, 2006 (gmt 0)



Can you post the code that is producing the error, please? Maybe we can solve the solution or come up with a better method for what you are trying to accomplish ;)

mcavic

5:55 pm on Jun 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I suggest using column names such as f1, f2, etc to avoid confusion. Even if you get the numbers to work, it'll probably add confusion.

triangulum

6:14 pm on Jun 13, 2006 (gmt 0)

10+ Year Member



thanks for the replies. I've solved it by using the escape ` as opposed to '

I didn't use column names such as F1 because the table is a width x height table which I need to perform mathematical functions on in order to obtain a price. The code I used is;

$sql = "INSERT INTO vert_band_a SET

id='$id',
`50`='$fifty',
`70`='$seventy',
`90`='$ninety',
`110`='$oneten',
`130`='$onethirty',
etc....

The numbers represent cm's and are the headers for my columns. The $id represents cm's in the vertical column, that way I can return a price for example of 70cm x 70cm. As you can see, the price list I am working with is in bands.

I'm sure there's a better way of doing it and I hope you can enlighten me, but for now i'm bigged up that it works at all :)

mooger35

9:50 pm on Jun 13, 2006 (gmt 0)

10+ Year Member



if you have a width and height table why don't you have columns named `width` and `height`. Then populate the rows with the actual widths and heights?

or am I missing something?

triangulum

10:18 pm on Jun 13, 2006 (gmt 0)

10+ Year Member



the rows are populated with the prices.

mcavic

10:30 pm on Jun 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why not have the column headings: type, measurement, and price?

Type would be W or H, measurement would be the width or height, then the corresponding price.

Select the width and the price for that width, then select the height and the price for that height.

triangulum

10:35 pm on Jun 13, 2006 (gmt 0)

10+ Year Member



Because the price is a result of width x height so the table works by selecting the price WHERE width = height (id = column)