Jump to content

Recommended Posts

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)){

Link to comment
https://forums.phpfreaks.com/topic/89237-solved-memberlist-letter-sorting/
Share on other sites

 

Heres more:

if(!$ltr){
$ltr="%";
}
$letterlink="&ltr=$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)){

Try this

 

if(!isset($_GET['ltr']) || strlen($_GET['ltr'])==0){
    $ltr="%";
}
else{
    $ltr=$_GET['ltr'];
}
$letterlink="&ltr=$ltr";

if(!isset($_GET['page']) || strlen($_GET['ltr'])==0){
    $page="1";
}
else{
    $page=$_GET['page'];
}

$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.

<?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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.