Forming an SQL query

From: Date: Tue, 02 Aug 2005 18:13:21 +0000
Subject: Forming an SQL query
Groups: php.general 
Request: Send a blank email to php-general+get-219852@lists.php.net to get a copy of this message
Hi, Thanks to everyone's help, that multipage monster of a form is now working properly (yay!). One problem I have though is that I stick the answers as each page is completed into a table. If the user hits the back button, rather than adding a new row to the table I'd rather update it if it's there. That's fairly straightforward when it's 1:1 questions to answers: $q_a_sql='INSERT INTO $userAnswerTable
                  ( q_id, a_id )
                  VALUES ' . (implode(",",$qanda))
                  . ' on duplicate key UPDATE a_id = VALUES(a_id);';
But when it's 1:n, such as with checkboxes, this neat little plan of mine is thwarted. So if I change the userAnswerTable to three columns, u_id, q_id and a_id, is there a way I can do all the 1:1 and 1:n in the manner I wish? TIA, JJ

« previous php.general (#219852) next »