Ad block is installed and active. Please support us by disabling it.
HomeSaturday, August 19, 2017, 09:01:38
1

MySQL Basic Functions

Tuesday, February 10, 15, 15:28:21, 3 Yaers Ago Via wain, Hits: 3256
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

MySQL Inner Join

MySQL Inner Join - Creating Dynamic Webpages Using PHP and MySQL, Requirement(s): PHP Server, MySQL

Sending HTML Email With Images - PHP Tutorial

Sending HTML Email With Images - Upload Image with PHP - Creating Dynamic Webpages Using PHP and MySQL - Select, Delete, Update..

Comments 1.1. :: PHP Script

This script allows your visitors to add comments to any single page on your web site.

Smarty Paginate Example - Smarty Pagination with PHP

Smarty Paginate Example, Smarty Pagination with PHP. SmartyPaginate: a class/plugin for data set pagination within the Smarty template environment

Inserting form data in MySql table

Inserting form data in MySql table with PHP

Contact Us 2.0. :: PHP Form

Version 2.0. - A contact us form with email and form field validation. It allows your visitors to send you an email directly from your website.

Advanced Contact Form - PHP Script

Advanced Contact Form with email and form field validation. Features: HTML Output(Response), Captcha Image.

PHP form with file upload

Advanced Contact Form with email and form field validation. It allows your visitors to send you an email directly from your website.

Process Form Data with Jquery

jQuery, Process form data

PHP explode

Explode — Split a string by string.
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.