SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Oct 2001
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Database Question

    Hi all,

    New here. I am looking to build a database. I am new to PHP/mySQL. I have already followed Kevin's tutorial and been able to build a very simple database almost identical to his jokes database.

    My problem is that I want my database to be able to return common entries. For eg. if one column is called names and has the same name entered, with associated different entries for the other column, I want to be able to select all the entries for that name. also same for the other columns.

    Also How do I password protect the database so that anyone can make entries but you need a password to delete/modify entries.

    Thanks, Hector

  2. #2
    SitePoint Zealot sonique's Avatar
    Join Date
    Sep 2001
    Location
    Missouri [U.S.]
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    where is this tutorial?
    jmulder[THE MENTOR]'s nice guy online!
    Rig: AMD Athlon 800mhz; 384mb SDRam; 32mb nVidia @ 1024x768; ie 6; Windows ME; 15 gig; Cd-RW

  3. #3
    SitePoint Member
    Join Date
    Oct 2001
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Kevin Yank's Tutorial from this very site

  4. #4
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The article is located here:
    http://www.webmasterbase.com/article.php?aid=228&pid=0

    For pulling multiple entries out of a database, suppose you have a field named name in a database named mysite. To select all entries that contain the name Colin, use a construct like this:
    Code:
    select * from mysite where name like "%Colin%"
    That will select all of the data from the table that has the value Colin anywhere in the name field. To print that out, I would use a simple while-loop statement with the mysql_fetch_array function like so:
    PHP Code:
    <?php
    while ($result mysql_fetch_array($query))
    {
         
    $name $result["name"];
         echo(
    "content from database where name is $name");
    }
    ?>
    Does this make sense at all?

    As for the password protecting, you could use a simple if;elseif;else set of statements to allow or disallow people to edit the database. If you're wanting extremely high security though, I would recommend looking into PHP's session handling capabilites or the .htaccess file on your server.

    Good luck!
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •