Forums

data search (3 posts)

  1. Spiritualight
    Member
    Posted 2 weeks ago #

    Hi

    Does anyone know of a plugin that would allow my blog members to search a database of names that I input myself.

    So for example: I would input details of each person in my directory like
    Name
    Age
    Etc

    and then my members could search using the Name fields. The names in my database wouldnt necessarily be members of my blog, but their names would be searchable by members of my blog, if that makes sense! lol

    Any help or suggestions would be greatly appreciated.

    I should also add that I would like the search function to search only the data I have inputted rather than posts or pages. :)

    Any Ideas?

  2. Spiritualight
    Member
    Posted 2 weeks ago #

    I dont seem to get any replies on my posts here! :(

  3. cogmios
    Member
    Posted 2 weeks ago #

    Just download any php addressbook mysql application, install it and then either use an iframe to load it into a wp page or use wp-exec as plugin to query the db directly e.g. for searches or other things.

    So: download XAMP , create a mysql db, create the db at your host, export/import the data and then create a WP page queering it:

    ini_set('display_errors',0);
    error_reporting(E_ALL|E_STRICT);
    $dbname = 'YOURDBNAME';
    
    $mysql_link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die (mysql_error() . 'Error connecting to mysql');
    mysql_select_db($dbname, $mysql_link) or die (mysql_error() . 'problem connecting with database');
    $sql ="SELECT * from names";
    $result = mysql_query($sql, $mysql_link) or die('Failed Query of '. $sql . ' ' . mysql_error());

    you can now use e.g.

    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
    echo "<tr>";
    echo "<TD>$i</TD>";
    echo "<TD>{$row['NAME']}</td>";
    echo "<TD>{$row['PRODUCT']}</td>";
    echo "</tr>";
    }

    to walk through your db and display it.

    don't forget to change the db back if you query the wp db e.g. if you further down query it for categories:

    <?php
    mysql_select_db(DB_NAME, $mysql_link) or die (mysql_error() . 'problem connecting with database');
    wp_list_categories('sort_column=name&number=10&title_li=&depth=10');
    ?>

    Pretty easy. So start by downloading XAMP and then read the XAMP documentation on how to use phpmyadmin to create the database, fill it and export it.

    cheers!

Reply

You must log in to post.

About this Topic

Tags