PDA

View Full Version : MySQL and PHP help


aphq
10-28-2006, 08:35 PM
I am new to MySQL and PHP, so I am taking tutorials and following the practices it gives me. I have data in the database, but I don't know how to create an out put. This code:
<?
$username='1883_forum';
$password='********';
$database='1883_forum';
$query='SELECT * FROM `Peopleid`';
mysql_connect('mysql',$username,$password);
@mysql_select_db($database) or die('Unable to access database');
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$first=mysql_result($result,$i,'first');
$last=mysql_result($result,$i,'last');
$phone=mysql_result($result,$i,'phone');
$mobile=mysql_result($result,$i,'mobile');
$fax=mysql_result($result,$i,'fax');
$email=mysql_result($result,$i,'e-mail');
$web=mysql_result($result,$i,'web');
echo '<b>$first $last</b><br>Phone: $phone<br>Mobile: $mobile<br>Fax:

$fax<br>E-mail: $email<br>Web: $web<br><hr><br>';
$i++;
}
?>
Creates this output:
$first $last
Phone: $phone
Mobile: $mobile
Fax: $fax
E-mail: $email
Web: $web.
What am I doing wrong?

aphq
10-28-2006, 08:58 PM
Oh nevermind, I got it :D

Now I have another problem, which could probably easily solved. I am using MySQL for the menus on my site, but it lists the information alphabetically (Shown Here (http://aphq.ulmb.com/mail.php)). How do I make it stop listing everything alphabetically?

Once again, nevermind. I decided to use my brain again.