[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

PHP Post Dynamic Data

Posted on 2006-06-29
5
Medium Priority
?
669 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
[X]
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
  • 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

656 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