Page 1 of 1

Getting data from a form

Posted: Mon Jul 09, 2007 12:28 pm
by shuka
pickle | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi Guys,

Just started to learn PHP and am slowly getting to hang of it, have currently got a form that consists of tickbox, with each one with a different ID that is assigned by the database when it creates the form, as each form is different depending on the user.

How managed to get it to recoginse what the form elements ID are so it can request the correct form element,

so in a while statement am going throught the ID to get the data using the following

[syntax="php"]while($rowCheck = mysql_fetch_array($resCheck))
{
   $strValue = $_POST['$rowCheck[TaskID];'];
   echo $strValue; ?> </br> <?
}
$rowCheck[TaskID] is the ID of the form element am trying to get from the form

But this is not beginning anything back to the screen all am getting is a blank screen, hope someone can help me.

Cheers in advanced

Shuka


pickle | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Jul 09, 2007 12:32 pm
by TheMoose
Close, but your quotes are in the wrong positions.

Code: Select all

$strValue = $_POST[$rowCheck['TaskID']];

Posted: Mon Jul 09, 2007 12:36 pm
by shuka
That works!!! Cheers your a life saver that has driving me nuts for the last hour :D

Shuka

Posted: Mon Jul 09, 2007 1:13 pm
by shuka
got another problem when inserting into a mySQL database back end, i have a insert statement

Code: Select all

<? echo $insertTS = "INSERT INTO `Tasksheet` (`userid`, `taskdate`, `taskID`, `taskValue`) VALUES ('$rowUser[userID]', CURDATE( ) , `$rowCheck[TaskID]`, '$strValue')"; ?></br><?
am getting the following output

Code: Select all

INSERT INTO `Tasksheet` (`userid`, `taskdate`, `taskID`, `taskValue`) VALUES ('3', CURDATE( ) , `2`, '0')
Unknown column '2' in 'field list'INSERT INTO `Tasksheet` (`userid`, `taskdate`, `taskID`, `taskValue`) VALUES ('3', CURDATE( ) , `27`, '1')
Unknown column '27' in 'field list'INSERT INTO `Tasksheet` (`userid`, `taskdate`, `taskID`, `taskValue`) VALUES ('3', CURDATE( ) , `6`, '1')
Unknown column '6' in 'field list'INSERT INTO `Tasksheet` (`userid`, `taskdate`, `taskID`, `taskValue`) VALUES ('3', CURDATE( ) , `25`, '1')
Unknown column '25' in 'field list'INSERT INTO `Tasksheet` (`userid`, `taskdate`, `taskID`, `taskValue`) VALUES ('3', CURDATE( ) , `4`, '1')
Unknown column '4' in 'field list'INSERT INTO `Tasksheet` (`userid`, `taskdate`, `taskID`, `taskValue`) VALUES ('3', CURDATE( ) , `5`, '0')
Unknown column '5' in 'field list'
can't figure out why it is stating/thing that the number is a number when it is already state the field name is taskID

Cheers

Neil

Posted: Mon Jul 09, 2007 1:44 pm
by Begby
Try changing the backticks (`) to single quotes (') around the numberes that are triggering the error.