Results 1 to 3 of 3

Thread: MySql

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    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.

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    259

    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
  •  



Click Here to Expand Forum to Full Width