Help please:)

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
hawkeye177
Forum Newbie
Posts: 8
Joined: Wed Nov 27, 2002 7:41 pm

Help please:)

Post by hawkeye177 »

I need help writing a script that will get the all the stuff that are in two fields and order them by the number. Is there a way i can do it?

Here's my format.
hawkshar_doc is my DB Name
user Table
email field
dp field
team field

I would like for the script to show the email and the dp field only, and order by number in the dp field .

Also i got another thing...
Is there a way i can have another site where it only shows the people who have like team number 1 in the team field?

Thank in advance!
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

What are "dp"'s attributes? eg: is it like an ID field that is set to AUTO_INCREMENT?
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

Never mind my last post, just do this:

Connect to the database as normal, then where you want the fields to be shown in the document add this:

<table width="100%">
<?php

$userlist = mysql_query("SELECT email, team FROM user ORDER BY dp DESC");

while ($list= mysql_fetch_array($userlist)) {
$email= $product["email"];
$team= $product["team"];
$dp= $product["dp"];
?>
<tr>
<td>
<?=$email?>
</td>
</tr>
<tr>
<td >
<?=$dp ?>
</td>
</tr>
<?php
}

?>
</table>
Post Reply