Jump to content


Photo

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


  • Please log in to reply
6 replies to this topic

#1 Haggen

Haggen
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 12 April 2006 - 07:11 PM

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

I have this 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>

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

#2 jworisek

jworisek
  • Members
  • PipPipPip
  • Advanced Member
  • 112 posts

Posted 12 April 2006 - 07:40 PM

I hate to burst your bubble, but unless you tell us what is going wrong we don't know what is wrong either!

#3 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,020 posts

Posted 12 April 2006 - 07:46 PM

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"?
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#4 Haggen

Haggen
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 13 April 2006 - 02:08 AM

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.

#5 Haggen

Haggen
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 17 April 2006 - 04:25 PM

Any help please?

#6 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,020 posts

Posted 17 April 2006 - 06:03 PM

You need a query like

$letra = $_GET['letra'];

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

I searched your code and cannot find the word "WHERE" .
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#7 Haggen

Haggen
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 17 April 2006 - 06:50 PM

Thanks man... that was the problem... :D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users