Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 28th, 2004, 05:40 PM
Registered User
 
Join Date: Oct 2004
Location: Ciric, Guadalajara, Mexico.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Renich
Default Searching Directory Engine

Hello,

Im trying to create a directory that takes in info, puts it on an array and makes .txt files for each add.

This is with the purpose of making "V-CARDS" for each input.

Everything else is done. The only thing im unable to do is the apropiate search method.

I would like you guys to help me with a starter...

The files are named $name.txt... i hope you get the idea

I want the files to be named $name $second_name $last_name.txt and i want to be able to put $second_name and the resulting page would list all the matches for that variable...

I will gladly add my sources in the next post.

Thank you

if you wanna help, go ahead, we need it
http://www.amba.org.mx
Reply With Quote
  #2 (permalink)  
Old October 29th, 2004, 09:03 AM
Registered User
 
Join Date: Oct 2004
Location: Ciric, Guadalajara, Mexico.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Renich
Default

Here is the source for directorio.php

<?php


// Función para hacer una consulta e imprimirla formateada
function consulta ($nombre)
{

    $directorio = "";
// Format string
    $nombre = Trim($nombre);
    $nombre = strtolower($nombre);
    $nombre = ucfirst($nombre);

// include the apropiate file
    if (!is_file($_SERVER['DOCUMENT_ROOT']."/directorio/db/" . $_POST['nombre'] .".txt"))
    {
    }
    else
    {
        include_once($_SERVER['DOCUMENT_ROOT']."/directorio/db/" . $_POST['nombre'] .".txt");
    }

// If Name exists in array print formated data
    if (!is_array($directorio))
    {
        print("<B>" . $_POST['nombre'] . "</B> no está en la lista");
    }
    else
    {

        $datos_personales = $directorio[$nombre]['datos personales'];
        $direccion = $directorio[$nombre]['direccion'];

        $nombre = $datos_personales['Nombre'];
        $apellido_paterno = $datos_personales['Apellido Paterno'];
        $apellido_materno = $datos_personales['Apellido Materno'];
        $edad_actual = $datos_personales['Edad'];
        $calle = $direccion['Calle'];
        $colonia = $direccion['Colonia'];
        $cp = $direccion['C.P.'];
        $telefono = $direccion['Teléfono'];
        $ciudad = $direccion['Ciudad'];
        $estado = $direccion['Estado'];
        $pais = $direccion['País'];

// Array "Directorio"



        print
        (
            "<H2>Información Personal</H2><BR>
            <DIV ALIGN=LEFT><TABLE BORDER=0 WIDTH=\"500\">
            <TR>
              <TD width=\"80\" ALIGN=LEFT BGCOLOR=\"#A8A8F8\"><B> Nombre: </B></TD>
                <TD ALIGN=LEFT BGCOLOR=\"#F0F8FF\"> $nombre $apellido_paterno $apellido_materno</TD>
            </TR>
            <TR>
              <TD ALIGN=LEFT BGCOLOR=\"#A8A8F8\"><B> Edad: </B></TD>
                <TD ALIGN=LEFT BGCOLOR=\"#F0F8FF\"> $edad_actual </TD>
            </TR>
              <TD ALIGN=LEFT BGCOLOR=\"#A8A8F8\"><B> Dirección: </B></TD>
                <TD ALIGN=LEFT BGCOLOR=\"#F0F8FF\"> $calle, $colonia, C.P. $cp </TD>
            </TR>
            </TR>
              <TD ALIGN=LEFT BGCOLOR=\"#A8A8F8\"><B> Cudad: </B></TD>
                <TD ALIGN=LEFT BGCOLOR=\"#F0F8FF\"> $ciudad </TD>
            </TR>
            <TR>
              <TD ALIGN=LEFT BGCOLOR=\"#A8A8F8\"><B> Estado: </B></TD>
                <TD ALIGN=LEFT BGCOLOR=\"#F0F8FF\"> $estado </TD>
            </TR>
            <TR>
              <TD ALIGN=LEFT BGCOLOR=\"#A8A8F8\"><B> País: </B></TD>
                <TD ALIGN=LEFT BGCOLOR=\"#F0F8FF\"> $pais </TD>
            </TR>
            </TABLE></DIV><BR>"
        );


    }



}


?>

<HTML>
<HEAD>
<STYLE TYPE="text/css">
<!--
BODY, P, TD {color: black; font-family: verdana; font-size: 10pt}
H1 {color: blue; font-family: verdana; font-size: 20pt}
H2 {color: blue; font-family: verdana; font-size: 12pt}
-->
</STYLE>
<TITLE>Directorio</TITLE>
</HEAD>

