Solved

PHP Post Dynamic Data

Posted on 2006-06-29
5
659 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

726 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