Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

PHP Post Dynamic Data

Posted on 2006-06-29
5
658 Views
Last Modified: 2012-06-21
Hi Experts

I have a page which is dynamically created from data within a MySQL database (prs.php).  The table I get this data from is called ReturnItem, it has a primary key ReturnID which is an auto_increment integer.

I then have another table within the database called PRS which stores additional values about each ReturnItem record.

The prs.php page displays data from the returnitem table, then I need to add 3 textboxes for each ReturnItem record so users can add that data to the PRS table via a form Post method.

the prs.php form posts to prsadd.php

How do I send the form to another page and add each new record it to the PRS table with the proper ReturnID number???

Thanks in advance!

0
Comment
Question by:etechnicsit
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:dr_dedo
ID: 17014567
after inserting a new record in prs.php, use this function mysql_insert_id() to get its id
you can save that id as session variable $_SESSION ['returnID'] = mysql_insert_id(), or you can send it to the other page as quaery string

after db insert use
header ("Location: page2.php?id=".mysql_insert_id())

but better use session method, as to prevent security hazards!

good luck
0
 

Author Comment

by:etechnicsit
ID: 17014638
there will be about 40 returnid's

how would I id each text box so I know that it is from that particular record?
0
 

Author Comment

by:etechnicsit
ID: 17014646
ie this is the prs.php page

$rid $phone $model textbox1 textbox2 textbox3  - rid = 1
$rid $phone $model textbox1 textbox2 textbox3  - rid = 14
$rid $phone $model textbox1 textbox2 textbox3  - rid = 15
$rid $phone $model textbox1 textbox2 textbox3  - rid = 29

I need a way to ID each textbox, and to insert into db
0
 
LVL 16

Accepted Solution

by:
dr_dedo earned 500 total points
ID: 17014788
name your text boxes as array and give them rid as the key
$rid $phone $model textbox1[1] textbox2[1] textbox3[1]  - rid = 1
$rid $phone $model textbox1[14] textbox2[14] textbox3[14]  - rid = 14

in the next page, loop through these array
foreach ($_POST['textbox1'] as $key => $element) {
 $value1 = $_POST['textbox1'][$key];
 $value2 = $_POST['textbox2'][$key];
 $value3 = $_POST['textbox3'][$key];
}
0
 

Author Comment

by:etechnicsit
ID: 17014878
Your Amazing!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question