-
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.
-
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.
-
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