#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    16
    Rep Power
    0
    Hi there.
    First of all thank you for taking you the time to read this post
    I have a few problems setting up a table in MySql to Sort the entries by the "Userid" is that possible? if so plz tell me how!

    mysql> CREATE TABLE userinfo (
    -> userid VARCHAR (20),
    -> username VARCHAR (15),
    -> userpass VARCHAR (15)
    -> useremail VARCHAR (80) );


    Another Question is:
    -------------
    The lines that sends the info to the table from a Html page:
    -------------
    $query = "INSERT INTO userinfo VALUES('$userid', '$username', '$userpass', '$useremail')";

    $result = MYSQL_QUERY($query);

    How do I make the user update the Entries if the Userid allready exsists and dont make a new entry?
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4492
    I don't really understand your first question, are you talking about the results from a query being sorted by userid? If so, you'd use

    select * from userinfo group by userid asc|desc

    use asc for ascending, desc for descending alpabetical order. if you're not talking about sorting queries, then i'm confused. you don't set up a table to sort anything, that's what you use the queries for. that's what make databases so beautiful, you can stick information into it in any order you want, and use the query to pull it out however you want it formatted...


    on question number to, use update instead of insert.

    $query = "UPDATE userinfo SET username='$username', userpass='$userpass', useremail='$useremail' WHERE userid='$userid'";

    you don't have to set userid because the WHERE clause makes sure that it only updates the userid that matches what was passed to it.

    Hope that helps...


    ---John Holmes...
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    16
    Rep Power
    0
    Ohh yes it did thx alot Im a bit new to MySql so forgive my first question!
  6. #4
  7. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4492
    I think I messed up my first answer, it should be

    select * from userinfo ORDER by userid asc|desc

    read through the manual. there are a lot of different functions you can use to format the data coming out of mysql in any manner....

    ---John Holmes...

Similar Threads

  1. League table problem
    By silverduck in forum MySQL Help
    Replies: 8
    Last Post: February 10th, 2004, 12:38 PM
  2. how to keep table on top, not centered??
    By vinyl in forum HTML Programming
    Replies: 2
    Last Post: January 20th, 2004, 06:19 PM
  3. problem with viewing table
    By hssuma in forum PHP Development
    Replies: 2
    Last Post: January 16th, 2004, 12:58 AM
  4. Replies: 1
    Last Post: January 1st, 2004, 01:45 PM
  5. Replies: 1
    Last Post: December 30th, 2003, 11:10 AM

IMN logo majestic logo threadwatch logo seochat tools logo