obaluba
02-01-2007, 12:57 AM
Hi All,
Thanks for looking, I have, what I hope is a simple query, I'm a newbie to PHP and am trying to get some records to display from a mysql database done in phpmyadmin... Now the php seems to run fine, but only displays 1 row from the database which is 'Web' and it does so in the wrong place (where First name & lastname should be)
<?
$user='cdesi_admin';
$password='xxxxxx';
$database='cdesi_contacts';
$dbh=mysql_connect ("localhost", "cdesi_admin", "xxxxxx") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("carrdesi_contacts");
$query="SELECT * FROM contacts";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Database Output</center></b><br><br>";
$i=0;
while ($i < $num){
$first=mysql_result($result,$i,"first");
$first=mysql_result($result,$i,"last");
$first=mysql_result($result,$i,"phone");
$first=mysql_result($result,$i,"mobille");
$first=mysql_result($result,$i,"fax");
$first=mysql_result($result,$i,"email");
$first=mysql_result($result,$i,"web");
echo"<b>Name: $first $last</b><br>Phone: $phone<br>Mobile: $mobile<br>Fax: $fax<br>E-mail: $email<br>Web: $web<br><hr><br>";
$i++;
}
?>
this has had me stumped, so any advice would be very much appreciated!
thanks for looking!
:)
Thanks for looking, I have, what I hope is a simple query, I'm a newbie to PHP and am trying to get some records to display from a mysql database done in phpmyadmin... Now the php seems to run fine, but only displays 1 row from the database which is 'Web' and it does so in the wrong place (where First name & lastname should be)
<?
$user='cdesi_admin';
$password='xxxxxx';
$database='cdesi_contacts';
$dbh=mysql_connect ("localhost", "cdesi_admin", "xxxxxx") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("carrdesi_contacts");
$query="SELECT * FROM contacts";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Database Output</center></b><br><br>";
$i=0;
while ($i < $num){
$first=mysql_result($result,$i,"first");
$first=mysql_result($result,$i,"last");
$first=mysql_result($result,$i,"phone");
$first=mysql_result($result,$i,"mobille");
$first=mysql_result($result,$i,"fax");
$first=mysql_result($result,$i,"email");
$first=mysql_result($result,$i,"web");
echo"<b>Name: $first $last</b><br>Phone: $phone<br>Mobile: $mobile<br>Fax: $fax<br>E-mail: $email<br>Web: $web<br><hr><br>";
$i++;
}
?>
this has had me stumped, so any advice would be very much appreciated!
thanks for looking!
:)