|
-
Apr 23rd, 2002, 11:30 AM
#1
Thread Starter
Hyperactive Member
MySql
How can i complete this code:
<?
$HostName="localhost";
$UserName="prokhaled";
$DBName="test";
$Password="";
$Connect =mysql_connect($HostName,$UserName,$Password);
$Select =mysql_select_db($DBName,$Connect);
?>
I want to create new table it's name (Members) this table contain this fields (UserName,Age,Password)
And also How can I add new records in this Table or this fields.
-
Apr 23rd, 2002, 12:47 PM
#2
Stuck in the 80s
To create a table:
PHP Code:
$sql = "CREATE TABLE Members (id tinyint(4) DEFAULT '0' NOT NULL AUTO_INCREMENT, UserName varchar(20), Age tinyint(2), Password varchar(20), PRIMARY KEY (id), UNIQUE id (id))";
$result = mysql_query($sql);
it's pretty self explanatory when you look through it:
"CREATE TABLE [tablename] (fieldname fieldtype fieldproperties)"
To add a record:
PHP Code:
$sql = "INSERT INTO Members (UserName,Age,Password) VALUES ('TheHobo','18','Password')";
$result = mysql_query($sql);
Also pretty self explanatory. Hope this helps.
-
Apr 24th, 2002, 01:27 AM
#3
Thread Starter
Hyperactive Member
Thank you very much
another question please :
How can I search for UserName and print record that contain this UserName ?
How Can I move to the third record that it's id=3 and print it ?
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|