Thank you very much, Mike. I'm working on your suggestions now. Kosuke ----- Original Message ----- From: Mike Franks To: [email protected] Sent: Sunday, July 03, 2005 12:27 PM Subject: Re: [php-list] info transfer to database problem
On 7/2/2005, "Kosuke" <[EMAIL PROTECTED]> wrote: > > >Hello, I'm new to this list. I'm a multimedia designer doing mainly animation, web design, video editing, etc. Now as part of a project I'm doing, I have to create a database using PhP and mySQL. I'm quite new to programming so if anyone can help me with the following problem, I'd really appreciate it. > >I made two pages. One is HTML for a FORM which sends information to another PHP page which then accesses a table in a database. The PHP page connects to the database and retrieves the data from the table. This code <?php echo $row['test_1']?> makes the data appear on the page. It works this far. However what I'd like to know is how I can transfer the information of $row['test_1'] to a different page and also record the data to another table. > >I've tried many ways but still haven't got a clue. If anyone has got a tip, please help > >Thanks, > >Kosuke > Kosuke - there are many good tutorials and references on the web regarding both PHP and MySQL. It will be difficult in a short email to give specific answers to your questions. As with so many things, Google is your friend. It is encouraging that you've managed to write a form and fetch the data from your data base. It indicates you know how to open a connection to a database, fetch a row, and display data from that row. Passing data to another page can be accomplished in (at least) 4 ways: 1) Store the data in a session variable (search Google for PHP session variables). On the subsequent page, fetch the data from session. Think of session variables as values passed in cookies. 2) If you're using a form submit button to go from the 2nd page to the 3rd page, you can pass the data in a hidden field: <form ...> <input type=hidden value=<?php echo $dataValue ?>> ... </form> 3) If you're using a link to go to the 3rd page, you could pass the data as part of the link: http://www...../3rdPage.php?dataValue=<?php echo $dataValue ?> This has many drawbacks too numerous to mention, not the least of which is the data must be encoded if it contains any spaces, special characters or other punctuation. I do not recommend this option! 4) Refetch the data on the 3rd page. Which means, you still have to pass the values necessary to refetch the data, using one of the above 3 methods. I strongly favor option 2 if you're using a form anyway, option 1 otherwise. *** Re: storing data in second table, is the target table in the same data base or an alternate data base? If same data base, simply Insert the data into the desired table (search Google for MySQL INSERT). If alternate data base, first open the data base, then INSERT the record. When you do the insert depends on when you've collected all the necessary information to complete the new record in the desired table. If you have the necessary data from the first page, store the data on the second page before the page is displayed. If not, you'll have to store the data on the third page. Keep one key concept in mind - all PHP processing occurs on the server BEFORE the page is displayed in the browser. So, all data manipulation must occur as you "enter" a page. If more processing is required based on user input into that page, the processing must occur on the next page. Hope that helps, Mike Community email addresses: Post message: [email protected] Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list ------------------------------------------------------------------------------ YAHOO! GROUPS LINKS a.. Visit your group "php-list" on the web. b.. To unsubscribe from this group, send an email to: [EMAIL PROTECTED] c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.8.8/37 - Release Date: 1/07/2005 [Non-text portions of this message have been removed] Community email addresses: Post message: [email protected] Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-list/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
