mysql

Database Modeling Programs

Database Modeling Programs

DBDesigner 4 recommended

"DBDesigner 4 is developed and optimized for the open source MySQL-Database to support MySQL users with a powerful and free available design tool."

      Subscribe in a reader

Simple MySQL Guestbook

Creating the guestbook has two parts, the table to hold the guestbook records and the script to insert and select records from the database
table.

The structure of the table should look similar to this:

CREATE TABLE guests (
id int(10) unsigned NOT NULL auto_increment,
guest varchar(50) NOT NULL default '',
message varchar(200) NOT NULL default '',
date datetime default NULL,
PRIMARY KEY (id)
) ;

The guestbook script has three sections - the code for the form, the code for saving the form data, and the code for displaying the data.

      Subscribe in a reader

A Closer Look: Five MySQL functions that handle query results

A Closer Look: Five MySQL functions that handle query results

Assigning variable names to a MySQL result set

After executing a query to select data from a MySQL table there are several functions you can use to perform operations on the retrieved data.

mysql_result() - fetches the contents of the specified cell

mysql_data_seek() - moves to the specified row of a result set

mysql_fetch_array() - fetches the next row in the result set as an array

mysql_fetch_object() - fetches the next row in the result set as an object

      Subscribe in a reader

Count the number of MySQL Queries

Count the number of MySQL Queries

How to count the number of MySQL queries used by your script

One way of optimizing your scripts that connect to MySQL databases is to determine how many queries to the database your script makes. If you would like to count the number of queries, you can write a script that will do so. You use this function in place of the regular mysql_query() function.

PHP Code:

<?php

function cnt_mysql_query($sql=FALSE)
{
static $queries = 0;
if (!$sql)
return $queries;

$queries ++;

return mysql_query($sql);
}

$sql= "SELECT 8+9";

      Subscribe in a reader

Flash Guestbook V2

Creating a guestbook in Flash using PHP script and a MySQL database

Setting up the database

You will need to have access to a server running PHP and MySQL. If you use another database, replace the MySQL database functions that I use in the PHP script with the database functions for the other database i.e. PostgresSQL, MSSQL.

First create two tables in the database:

# This table will hold the guestbook entries.
# Table structure for table `flashgb`
#

CREATE TABLE flashgb (
id int(4) NOT NULL auto_increment,
name varchar(20) NOT NULL default '',

      Subscribe in a reader

Creating a random link generator

Creating a random link generator

The random generator code that this generator uses was originally posted to the PHP mailing list. View the original: Retrieve random Sql results
SQL for links table:

# Table structure for database table 'links'
#

CREATE TABLE links (
id tinyint(5) DEFAULT '0' NOT NULL auto_increment,
name char(250) NOT NULL,
url char(250) NOT NULL,
alt char(250) NOT NULL,
PRIMARY KEY (id)
);

PHP Code:

<?php

$db = mysql_connect("server", "username", "password");
mysql_select_db("database",$db) or die ("Unable to connect to database");

      Subscribe in a reader

Introduction to using MYSQL with PHP

Introduction

PHP (recursive acronym for "PHP: Hypertext Preprocessor") is a server-side scripting language that can be used on a host of webservers and platforms.

      Subscribe in a reader
Syndicate content