Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 16th, 2004, 11:47 PM
Registered User
 
Join Date: Feb 2004
Location: Daytona, Florida, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to KoRn Send a message via MSN to KoRn Send a message via Yahoo to KoRn
Default Store info into a MySQL DB table

I was wondering if anybody could tell me
how to use PHP to
1) a script to store info into a MySQL DB Table (using html forms)
2) recall that info (and the script I'd use for that)

I'm new to both PHP and MySQL; for MySQL,
I know basic stuff like info to enter, when installing IPB forums, etc.

I've done a small, easy script using php alrdy;
(see http://korn.lp-hc.us/script_test )

Anywhose, if anybody could help me out, it'd
be a great help :) Thnkx in advance for any/all help

Reply With Quote
  #2 (permalink)  
Old February 17th, 2004, 03:00 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is actually extremely easy to do, and is one of the main reasons people use server-side scripting languages like PHP in the first place.

Here's the minimum you'll need to do to:

<?php

if (isset($_POST['some_input_field']))
{
    mysql_connect(...);
    mysql_select_db(...);

    $query = "INSERT INTO table (some_column)
                     VALUES ('{$_POST['some_input_field]}')";
    mysql_query($query);
}

?>

<?php

mysql_connect(...);
mysql_select_db(...);

$query = "SELECT * FROM table";

$result = mysql_query($query);

if ($result)
{
    while ($row = mysql_fetch_array($result))
    {
        echo "Your row was: <pre>";
        print_r($row);
        echo "</pre>\n";
    }
}

?>

As always, RTM: http://www.php.net/mysql

There are ___LOTS___ of tutorials and articles out there, too, so no one should have to rewrite any of them. Just search on google:

  http://www.google.com/search?q=php+mysql+tutorial


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating DB Table using XML inline schema info sriram_shol VB.NET 1 September 7th, 2012 02:08 PM
Need info about MySQL bmains MySQL 3 September 23rd, 2004 08:18 AM
Automatically retrieval info from MySql Master_D Pro PHP 1 June 5th, 2004 06:08 PM
HttpContext.Current.Cache used to store user info? flyin General .NET 11 April 6th, 2004 04:57 PM
How do I store user login info to use in a form? lanctotd Classic ASP Basics 1 July 15th, 2003 09:06 PM



All times are GMT -4. The time now is 05:38 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.