|
Posted by ScareCrowe on 05/10/05 05:31
--ScareCrowe
"toedipper" <send_rubbish_here734@hotmail.com> wrote in message
news:QiPfe.81$RJ6.64@newsfe1-win.ntli.net...
> Hello,
>
> Newbie alert, run for cover.
>
> Apache, PHP and MY SQL
>
> Imagine I have 2 tables, users and cars. The users table basically lists
> people who own cara and the cars table is the cars that are owned by the
> people.
>
> The users table has the following standard info
>
> userid
> username
> password
>
> The cars table has the following
>
> carid,
> ownerid - this is the userid of the table users
> reg_plate_number,
> make,
> model,
> blah,
> blah,
>
> What I want to be able to do is say have a user login on at a simple page
> with a text box for username/password, maybe called login.php - and
assuming
> they pass the logon test (exists and correct username/pw) they will be
> redirected to a page that shows the cars that they own. So for example if
> Tom logs in correctly he will get a list on screen of the car(s) that he
> owns.
>
> Any ideas?
>
> Thanks,
>
> td.
Check out some of the functions for mysql, specifically mysql_connect(),
mysql_query(), mysql_fetch_array(). Some are dependent on other functions,
but the manual will tell you which ones you need. Then, after
authenticating, you basically just want to query MySQL with a basic " SELECT
* FROM car_table WHERE ownerid='$_POST[this_id]' ", throw it in a loop in
case they own more than one car and print it out in whatever fashion you see
fit!
Something like:
$sql = " SELECT * FROM car_table WHERE ownerid='$_POST[this_id]' ";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
echo $row['carid']." ".$row['reg_plate_number']." ".$row['make']."
".$row['model']."<br>\n";
}
You can start researching somewhere around here:
http://us2.php.net/manual/en/function.mysql-query.php
Have Fun!
--ScareCrowe
Navigation:
[Reply to this message]
|