<BODY>

<H1><CENTER>Directorio</CENTER></H1>

<BR>
<FORM ACTION="<?php $_SERVER['PHP_SELF']; ?>" METHOD="POST">
<DIV ALIGN=cENTER>
  <P>A quién buscás, Imbécil?
  <INPUT TYPE="text" SIZE=10 NAME="nombre">
  <INPUT TYPE="submit" NAME="submit" VALUE="Ámonos!">
</FORM>
</DIV>



<DIV ALIGN=left>
<BR>
<?php

if (!IsSet($_POST['nombre']))
{
    print("<CENTER><IMG src=\" " . $_SERVER['DOCUMENT_ROOT'] . "/Renich.jpg\"></CENTER>");
}
else
{
    consulta($_POST['nombre']);
}

print('<BR><BR>');

print('<A href="directorio_add.php">Agregar a alguien</a>');

?>

</BODY>
</HTML>

if you wanna help, go ahead, we need it
http://www.amba.org.mx
Reply With Quote
  #3 (permalink)  
Old October 29th, 2004, 09:04 AM
Registered User
 
Join Date: Oct 2004
Location: Ciric, Guadalajara, Mexico.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Renich
Default

This is the add info page

<?php

require_once($_SERVER['DOCUMENT_ROOT'].'/header.inc');
?>

<FORM ACTION="directorio_put_into_db.php" METHOD="POST">
<DIV ALIGN=CENTER><TABLE BORDER=0 WIDTH="500">
            <TR>
              <TD width="130" ALIGN=LEFT BGCOLOR="#A8A8F8"><B> Nombre: </B></TD>
                <TD ALIGN=LEFT BGCOLOR="#F0F8FF"><INPUT TYPE="text" SIZE=55 NAME="nombre"></TD>
            </TR>
            <TR>
              <TD width="130" ALIGN=LEFT BGCOLOR="#A8A8F8"><B> Apellido Paterno: </B></TD>
                <TD ALIGN=LEFT BGCOLOR="#F0F8FF"><INPUT TYPE="text" SIZE=55 NAME="apellido_paterno"></TD>
            </TR>
            <TR>
              <TD width="130" ALIGN=LEFT BGCOLOR="#A8A8F8"><B> Apellido Materno: </B></TD>
                <TD ALIGN=LEFT BGCOLOR="#F0F8FF"><INPUT TYPE="text" SIZE=55 NAME="apellido_materno"></TD>
            </TR>
            <TR>
              <TD width="130" ALIGN=LEFT BGCOLOR="#A8A8F8"><B> Edad: </B></TD>
                <TD ALIGN=LEFT BGCOLOR="#F0F8FF"><INPUT TYPE="text" SIZE=55 NAME="edad"></TD>
            </TR>
            <TR>
              <TD width="130" ALIGN=LEFT BGCOLOR="#A8A8F8"><B> Calle: </B></TD>
                <TD ALIGN=LEFT BGCOLOR="#F0F8FF"><INPUT TYPE="text" SIZE=55 NAME="calle"></TD>
            </TR>
            <TR>
              <TD width="130" ALIGN=LEFT BGCOLOR="#A8A8F8"><B> Colonia: </B></TD>
                <TD ALIGN=LEFT BGCOLOR="#F0F8FF"><INPUT TYPE="text" SIZE=55 NAME="colonia"></TD>
            </TR>
            <TR>
              <TD width="130" ALIGN=LEFT BGCOLOR="#A8A8F8"><B> C.P.: </B></TD>
                <TD ALIGN=LEFT BGCOLOR="#F0F8FF"><INPUT TYPE="text" SIZE=55 NAME="cp"></TD>
            </TR>
            <TR>
              <TD width="130" ALIGN=LEFT BGCOLOR="#A8A8F8"><B> Teléfono: </B></TD>
                <TD ALIGN=LEFT BGCOLOR="#F0F8FF"><INPUT TYPE="text" SIZE=55 NAME="telefono"></TD>
            </TR>
            <TR>
              <TD width="130" ALIGN=LEFT BGCOLOR="#A8A8F8"><B> Ciudad: </B></TD>
                <TD ALIGN=LEFT BGCOLOR="#F0F8FF"><INPUT TYPE="text" SIZE=55 NAME="ciudad"></TD>
            </TR>
            <TR>
              <TD width="130" ALIGN=LEFT BGCOLOR="#A8A8F8"><B> Municipio: </B></TD>
                <TD ALIGN=LEFT BGCOLOR="#F0F8FF"><INPUT TYPE="text" SIZE=55 NAME="municipio"></TD>
            </TR>
            <TR>
              <TD width="130" ALIGN=LEFT BGCOLOR="#A8A8F8"><B> Estado: </B></TD>
                <TD ALIGN=LEFT BGCOLOR="#F0F8FF"><INPUT TYPE="text" SIZE=55 NAME="estado"></TD>
            </TR>
            <TR>
              <TD width="130" ALIGN=LEFT BGCOLOR="#A8A8F8"><B> País: </B></TD>
                <TD ALIGN=LEFT BGCOLOR="#F0F8FF"><INPUT TYPE="text" SIZE=55 NAME="pais"></TD>
            </TR>
            <TR>
