Zepo. Posted February 3, 2008 Share Posted February 3, 2008 The letter sorting in my member list isnt working: http://eliteladders.com/development/members.php Code: if(!$ltr){ $ltr="%"; } $stafflist=mysql_query("SELECT id,name,email,aim,points,country,lastactive,DATE_FORMAT(joined,'%M %d, %Y') FROM members WHERE 'name' LIKE '".$ltr."%' ORDER BY name LIMIT $page,25"); while(list($id,$name,$email,$aim,$points,$country,$lastactive,$joined)=mysql_fetch_row($stafflist)){ Quote Link to comment https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/ Share on other sites More sharing options...
Stooney Posted February 3, 2008 Share Posted February 3, 2008 Couple things that might help. Are you grabbing the actual get variable? $ltr=mysql_real_escape_string($_GET['ltr']); and try this: LIKE '$ltr%' Quote Link to comment https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/#findComment-456933 Share on other sites More sharing options...
pocobueno1388 Posted February 3, 2008 Share Posted February 3, 2008 EDIT: Nevermind Quote Link to comment https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/#findComment-456935 Share on other sites More sharing options...
Zepo. Posted February 3, 2008 Author Share Posted February 3, 2008 Still doesnt work.... When you click on N it shows all of them... Quote Link to comment https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/#findComment-456991 Share on other sites More sharing options...
Stooney Posted February 3, 2008 Share Posted February 3, 2008 Post more of your script if you would. Quote Link to comment https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/#findComment-457024 Share on other sites More sharing options...
Zepo. Posted February 6, 2008 Author Share Posted February 6, 2008 Heres more: if(!$ltr){ $ltr="%"; } $letterlink="<r=$ltr"; if(!$page){ $page="1"; } $page=($page - 1); $out[body].=" <br /> <center> <div style='background-color:$config[altcolora];width:90%;border: 1px solid rgb(0, 0, 0);'> <a href='./members.php'>#</a> | <a href='./members.php?ltr=a'>A</a> | <a href='./members.php?ltr=b'>B</a> | <a href='./members.php?ltr=c'>C</a> | <a href='./members.php?ltr=d'>D</a> | <a href='./members.php?ltr=e'>E</a> | <a href='./members.php?ltr=f'>F</a> | <a href='./members.php?ltr=g'>G</a> | <a href='./members.php?ltr=h'>H</a> | <a href='./members.php?ltr=i'>I</a> | <a href='./members.php?ltr=j'>J</a> | <a href='./members.php?ltr=k'>K</a> | <a href='./members.php?ltr=l'>L</a> | <a href='./members.php?ltr=m'>M</a> | <a href='./members.php?ltr=n'>N</a> | <a href='./members.php?ltr=o'>O</a> | <a href='./members.php?ltr=p'>P</a> | <a href='./members.php?ltr=q'>Q</a> | <a href='./members.php?ltr=r'>R</a> | <a href='./members.php?ltr=s'>S</a> | <a href='./members.php?ltr=t'>T</a> | <a href='./members.php?ltr=u'>U</a> | <a href='./members.php?ltr=v'>V</a> | <a href='./members.php?ltr=w'>W</a> | <a href='./members.php?ltr=x'>X</a> | <a href='./members.php?ltr=y'>Y</a> | <a href='./members.php?ltr=z'>Z</a></div><br /> <table width='90%' border='0' cellspacing='1' cellpadding='1' bgcolor='#000000' cellpadding='1' cellspacing='1'> <tr bgcolor='$config[altcolor]'> <td width='100%' valign='center' background='$config[bg]' colspan='5'><b> Members List</b></td> </tr><tr bgcolor='$config[altcolorb]'> <td width='5%' valign='center' background='$config[bg2]' align='center'></td> <td width='28%' valign='center' background='$config[bg2]' align='center'><b>Name</b></td> <td width='15%' valign='center' background='$config[bg2]' align='center'><b>Contact</b></td> <td width='22%' valign='center' background='$config[bg2]' align='center'><b>Points</b></td> <td width='25%' valign='center' background='$config[bg2]' align='center'><b>Joined</b></td> </tr>"; $stafflist=mysql_query("SELECT id,name,email,aim,points,country,lastactive,DATE_FORMAT(joined,'%M %d, %Y') FROM members WHERE 'name' LIKE '$ltr%' ORDER BY name LIMIT $page,25"); while(list($id,$name,$email,$aim,$points,$country,$lastactive,$joined)=mysql_fetch_row($stafflist)){ Quote Link to comment https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/#findComment-459311 Share on other sites More sharing options...
Stooney Posted February 6, 2008 Share Posted February 6, 2008 Try this if(!isset($_GET['ltr']) || strlen($_GET['ltr'])==0){ $ltr="%"; } else{ $ltr=$_GET['ltr']; } $letterlink="<r=$ltr"; if(!isset($_GET['page']) || strlen($_GET['ltr'])==0){ $page="1"; } else{ $page=$_GET['page']; } Quote Link to comment https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/#findComment-459425 Share on other sites More sharing options...
Zepo. Posted February 7, 2008 Author Share Posted February 7, 2008 Nope, still displays nothing when you click on a letter, when a letters not set it displays all of them like it's supposed to. Quote Link to comment https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/#findComment-460298 Share on other sites More sharing options...
phpSensei Posted February 7, 2008 Share Posted February 7, 2008 Try reference to this page http://www.htmlite.com/mysql011.php Quote Link to comment https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/#findComment-460299 Share on other sites More sharing options...
teng84 Posted February 7, 2008 Share Posted February 7, 2008 can you explain what do you mean by letter sorting? and maybe more of your objective on this Quote Link to comment https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/#findComment-460302 Share on other sites More sharing options...
Zepo. Posted February 7, 2008 Author Share Posted February 7, 2008 can you explain what do you mean by letter sorting? and maybe more of your objective on this Like most member lists have, when you click a letter it pulls all of the members whos name starts with the selected letter. Quote Link to comment https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/#findComment-460306 Share on other sites More sharing options...
teng84 Posted February 7, 2008 Share Posted February 7, 2008 $ltr = range('a-z'); $letter = $_GET['letter']; if(in_array($letter,$ltr)){ $query = "slect * form teng where name like '$letter%'"; } else{ //select all } shorter but should do the trick Quote Link to comment https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/#findComment-460309 Share on other sites More sharing options...
Zepo. Posted February 7, 2008 Author Share Posted February 7, 2008 $ltr = range('a-z'); $letter = $_GET['letter']; if(in_array($letter,$ltr)){ $query = "slect * form teng where name like '$letter%'"; } else{ //select all } shorter but should do the trick Are you sure, $letter isnt defined, only $ltr is. Quote Link to comment https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/#findComment-460329 Share on other sites More sharing options...
teng84 Posted February 7, 2008 Share Posted February 7, 2008 what? Quote Link to comment https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/#findComment-460333 Share on other sites More sharing options...
marcus Posted February 7, 2008 Share Posted February 7, 2008 <?php $alphanum = array_merge(range('a','z'),range('1','9')); $x=1; foreach($alphanum AS $char){ $pipe = ($x == count($alphanum)) ? "" : " | "; $link = ($_GET['ltr'] == $char) ? $char . $pipe : "<a href=\"alphanum.php?ltr=".$char."\">".$char."</a>" . $pipe; echo $link; $x++; } $ltr = $_GET['ltr']; echo "<br><br>\n"; if($ltr){ if(in_array($ltr,$alphanum)){ $sql = "SELECT * FROM `table` WHERE `field` LIKE '".$ltr."%'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ echo "No results!\n"; }else { while($row = mysql_fetch_assoc($res)){ echo $row['field'] . "<br>\n"; } } }else { echo "Please choose a letter or number!\n"; } }else { echo "Please choose a letter or number!\n"; } ?> suttin like dat? Quote Link to comment https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/#findComment-460341 Share on other sites More sharing options...
Zepo. Posted February 7, 2008 Author Share Posted February 7, 2008 Ok i got it thanks! =] Quote Link to comment https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/#findComment-460377 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.