Jump to content

**SOLVED** Problem with ABCDEF... links


Haggen

Recommended Posts

Hi, i have this agenda script and i need to add the "ABCDEFG..." on each listing...

I have this code:

[code]<? include ("admin/config.php"); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <title><? echo "$page_title"; ?></title>
  <LINK REL="stylesheet" TYPE="text/css" href="css.css">
</head>
<body leftmargin="8" rightmargin="8" bottommargin="8" bgcolor="#FFFFFF"  >
<table border="0" width="92%" height="100%" cellpadding="0" cellspacing="0" align="center">
<? include ("includes/main_header.php"); ?></td>
<tr>
    <td width="14%" valign="top" align="center" bgcolor="357A54">
    <? include ("includes/main_nav.php"); ?>
    
    </td>
    <td valign="top"  bgcolor="#FFFFFF"><br>
    <table border="0" width="98%" height="100%" cellspacing="1" cellpadding="2" align="center">
    <tr><td height="40" colspan="7" class="titulos">Directorio de Empleados <div  style="text-align:right;" class="base"><b>[ <a href="listar_todos_empleados.php">Mostrar Todos</a> ]</b></div></td></tr>

     <tr align="center" height="1">
     <td width="45%" class="row1"><b>Nombre</b></td>
     <td width="15%" class="row1"><b>Telefono</b></td>
     <td width="20%" class="row1"><b>Celular</b></td>
     <td width="20%" class="row1"><b>Departamento</b></td>
    </tr>
    <?
echo '<p align=center>
<span class=base><a href=listar_empleados.php?letra=numerico>0-9</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=a>A</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=b>B</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=c>C</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=d>D</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=e>E</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=f>F</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=g>G</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=h>H</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=i>I</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=j>J</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=k>K</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=l>L</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=m>M</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=n>N</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=o>O</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=p>P</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=q>Q</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=r>R</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=s>S</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=t>T</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=u>U</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=v>V</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=w>W</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=x>X</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=y>Y</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php?letra=z>Z</a></span><span class=base> | </span>
<span class=base><a href=listar_empleados.php>Todos</a>
</p>';    

    $connection=mysql_connect("$hostname", "$username", "$password")
    or die("Could not establish connection");
    mysql_select_db($database_name, $connection)
    or die ("Could not select database");
    if (isset($_GET['np'])){
       $num_pages=$_GET['np'];
    } else {
       $query="SELECT COUNT(*) FROM empleados";
       $result=mysql_query($query);
       $row=mysql_fetch_array($result, MYSQL_NUM);
       $num_records=$row[0];
       if ($num_records > $display){
          $num_pages=ceil($num_records/$display);
       } else {
          $num_pages=1;
       }
    }
    if (isset($_GET['letra'])) {
   if ($_GET['letra'] == 'numerico')
       $sort = "AND SUBSTRING(nombre, 1, 1) IN ('.','#','0','1','2','3','4','5','6','7','8','9')";
   elseif (strpos('abcdefghijklmnopqrstuvwxyz', strtolower($_GET['letra'])) !== false)
       $sort = "AND nombre LIKE '" . $_GET['letra'] . "%'";
} else
  $sort = '';
    
    if (isset($_GET['s'])){
       $start=$_GET['s'];
    } else {
       $start=0;
    }
    

    $query="SELECT * FROM " . empleados . " ORDER BY nombre ASC LIMIT $start, $display";
    $result=mysql_query($query);
    while($row=mysql_fetch_array($result)){
    $bg=($bg=="$altrow_color1" ? "$altrow_color2" : "$altrow_color1");
    $etitle=$row[etitle];
    $alt_title=$row[alt_title];
    if ($alt_title == "N/D" and $etitle != "N/D")
       $alt_title='(<i><a href="show_anime.php?id=' . $row[id] . '" class="style1">' . $etitle . '*</a></i>)';
    elseif ($alt_title == "N/D" and $etitle == "N/D")
       $alt_title="";
    else
    $alt_title='(<i><a href="show_anime.php?id=' . $row[id] . '" class="style1">' . $row[alt_title] . '</a></i>)';
    echo '<tr height="1" bgcolor="' . $bg . '" onMouseOver="this.style.backgroundColor=\'' . $mouseover_color . '\';" onMouseOut="this.style.backgroundColor=\'' . $bg . '\';">
       <td class="lista">&nbsp; <a href="mostrar_empleados.php?id=' . $row[id] . '" class="style1">' . $row[nombre] . ' ' . $row[apellido_paterno] . ' ' . $row[apellido_materno] . '</td>
       <td align="center" class="lista">' . $row[telefono] . '</td>
       <td align="center" class="lista">' . $row[celular] . '</td>
       <td align="center" class="lista">' . $row[depto] . '</td>
    </tr>';}
    

  
    mysql_close($connection);
    $connection=mysql_connect("$hostname", "$username", "$password")
    or die("Could not establish connection");
    mysql_select_db($database_name, $connection)
    or die ("Could not select database");
    $query = "select count( * ) as Total from empleados";
    $result = mysql_query($query);
    $row = mysql_fetch_assoc($result);
    $Totalempleados = $row['Total'];

echo " <div class=base align=center><font size=2><b>Total de Empleados:</b> $Totalempleados</div></font>\n";
?>
    <tr valign="top">
       <td colspan="7">
<div  style="text-align:right;" class="base"><b>[ <a href="listar_todos_empleados.php">Mostrar Todos</a> ]</b></div>
       <div style="text-align:center;">
       <?
       if ($num_pages > 1) {
          $current_page = ($start/$display) + 1;
          if ($current_page != 1) {
             echo '<a href="list_anime.php?s=' . ($start - $display) . '&np=' . $num_pages . '" class="style3">Anterior</a> ';}
          for ($i = 1; $i <= $num_pages; $i++) {
             if ($i != $current_page) {
                echo '<a href="list_anime.php?s=' . (($display * ($i - 1))) . '&np=' . $num_pages . '" class="style3">' . $i . '</a> ';
             } else {
                echo '<font face="serif" size="4">';
                echo $i . '</font> ';}
          }
          if ($current_page != $num_pages) {
             echo '<a href="list_anime.php?s=' . ($start + $display) . '&np=' . $num_pages . '" class="style3">Siguiente</a>';}
       }
       ?>
       </div>
       </td>
    </tr>
   </table>
   </td>
</tr>
<? include ("includes/main_footer.php"); ?>
</table>
</body>
</html>[/code]

Im not sure what im doing wrong... Any help will be great!
Link to comment
Share on other sites

I do not have your database so I cannot run your script, so perhaps you would care to give me a clue about what to look for

a) what is it doing that it it shouldn't do?

b) what is it not doing that it should?

In other words, what is your problem other then "this script doesn't work"?
Link to comment
Share on other sites

Upps, sorry guys.. well, this code is suppost to have ABC links to select a letter and display the entries that start with the selected letter.

This code doesnt do anything at all :(, i clicked the letter and i keep seeing my whole list of entries.
Link to comment
Share on other sites

You need a query like

[code]$letra = $_GET['letra'];

$query = "SELECT * FROM empleados
               WHERE nombre LIKE '$letra%'
               ORDER BY nombre ASC
               LIMIT $start, $display";[/code]

I searched your code and cannot find the word "WHERE" .
Link to comment
Share on other sites

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.