Thread: Mysqli
View Single Post
Old 05-12-2015, 04:48 AM   #1
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,170
Default Mysqli

i do not know how dream weaver approaches its php code now. i stopped using it a long time ago as it because as DW tries to be everything to everyman the code it produces is long and over complex or was at least .

i thought i would post some examples to help break away from DW and code directly. so i will give some examples using Mysqli, basically because soon mysql will be no more and its use of prepareed statements offer a security that is very nescersary today, perhaps more that ever before.

Any way first, a database to work with. paste the below code intom phpadmin (or other database manager you use) on your server.

It will create a database called employees with a table named Staff

Code:
CREATE DATABASE `employees`
    CHARACTER SET 'latin1'
    COLLATE 'latin1_swedish_ci';

USE `employees`;

#
# Structure for the `staff` table : 
#

CREATE TABLE `staff` (
  `id` INTEGER(3) NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(100) COLLATE latin1_swedish_ci NOT NULL,
  `position` VARCHAR(100) COLLATE latin1_swedish_ci NOT NULL,
  `department` VARCHAR(100) COLLATE latin1_swedish_ci NOT NULL,
  `start_date` DATE NOT NULL,
  `telephone` VARCHAR(100) COLLATE latin1_swedish_ci NOT NULL,
  `gender` VARCHAR(100) COLLATE latin1_swedish_ci NOT NULL,
  `status` VARCHAR(100) COLLATE latin1_swedish_ci NOT NULL,
  `email` VARCHAR(100) COLLATE latin1_swedish_ci NOT NULL,
  PRIMARY KEY USING BTREE (`id`) COMMENT ''
)ENGINE=InnoDB
AUTO_INCREMENT=9 AVG_ROW_LENGTH=2048 CHARACTER SET 'latin1' COLLATE 'latin1_swedish_ci'
COMMENT=''
;
INSERT INTO `staff` (`id`, `name`, `position`, `department`, `start_date`, `telephone`, `gender`, `status`, `email`) VALUES
  (1,'Maria','manager','sales','2013-05-01','222 333 4444','female','maried','maria@work.com'),
  (2,'Gina','staff','sales','2013-05-01','222 333 4445','female','Single','Gina@work.com'),
  (3,'Jacob','staff','sales','2013-05-01','222 333 4446','Male','maried','Jacob@work.com'),
  (4,'Bob','staff','sales','2013-05-01','222 333 4447','Male','Single','Bob@work.com'),
  (5,'Nobby','manager','marketing','2013-05-01','222 333 4444','Male','maried','nobby@work.com'),
  (6,'Tom','staff','marketing','2013-05-01','222 333 4448','Male','Single','Tom@work.com'),
  (7,'Dick','staff','marketing','2013-05-01','222 333 4449','Male','Single','Dick@work.com'),
  (8,'Harry','staff','marketing','2013-05-01','222 333 4450','Male','Single','Harry@work.com');
COMMIT;
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas

Last edited by edbr; 05-12-2015 at 10:16 AM..
edbr is offline   Reply With Quote