Solved

PHP Post Dynamic Data

Posted on 2006-06-29
5
654 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Your Amazing!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
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.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now