MYSQL Database for displaying image and info

Discussion in 'Web Design and Development' started by geekindisguise, Nov 30, 2009.

  1. geekindisguise macrumors 6502

    geekindisguise

    Joined:
    Jul 22, 2008
    Location:
    Oklahoma
    #1
    Ok, I made a Website for a Jewelry store, and the page is done. They like it and everything, and I am the WebMaster and control it all. But to make it easier on me, I want to know how I can have a Secured page where I login and I upload a photo along with it's info. PHP would then split that image into 2 copies. One copy is 700x700 and the other will be 154x154. It uploads those two in the appropriate folders.
    I also want it to upload the image's name or path on the server. And in the same Row or Table on the database it will have the Store, Category, and all the description info stuff.....

    I would then have their pages display ALL the items for Just that page. (Category in a Store)

    So how can I possibly do this?
    OR where are some GREAT MYSQL (with PHP) tutorials?

    THANKS!
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    So, is there a particular part of that you want help with? Do you know how to interact with databases?
     
  3. geekindisguise thread starter macrumors 6502

    geekindisguise

    Joined:
    Jul 22, 2008
    Location:
    Oklahoma
    #3
    Well... Sort of. I know the basics. I can make new Databases and Tables and all that. And I can connect and display a table in PHP.

    A Big part I want to find out is how can I get PHP to upload and copy photos? Also resizing each copy.

    I know its possible because Wordpress does it. But I don't know how to do it myself.
     
  4. geekindisguise thread starter macrumors 6502

    geekindisguise

    Joined:
    Jul 22, 2008
    Location:
    Oklahoma
    #4
    OK, so another big question is: How can I get PHP to display my Database ROWS a certain way?

    I need them in Rows of 3 on the page. And in the rows they have IDs 1, 2, and 3.

    So how could I get PHP to display my entire database for that page into Rows with 3 pics per row. While also numbering the 3 differently?

    This seems a lot harder than the rest... And I don't know where to even start!
     
  5. Banacek macrumors 6502

    Joined:
    Jan 13, 2008
    #5
  6. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #6
    Here's one of many PHP file upload tutorials.

    Displaying DB rows in a certain way is pretty straight forward. Once you have a row you simply refer to the columns.
    PHP:
    $query "SELECT * FROM example"
    $result mysql_query($query) or die(mysql_error());
    $row mysql_fetch_array($result) or die(mysql_error());
    echo 
    $row['name']. " - "$row['age'];
    Since you'll be going through 1 -> 3 over again a common approach is to keep an iterator and then use a modulus operator.

    PHP:
    $x 0;
    while (
    $row mysql_fetch_array($result) or die(mysql_error())) {
      echo (
    $x++ % 3)+1// will output 1, 2, 3, 1, 2, ... as $x increases
    }
    So you can use that modulus value to create your table format.

    Most of what you want is a quick Google search away, though you'll likely need to read over multiple tutorials as you likely won't find one that shows you how to do everything you want.
     
  7. JohnDoe8450 macrumors member

    Joined:
    Feb 3, 2009
    #7
    tizag.com and wrschools.com both have good (quite similar actually) beginner tutorials. Displaying the info the way you want is more a matter of thinking it out.

    To display in rows of 3 items, angelwatt's method is very effective.

    If you want to get a simple backend going, you'll have to look into PHP sessions and md5 or other hashing. Make sure you protect yourself from SQL injection. A simple user login tutorial shouldn't be hard to come by.

    Make sure those are CSS classes, not IDs.
     
  8. geekindisguise thread starter macrumors 6502

    geekindisguise

    Joined:
    Jul 22, 2008
    Location:
    Oklahoma
    #8
    OK, so I found how to show all of my stored database info, but what I REALLY need is to have PHP automatically assign the 1, 2, 3 classes. And I want it to end a DIV after 3 items, then start a new DIV with 3 more items. How can I possibly do this?

    And then, when it gets to the end, instead of just having a row with only 1 item, I want it to fill in the blanks with a special item (Coming Soon item)

    IS ANY OF THIS POSSIBLE?
    PLease help. :confused: :D
     
  9. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA

Share This Page