Advertisement
7_2009-2012 String Manipulation #225452

Learn MySQL thru PHP! Easily and Quickly! (updated!)

This code teaches you how to connect and use a MySQL database thru PHP 3/4. Great for beginners! I update it, so the version on this page has no comments because the PSC butchers it alot, so if you would like an explanation of the code go here http://www.moddingcentral.com/~oblivion/ I dont think this is allowed but its for the better. If you want to copy and paste the code then do it thru this the PSC page.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
<?php
$connect = mysql_connect('localhost','username','password');
mysql_query("CREATE TABLE table1 (id INT (5) not null , name VARCHAR (32) not null )");
mysql_query("DROP TABLE table1");
mysql_query("CREATE TABLE table1 (id INT (5) not null , name VARCHAR (32) not null )") or die(mysql_error());
mysql_query("INSERT INTO table1 (id, name) VALUES ('1', 'name1')") or die(mysql_error());
mysql_query("INSERT INTO table1 (id, name) VALUES ('2', 'name2')") or die(mysql_error());
mysql_query("INSERT INTO table1 (id, name) VALUES ('3', 'name3')") or die(mysql_error());
mysql_query("INSERT INTO table1 (id, name) VALUES ('4', 'name4')") or die(mysql_error());
mysql_query("INSERT INTO table1 (id, name) VALUES ('5', 'name5')") or die(mysql_error());
$query = mysql_query("SELECT * FROM table1");
$query = mysql_query("SELECT id, name FROM table1");
while($rst = mysql_fetch_array($query)){
	print("$rst[id]<br>$rst[name]<br><br>");
}
$rst = mysql_fetch_array($query);
print("$rst[id]<br>$rst[name]<br><br>");
mysql_query("UPDATE table1 SET name = 'new_name1' WHERE id = '1'") or die(mysql_error());
mysql_query("DELETE FROM table1 WHERE id = '1' AND name = 'name1'") or die(mysql_error());
mysql_query("DELETE FROM table1") or die(mysql_error());
mysql_close();
?>
Original Comments (3)
Recovered from Wayback Machine