Jump to content

Search the Community

Showing results for tags 'nested queries sql gallery'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hi there, I am trying to get images uploaded from a gallery to be organized under the author's id (displaying their name from the users table). I don't know if there are supposed to be different results (result1 result2 result3) either.... Thank you! Here is what the requirements are: $result1 = mysql_query("SELECT DISTINCT author_id FROM mugallery"); while ($row = mysql_fetch_array($result1)){ // nested query 1 { } // nested query 2 { } } // end outside query Inside this outside query, we will have 2 nested queries: 1. User data: One that uses the author_id from the mugallery table, and matches it to the user_id field of the users table. We can then retrieve first and last name of the author. • While we have the author name, create a <div> to contain them and echo out the name as a heading of sorts. 2. Gallery data: Another that retrieves all thumbnails from the gallery, but only WHERE the author_id matches the particular author in the current iteration of the loop from the outside query. Here is my code thus far: $result1 = mysql_query("SELECT DISTINCT author_id FROM mugallery"); while ($row = mysql_fetch_array($result1)){ $result2 = mysql_query("SELECT * FROM mugallery JOIN users ON mubdata.author_id = users.user_id "); while ($row = mysql_fetch_array($result2)){ $title = $row['title'] ; $description = $row['description']; $filename = $row['filename']; $imageid = $row['imageid']; $author_id = $row['author_id']; //echo $title . " | " .$description . " | " .$filename . " | " .$imageid; echo $author_id; }// end nested query 1 $result3 = mysql_query("SELECT * FROM mugallery WHERE author_id = !!!!! What to put here??!!!!!!!! "); while ($row = mysql_fetch_array($result3)){ $thisThumbHeader = " \n<div class=\"thumb\">"; $thisTitleToDisplay = "\n<div class=\"title\">$title</div>"; $titledescription = $title . ": " . $description; $thisImageCodePre = "<a href=\"display.php?imageid=$imageid\">"; $thisImageCode ="<img src=\"uploads/thumbs120/$filename\" /></a>"; $thisImageToDisplay = "\n<div class=\"image\">$thisImageCodePre$thisImageCode</div>"; $thisThumbFooter = " \n</div>"; $thisThumbToDisplay = $thisThumbHeader . $thisTitleToDisplay .$thisImageToDisplay.$thisDescriptionToDisplay .$thisThumbFooter ; echo $thisThumbToDisplay ; }// end nested query 2 } // end outside query
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.