PHP expert |
|
>>Heb gezocht!!<<
ben geen held met mysql , maar heb nu een ledenlijst, alleen hij moet gegevens halen uit 2 tabellen, hoe doe je dat?? neem aan met while maar heb een while in een andere while gezet en dan laat hij helemaal nix meer zien
(alleen de tabel word geshowd, de membersregel etc niet..)
(I know de tijd, verveelde me(voor iemand dat gaat zegge )
<?php
include ("include/config.php");
$users = mysql_query("SELECT * FROM users");
$members = mysql_num_rows($users);
$ranks = mysql_query("SELECT * FROM ranks");
$rank = mysql_num_rows($ranks);
if($members == "0"){
$members = "We have no members!";
}
if($members == "1"){
$members = "We have 1 member!";
}
else{
$members = "We have ". $aantal ." members!";
}
?>
<p align="center"><?php echo ("$members"); ?></p>
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr bgcolor="#CCCCCC">
<td width="5%"><div align="center">id</div></td>
<td width="25%"><div align="center">Username</div></td>
<td width="25%"><div align="center">Email address</div></td>
<td width="25%"><div align="center">Homepage</div></td>
<td width="25%"><div align="center">Rank</div></td>
</tr>
<?php
while($member_list = mysql_fetch_object($users)){
$username = $member_list->username;
$id = $member_list->id;
$mail = $member_list->mail;
$homepage = $member_list->homepage;
while($rank_list = mysql_fetch_object($ranks)) {
$rank = $rank_list->rank;
if(empty($homepage)){
$homepage = "No homepage";
}
else{
$homepage = "<a href=\"" . $homepage . "\" target=\"_blank\">$homepage</a>";
}
echo ("");
echo ("<tr>");
echo ("<td><a href=\"profiel.php?id=" . $id . "\" target=\"_blank\">$id</a></td>");
echo ("<td>$username</td>");
echo ("<td>$mail</td>");
echo ("<td>$homepage</td>");
echo ("<td>$rank</td>");
echo ("</tr>");
echo ("");
}
}
?>
</table>
<?php include ("include/config.php"); if($members == "0"){ $members = "We have no members!"; } if($members == "1"){ $members = "We have 1 member!"; } else{ $members = "We have ". $aantal ." members!"; } ?> <p align="center"> <?php echo ("$members"); ?></p> <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000"> <tr bgcolor="#CCCCCC"> <td width="5%"><div align="center">id</div></td> <td width="25%"><div align="center">Username</div></td> <td width="25%"><div align="center">Email address</div></td> <td width="25%"><div align="center">Homepage</div></td> <td width="25%"><div align="center">Rank</div></td> </tr> <?php $username = $member_list->username; $id = $member_list->id; $mail = $member_list->mail; $homepage = $member_list->homepage; $rank = $rank_list->rank; $homepage = "No homepage"; } else{ $homepage = "<a href=\"" . $homepage . "\" target=\"_blank\">$homepage</a>"; } echo ("<td><a href=\"profiel.php?id=" . $id . "\" target=\"_blank\">$id</a></td>"); echo ("<td>$username</td>"); echo ("<td>$homepage</td>"); } } ?> </table>
|