472,352 Members | 1,560 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,352 software developers and data experts.

PHP mysql survey

I must build a survey with many question (around 50), so i cannot have the survey in just one page, i would like to have it on many pages so one user will hit submit many times, how can i make so in the database there's always one Row per user and not many rows as many submit per user?
Nov 16 '09 #1
4 3430
5,058 Expert 4TB

You can use the UPDATE command to do that.
Use INSERT on the first page and just UPDATE the row on the proceeding pages.
Nov 16 '09 #2
hi, yes but the action attribute of the form is another form so it wont complete the MSQL command:
<form method="post" action="Q2.php">
looks like i need to use sessions so i do all the SQL command on the last form/page
Nov 16 '09 #3
5,058 Expert 4TB
What do you mean?

You just use a different SQL query on each page...

Expand|Select|Wrap|Line Numbers
  1. <form action="page2.php" method="post">
  2.     <input type="text" name="first_info" />
  3.     <input type="submit" />
  4. </form>
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Get the data from the last form
  3. $first_info = mysql_real_escape_string($_POST['first_info']);
  5. // Insert a new row into the database
  6. $sql = "INSERT INTO tbl(first_info) VALUES('{$first_info}')";
  7. mysql_query($sql) or trigger_error(mysql_error(), U_USER_ERROR);
  9. // Get the ID of the row that was just created.
  10. $row_id = mysql_insert_id();
  11. ?>
  12. <form action="page3.php" method="post">
  13.     <input type="hidden" name="row_id" value="<?php echo $row_id; ?>" />
  14.     <input type="text" name="second_info" />
  15.     <input type="submit" />
  16. </form>
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Get the data from the last form
  3. $second_info = mysql_real_escape_string($_POST['second_info']);
  4. $row_id = mysql_real_escape_string($_POST['row_id'])
  6. // Update the row in the database with the new info
  7. $sql = "UPDATE tbl 
  8.         SET second_info='{$second_info}' 
  9.         WHERE row_id={$row_id}
  10.         LIMIT 1";
  11. mysql_query($sql) or trigger_error(mysql_error(), U_USER_ERROR);
  12. ?>
  13. <form action="page4.php" method="post">
  14.     <input type="hidden" name="row_id" value="<?php echo $row_id; ?>" />
  15.     <input type="text" name="third_info" />
  16.     <input type="submit" />
  17. </form>
Nov 17 '09 #4
thanks , i have just made something with session,i will check your version.
thanks again.
Nov 17 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Paris_Sucks | last post by:
I'm trying to redirect when testing for certain condidtions as shown below. When the conditions are ture, it redirects, but still goes ahead and...
by: GTF | last post by:
PHP Web Survey Idea.. I have been given an opportunity to create a web based survey. This is a fairly lengthy survey of 60 pages on paper...
by: Jon Dellaria | last post by:
I have been using MySql as the database using JSP's and JavaBeans but recently I have wanted to start using the database connection pooling ...
by: Mmm_moo_cows | last post by:
Hi, I'm new to the world of mysql and i'm having alot of trouble with it. All i want to do is create a page with a response form, e.g. name etc...
by: Sai Hertz And Control Systems | last post by:
Dear all, Their was a huge rore about MySQL recently for something in java functions now theirs one more ...
by: alf | last post by:
Hi, is it possible that due to OS crash or mysql itself crash or some e.g. SCSI failure to lose all the data stored in the table (let's say...
by: Miyagi | last post by:
I am running a custom setup that the workgroup here needs to run. IIS6 with Windows Server 2K3. PHP install was a little tricky but only required...
by: runsun | last post by:
I am new in PHP/Mysql. I want to input sth from website to mysql, then output the formatted data to .txt, and finally use Excel to open the .txt...
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.