July 22nd, 2000, 06:18 PM
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?
July 22nd, 2000, 07:21 PM
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...
July 23rd, 2000, 05:22 AM
Ohh yes it did thx alot Im a bit new to MySql so forgive my first question!
July 23rd, 2000, 02:40 PM
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....