Ad block is installed and active. Please support us by disabling it.
HomeFriday, April 20, 2018, 19:59:13
1

MySQL Basic Functions

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

PHP Trim

trim() Strip whitespace (or other characters) from the beginning and end of a string.

PHP/MySQL Bookmarklet - PHP Tutorial

PHP/MySQL bookmarklet, bookmark current page, PHP/MySQL tutorial.

View content in a zip file with PHP

List all files in a zip archive with PHP

RSS, MySQL & Smarty

Smarty > Publishing MySQL Data in RSS 2.0

Preg_Match - PHP Email Validation

Validate email with preg_match in php

Creating a CAPTCHA with PHP :: PHP Tutorial

Captcha Image, This tutorial will show you how to create a form with Captcha.

PHP highlight_string - PHP Tutorial

Outputs or returns a syntax highlighted version of the given PHP code using the colors defined in the built-in syntax highlighter for PHP. Requirement(s): PHP Server.

Random MySQL Query

Random MySQL query, requirement(s): PHP Server, MySQL

PHP $_GET Function

Get function in PHP

PHP explode

Explode — Split a string by string.
About Author

wain

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