|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
"Insert into" problem
Hello, I'm a newbie hoping that anyone reading this may be willing to
help me with my problem. I'm making a database where my dad can store his records. I'm using a form with several sets of radio buttons, one for each record. To achieve this I've named each array with a counter, so the first button set is $kat0[0], set 2 is $kat1[0] and so on. I'm using the following code with a for loop to insert: for ($counter=0; $counter< $countrecs; $counter++) { INSERT INTO recs (id, kat) VALUES (NULL, '$kat$counter[0]') } But php refuses to read '$kat$counter[0]' as '$kat0[0]', as I want it to, instead it looks for $kat, then $counter[0] so I end up with 0[0] inserted into the database instead of the *real* variable from the form. I have tried using concatenation, still doesn't work because then php sees '$kat0[0]' as a STRING and simply inserts "$kat0[0]" into the database. How should I solve this? Any help would be very appreciated. Thank you for reading. L. |
|
#2
|
|||
|
|||
|
RE:
|
|
#3
|
|||
|
|||
|
RE:
Thanks I'll try that!
|
|
#4
|
|||||
|
|||||
|
RE:
The string variable idea was very close to working
if you have a string, '$kat0[0]' and want php to interpret it as a variable, you need to reference it via a holding variable with two dollar signs... like so: php Code:
Cheers, Keith. |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > "Insert into" problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|