77928490 Wrote:
-------------------------------------------------------
> Hi Mac,
>
> My question is about the primary/foreign key
> passed between the two tables, i.e.:
> 'tblquestions' and 'answers' in this section.
>
> In tablquestions it is quite clear how question 4
> is pulled from the table,i.e. include
> 'sqlSurvey.php';.
>
It can be confusing (and is).... best way is to run it all as opposed to just reading through it (not saying that is what you are doing).
Add the Vote to the Database page explains it, although they acknowledge that they are taking shortcuts
Language: PHP
$selected_radio = $_GET[';q';];
// This just gets which radio button was clicked. The value comes from the HTML form, and will be A, B or C. This is then placed into the variable called $selected_radio.
// $selected_radio will then have the value A or B or C
$SQL = "UPDATE answers SET $selected_radio = $selected_radio + 1";
//e.g. SET $selected_radio =.... is now SET A =.....
$SQL = "UPDATE answers SET A = $selected_radio + 1";