Computer Science Canada

Simple MySQL Help

Author:  agnivohneb [ Tue Mar 20, 2007 6:21 pm ]
Post subject:  Simple MySQL Help

I have looked a lot and would like to know how to create a page that uses a MySQL database.

The following is just an example of php. I don't really know php syntax other than echo and $_GET('test').

I would like to:
code:
$_GET('ID')

if ID = "create" {
  if the table "userinfo" not exists {
    create the table "userinfo"
  }
  $_GET('USER')
  $_GET('PASS')
  create a new item in the table "userinfo"
  put USER and PASS into the table "userinfo"
}
elsif ID = "login"{
  if the table "userinfo" not exists {
    echo "Invalid"
    stop the program
  }
  $_GET('USER')
  $_GET('PASS')
  validate USER and PASS
  if valid {
    echo "VALID"
  }
  else {
    echo "Invalid"
  }
}
else {
  echo "Invalid"
}

You get the point.

Don't use $_POST(''). the program that i want to use with it doesn't support POST only GET.

DON'T just give me the code but give me the code. break it up so i can learn it.
You can pretty much say I'm a NOOB when it comes to PHP

I would look up how to do this but it is very hard to find how to do it with examples and this simple.
I learn best with examples. Thats how I learned HTML

Author:  rdrake [ Tue Mar 20, 2007 8:17 pm ]
Post subject:  RE:Simple MySQL Help

Examples eh? You have inspired me to repost my (very basic) PHP & MySQL tutorial. You can find it here.

Author:  agnivohneb [ Wed Mar 21, 2007 3:29 pm ]
Post subject:  Re: Simple MySQL Help

Yes that helped for the connecting part. I want to know how to add/remove/edit/read information in the database.

Author:  Dragan [ Wed Apr 09, 2008 3:31 pm ]
Post subject:  RE:Simple MySQL Help

To add some values in mysql base use query

$query = "INSERT INTO some_table (username, password) VALUES ('agnivohneb', 'entered_password')";

to remove
$query = "DELETE FROM some_table WHERE username='agnivohneb' ";

to edit
$query = "UPDATE some_table SET password = 'newpass' WHERE username = 'agnivohneb'";

to read
$query = "SELECT username FROM some_table WHERE id = 1;

that are simple examples


: