Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 16th, 2004, 11:47 PM
Registered User
 
Join Date: Feb 2004
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

 
Old February 17th, 2004, 03:00 PM
Friend of Wrox
 
Join Date: Jun 2003
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/





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 01:08 PM
Need info about MySQL bmains MySQL 3 September 23rd, 2004 07:18 AM
Automatically retrieval info from MySql Master_D Pro PHP 1 June 5th, 2004 05:08 PM
HttpContext.Current.Cache used to store user info? flyin General .NET 11 April 6th, 2004 03:57 PM
How do I store user login info to use in a form? lanctotd Classic ASP Basics 1 July 15th, 2003 08:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.