</TABLE>
<TABLE>
<TD ALIGN=CENTER WIDTH=600 BGCOLOR="#FFFFFF"><INPUT TYPE="submit" NAME="Submit" VALUE="Échale!"></TD>
</TABLE>
</DIV>
</FORM>
<BR>

<?php

print('<BR><BR><DIV ALIGN="LEFT">');

print('<A href="directorio.php">Consulta</a>');

require_once($_SERVER['DOCUMENT_ROOT'].'/footer.inc');

?>




if you wanna help, go ahead, we need it
http://www.amba.org.mx
Reply With Quote
  #4 (permalink)  
Old October 29th, 2004, 09:05 AM
Registered User
 
Join Date: Oct 2004
Location: Ciric, Guadalajara, Mexico.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Renich
Default

This one makes the report and makes the "v-card".txt

<?php


$nombre = $_POST['nombre'];
$apellido_paterno = $_POST['apellido_paterno'];
$apellido_materno = $_POST['apellido_materno'];
$edad = $_POST['edad'];
$calle = $_POST['calle'];
$colonia = $_POST['colonia'];
$cp = $_POST['cp'];
$telefono = $_POST['telefono'];
$ciudad = $_POST['ciudad'];
$municipio = $_POST['municipio'];
$estado = $_POST['estado'];
$pais = $_POST['pais'];

$nombre = Trim($nombre);
$nombre = strtolower($nombre);
$nombre = ucfirst($nombre);

$db = fopen($_SERVER['DOCUMENT_ROOT']."/directorio/db/$nombre.txt", "w");


fwrite($db, " <?php

              \$directorio =

        array(
            '$nombre' =>
            array(
                'datos personales' =>
                array(
                    'Nombre' => '$nombre',
                    'Apellido Materno' => '$apellido_paterno',
                    'Apellido Paterno' => '$apellido_materno',
                    'Edad' => '$edad'
                ),
                'direccion' =>
                array(
                    'Calle' => '$calle',
                    'Colonia' => '$colonia',
                    'C.P.' => '$cp',
                    'Teléfono' => '$telefono',
                    'Ciudad' => '$ciudad',
                    'Municipio' => '$municipio',
                    'Estado' => '$estado',
                    'País' => '$pais'
                )
            )
        );
              ?>
    ");

fclose($db);
print("Has agregado a:<BR><BR>");

print("<B>Nombre</B>: $nombre $apellido_paterno $apellido_materno<BR>");
print("<B>Dirección</B>: $calle, Colonia $colonia, C.P. $cp, $ciudad, $municipio, $estado, $pais<BR><BR>");
PRINT("<B>Teléfono</B>: $telefono<BR>");
print("<B>Edad</B>: $edad años<BR><BR>");
print('<A href="directorio_add.php">Agregar a otro</a><BR>');
print('<A href="directorio.php">Consulta</a>');


?>

if you wanna help, go ahead, we need it
http://www.amba.org.mx
Reply With Quote
  #5 (permalink)  
Old October 29th, 2004, 09:07 AM
Registered User
 
Join Date: Oct 2004
Location: Ciric, Guadalajara, Mexico.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Renich
Default

This is how it works

you make a directory in your document root named "directorio". Thats where you make the files

And

You have to make a directory named "Db" in "directorio" so your txt files get saved there.

I wanna say im totaly new to this. This is my first proyect and i would like to improove it.

Thank you guys for the help.
Renich

if you wanna help, go ahead, we need it
http://www.amba.org.mx
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching for a user in Active Directory with ASP Ricapar Classic ASP Professional 1 July 15th, 2008 11:07 PM
Searching Active Directory mendezw@hotmail.com General .NET 0 November 30th, 2004 12:10 PM
Searching Active Directory schenkp ASP.NET 1.0 and 1.1 Basics 4 September 21st, 2004 11:35 AM
Searching Active Directory levinll VB How-To 1 June 8th, 2004 08:47 AM
Active Directory Searching schenkp C# 1 July 11th, 2003 03:41 PM



All times are GMT -4. The time now is 07:59 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.