Jump to content


This topic is now archived and is closed to further replies.


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

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">
<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">
<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>
    <td width="14%" valign="top" align="center" bgcolor="357A54">
    <? include ("includes/main_nav.php"); ?>
    <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>
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>

    $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'])){
    } else {
       $query="SELECT COUNT(*) FROM empleados";
       $row=mysql_fetch_array($result, MYSQL_NUM);
       if ($num_records > $display){
       } else {
    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'])){
    } else {

    $query="SELECT * FROM " . empleados . " ORDER BY nombre ASC LIMIT $start, $display";
    $bg=($bg=="$altrow_color1" ? "$altrow_color2" : "$altrow_color1");
    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='(<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>

    $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>';}
<? include ("includes/main_footer.php"); ?>

Im not sure what im doing wrong... Any help will be great!

Share this post

Link to post
Share on other sites
I hate to burst your bubble, but unless you tell us what is going wrong we don't know what is wrong either!

Share this post

Link to post
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"?

Share this post

Link to post
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.

Share this post

Link to post
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" .

Share this post

Link to post
Share on other sites


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.