|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I'm currently trying to develope a system that allows users to develop tests. These tests can range from 10 questions to 100 questions. To cope with the different size I setup each test as its own table.
Now to read the input from the forms generated by this test I am using a while loop: $TestData = @mssql_query("SELECT Id FROM Course$CourseId$TestType"); $Counter = 1; while ($TData = mssql_fetch_array($TestData)) { $QuestionId = htmlspecialchars($TData["Id"]); $Question$Counter = $_POST["$QuestionId"]; $Counter++; } How can I get the $QuestionId to be read as a number and not a variable. cause it spits back "..parse error, unexpected T_VARIABLE.." |
|
#2
|
|||
|
|||
|
what line is the problem at
|
|
#3
|
||||
|
||||
|
Your problem's in the second line within your while statement. You're jamming two variables together and trying to assign the $_POST value to the jammed-together variables. You'll need to use an array or something instead.
Incidentally, it's probably not the best idea to have a different table for each test. Better to have a test table that holds general info (title, etc.) and a questions table that has a test_id field for each row mapping the row's question to the given test. |
|
#4
|
|||
|
|||
|
The problem is with
$Question$Counter = $_POST["$QuestionId"]; |
|
#5
|
|||
|
|||
|
i have a poll script i wrote, if u want ill post it so u can get the basic idea of what houston was saying.
|
|
#6
|
|||
|
|||
|
Thanks I got it to work, also thanks for the advice on my database setup...
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Using a Variable in a $_POST |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|