PHP gevorderde |
|
Ik werk met Template power en heb 2 blokken waarbij blok 2 genest is in blok 1. Het doel van het script is om de namen van alle leden weer te geven. Hij stopt nu alleen na de letter A en ik krijg het maar niet gevonden waar het aan zou kunnen liggen.
De goto statements heb ik ook al op allerlei manieren verschoven, maar dat werkt ook niet. Enig idee waarom ik alleen maar de leden krijg te zien met de beginletter a?
De phpcode:
$alfabet = array('A','B','C',"D","E","F","G","H","I","J","K","L","M","N",
"O","P","Q","R","S","T","U","V","W","X","Y","Z");
foreach ($alfabet as $letter){
$tpl->newBlock("Users".$letter);
$tpl->assign(array("Letter" => $letter));
$qry = "SELECT Userid, Username
FROM users
WHERE Username LIKE '".$letter."%'
OR Username LIKE '".Strtolower($letter)."%'
ORDER BY Username ASC";
$rs = mysql_query($qry) or die ("Error while retrieving userdata: ". mysql_error());
while ($arr = mysql_fetch_assoc($rs)){
$tpl->newBlock("Users".$letter."Names");
$tpl->assign(array("Username" => stripslashes($arr["Username"]),
"Id" => $arr["Userid"]));
}
$tpl->gotoBlock("Users".$letter);
}
$tpl->gotoBlock("_ROOT");
$alfabet = array('A','B','C',"D","E","F","G","H","I","J","K","L","M","N", "O","P","Q","R","S","T","U","V","W","X","Y","Z"); foreach ($alfabet as $letter){ $tpl->newBlock("Users".$letter); $tpl->assign(array("Letter" => $letter)); $qry = "SELECT Userid, Username FROM users WHERE Username LIKE '".$letter."%' ORDER BY Username ASC"; $tpl->newBlock("Users".$letter."Names"); "Id" => $arr["Userid"])); } $tpl->gotoBlock("Users".$letter); } $tpl->gotoBlock("_ROOT");
De html code:
<!-- START BLOCK : UsersA -->
<b>{Letter}</b>
<!-- START BLOCK : UsersANames -->
<a href="user_profile.php?id={Id}" class="view"> {Username}</a><br />
<!-- END BLOCK : UsersANames -->
<!-- END BLOCK : UsersA -->
<!-- START BLOCK : UsersA --> <!-- START BLOCK : UsersANames --> <a href="user_profile.php?id={Id}" class="view"> {Username} </a><br /> <!-- END BLOCK : UsersANames --> <!-- END BLOCK : UsersA -->
|