Hi everyone. I'm new to this forum and was hoping someone could help me find a solution for this project, or at least point me to the different components I'd need to create.

I'm looking to create something like this: http://www.thegilbertapartments.com/cgi-bin/serve.cgi?page=updates

In the example site, when the client clicks on "add a construction update" they get a login screen, and then an interface that allows them to upload a new picture and a caption. It looks like it was done with perl, which I don't want to go near. I'm wondering if this is something I can build with PHP and SQL, and if so... where I start??

I'm pretty savvy when it comes to modifying existing code to fit my needs (I'm not looking for beginners tutorials right now), I just don't know where to start looking for a solution since I don't speak PHP or SQL (yet).

Any advice?

    Umm... it's pretty easy:

    Tables:
    -- Users
    -- Photos
    -- Comments
    -- Categories / Sections

    That'd be the basic Photo gallery with comments. You might look into PhotoGallery or some other pre-made photo galleries that prove it's been done 😉

      It's so hard to know what questions to ask when I have no idea what I'm talking about. I bet this will send me in the right direction, thanks!! 🙂

        Kind of off topic (well, yes it is off topic)!
        Brett you need to include the frog again, not that anything is wrong with the present one but I liked the frog, it just ain't you without it!

          Okay, long drawn out answer to follow.....:

          You'd need a few pages obviously.

          Login
          The page initially to do the login. This page would either post to itself or to a verification page where a query is run against the database table "users" and the username and password are checked. If verified, they are shown the "Add" page. If they aren't verified, they are redirected to the login page and shown some sort of error message.

          Add
          The page to add the information would be just like the login in that you have a form that posts either to itself or to another PHP page that deals with it. This page will take the posted form, verify that everything was submitted, submitted properly, and the expected values are there. Once the data is verified, you then escape all the input, and run a query/queries to insert the data into the tables "photos", "comments" and "categories / sections".

          The tables
          The tables are easy to understand. The users table has an ID field, a username, a password and any other info about your user (like Display name, email, etc.) you want. The ID is how other tables will link to a specific user.
          The photos table is the table that really contains everything while only containing numbers. The photos table would have at least the following: ID, userID, section/categoryID, commentID, photoPath, postedDate.
          All the ID columns would be integers referring to the IDs of the other tables (user, section/category, comments). The photoPath would store the path of your photo from the document root of your website. The posted Date would be just that, the date the photo was posted.
          Comments holds all the comments posters made about the photos. Basically, it's one comment per photo, but can be expanded to have viewers comment upon the photo later if you want. That's why it's a separate table, and not just another column in the photos table. It has the following fields: ID, comment.
          Sections/Cagetories is simple: it helps differentiate what category or section the photo is in. Maybe per project, or even per date range. But it should contain the following columns: ID, title. The section isn't required if you're doing just one project, or if you don't want it.

          The queries would basically query the photos table and JOIN the other tables (comments, section/cateogry) onto it. You'd get all your information in one query. The queries would look something like:

          Login

          SELECT 1
          FROM `users`
          WHERE username = '$username'
              AND password = '$password'
          LIMIT 1

          Post Photo

          INSERT INTO `comments` (comment) VALUES ('$comment');
          /**PHP: $commentID = mysql_get_insert_id($mysqlConn); **/
          INSERT INTO `photos` (userID, commentID, catID, photoPath, postedDate) VALUES ('$userID', $commentID, '$catID', '$photoPath', NOW());

          View Photos

          SELECT p.*, s.title, c.comment
          FROM photos AS p
          INNER JOIN section AS s
              ON p.sectionID = s.ID
          INNER JOIN comments AS c
              ON p.commentID = c.ID
          ORDER BY p.ID DESC
          LIMIT 0, 10;

          This would show the 10 most recent photos.

          I hope that helps you out a bit. But of course, if you need clarification of any functions, crack open the mySQL or PHP manual.

          @:
          I can't say that the frog will come back.... but maybe it will make an appearance....

            You are fabulous. Thank you so much for the addtional details. 🙂

            Hopefully I'll be able to whip something up for them. We shall see! Thanks again!

              Write a Reply...