Ad block is installed and active. Please support us by disabling it.
HomeSaturday, October 21, 2017, 10:36:37
1

MySQL Basic Functions

Tuesday, February 10, 15, 15:28:21, 3 Yaers Ago Via wain, Hits: 3606
MySQL Basic Functions - select, delete, update..
1. Create a Connection to a MySQL Database.
Code:
<?php
$dbhost = 'localhost';
$dbusername = 'root';
$dbpassword = 'mypassword';
$dbname = 'mydbname';
$conn=mysql_connect($dbhost, $dbusername, $dbpassword);
if(!$conn) :
die('Could not connect: ' . mysql_error());
endif;
$db=mysql_select_db($dbname, $conn);
if(!$db) :
die ('Cant connect to database : ' . mysql_error());
endif;
?>


2. Select Database
Code:
<?php
$result = mysql_query("SELECT text FROM textbase")
or die(mysql_error());
while($link=mysql_fetch_array($result))
{
echo $link[text];
}
?>


3. Delete From Database
Code:
<?php
$result = mysql_query("DELETE FROM textbase WHERE textid = 4 ")
or die(mysql_error());
?>


4. Update Database
Code:
<?php
$result = mysql_query("UPDATE textbase SET textno='1'
WHERE textno='0' ")
or die(mysql_error());
?>


Sign In

Sponsor

Related

Upload Attachment - PHP Tutorial

Upload attachment with PHP example, Requirement(s): PHP server

Imageline

Draws a line between the two given points.

Send This Link PHP Script

A popup form which allows your visitors to send a referral link from your site. It features admin notification and HTML output.

MySQL to RSS

Publishing MySQL data in RSS

Images In Textarea - CSS

Tutorial Images in Textarea

PHP Forms

FREE PHP forms

Sitemap

phpForm.net Website Sitemap

PHP str_replace

str_replace - This function returns a string or an array with all occurrences of search in subject replaced with the given replace value

Preg_Match - PHP Form Validation

PHP form validation with preg_match

E-Cards 1.1. PHP Script

This script will allow your visitors to send e-cards to their friends. It features admin notification and HTML output.To use the "e-cards" script completely free , the "powered by" link at the bottom of the pages must stay intact.
About Author

wain

Date Registered: Sun, Feb 8, 15
Last Time Online: Thu, Jun 15, 17
So far has created 115 entries.
wain
This author has not yet filled in any details.