Your Ad Here

 Navigation
Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links




 Sponsors
 Links
dvd information
gambling sites
golfing products
 Downloads
 Misc
Webmaster Resources
Only PHP
ScriptSearch.com
Scripts.com - Get the best scripts NOW!
AndreaPHP Programming

Valid XHTML 1.0 Transitional


Valid CSS!


Adding data to a Database


Adding data to a Database



In this first of our three part guide to manipulating data in a MySQL database we will add data to a MySQL database . First create our sample database.

Now create our sample table like this.

Now we have our table , what we will do is create a form which allows a user to add some text to the database in this we will make it a link. Here is the code for our form , this is pretty straightforward .

<form action="addingtoadb1.php" method ="POST">
<input type = "text" name = "add" maxlength="50"><br>
<input type = "submit" value = "add link"><br>
</form>

Now we move onto our php script , replace the ("hostname" , "username" , "password") with your own details .

<?php
//make our connection details
$connection = mysql_connect("hostname" , "username" , "password")
or die ("Cannot make the connection");
//connect to sampledb with our connection details
$db = mysql_selectdb("sampledb" , $connection)
or die ("Cannot connect to the database");
//if the text field wasnt blank enter data
if($add)
{
//insert the text box data into the sample table
$sql_query = "INSERT into sample VALUES ('','$add')";
$result = mysql_query($sql_query);
//display the entered link
echo "You entered the following info " . $add;
}
//if it was blank display a message
else
{
echo ("you didnt enter any data");
}
?>

 

This will add the text / link to the database , in our next part we will display the links in the database

Part 2 : Displaying the links



Books
 Sponsors
 Random Code
bbc science/nature with PEAR packages(xml)
grab a web page with cURL(internet)
list all databases(database)
 Random Article
  Network
Programming resources
Tutorials directory
Clickbank mall
sell software
Free auctions, low cost stores
UK products
US products
Gambling directory
Sexy free wallpapers
Hosting resources
ASP site
DVD site
Domain names
Dating site
Software directory
Maxi directory
bigarticle : free articles




beginners PHP Copyright © 2004 onwards by beginnersPHP.