Welcome, Guest
  • Author Topic: help with PHP & mySQL  (Read 1137 times)

    jiffyloop

    • Server what's that
    • *
    • Posts: 22
    • Flash-db Rules
      • View Profile
      • Email
    help with PHP & mySQL
    « on: 10/11/02, 14:09 »
    Hello

    I'm trying to make a dynamic database driven portfolio page. I have a mySQL database setup with the following columns: portfolioID, section, jobname, description and image

    I have it working now where it shows the first entry in the database. I want to add some prev / next buttons to call to the database and move to the next field. I guess calling the portfolioID would be the best bet. Would I need to call up a whole new PHP script for that??

    here is a sample of my code (be kind!! I know it sucks):

    $query = "select * from $table order by jobname asc";

    $result = @mysql_query($query);

    if ($result && @mysql_num_rows($result) > 0) {

    while($row = mysql_fetch_array($result))
    {

    $section = stripslashes($row['section']);
    $jobname = stripslashes($row['jobname']);
    $description = stripslashes($row['description']);
    $image = stripslashes($row['image']);

    print"&section=" . urlencode($section);
    print"&jobname=" . urlencode($jobname);
    print"&description=" . urlencode($description);
    print"&image=" . urlencode($image);

    Any help would be appreciated!!

    Jiffy Loop

    Musicman

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 2685
      • View Profile
      • Email
    Re:help with PHP & mySQL
    « Reply #1 on: 10/11/02, 16:29 »
    Hi,

    the simple mistake: if there are more images, the latest one (in mysql's delivery order) will overwrite all previous ones.
    If you have few entries, you could change your script to send
    &image$num=urlencode($image)
    and add
    &count=$num
    as last variable. Now the prev / next buttons would do something like
    image = _root["image"+num]
    to retrieve the actual data

    Musicman

    jiffyloop

    • Server what's that
    • *
    • Posts: 22
    • Flash-db Rules
      • View Profile
      • Email
    Re:help with PHP & mySQL
    « Reply #2 on: 10/11/02, 16:51 »
    Thanks Musicman!!

    Would I need to call back to the PHP script each time I hit the prev or next button? Or does it all stay in memory??

    JIF


    Musicman

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 2685
      • View Profile
      • Email
    Re:help with PHP & mySQL
    « Reply #3 on: 10/11/02, 17:02 »
    Hi,

    it is meant to stay in memory - that's why I said "if you have few entries"

    Musicman

    jiffyloop

    • Server what's that
    • *
    • Posts: 22
    • Flash-db Rules
      • View Profile
      • Email
    Re:help with PHP & mySQL
    « Reply #4 on: 10/11/02, 17:17 »
    What's considered "a few entries"? Are we talking 5, 10, 25, 40??

    Musicman

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 2685
      • View Profile
      • Email
    Re:help with PHP & mySQL
    « Reply #5 on: 10/11/02, 17:34 »
    Hi,

    let's say: once your text file (mostly combined descritions) starts to exceed 100kb, it really makes sense to get individual items or group of items. Also, if you want the server to search in the descriptions, you would better load individual entries.
    I
    Musicman