Solved

PHP Post Dynamic Data

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

717 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