0
i have a upload.php page where user can upload images to database.
now i want to create gallery.php. where  who ever is loged in can view all his photos from database.
here is my struct for my gallery.php file

gallery.php
______________________________________
(1)at top there is going to be menu and random text, titles...etc  (already done)
(2)here i want to display all his photos backwards from database. so newest image is at top.
   when displaying i want to have 4 cols and infinity # of rows. note. there is no next or pre button. all one pages
(3)some random text here(already done)
----------------------------------------------------------------------

for step (2)
(2.1)i would have to read from image database and get a image i have a get.php file to do this 


    <?php 
    /*Get image from database. */
    session_start();
    include("connect.php");

    $user_id = $_SESSION['user_id']; 

    $image = mysql_query("SELECT * FROM image WHERE user_id = $user_id ORDER BY image_id DESC");
    $image = mysql_fetch_assoc($image); //get access to image table
    $image = $image['image'];
    echo base64_decode($image); 
    ?>          


(2.2)after that i need to create table with  4 cols and  infinity # of rows.       // I DONT NOW HOW TO DO THIS PART
 i guess i will have a html table with 4 cols but how to put infinity #of rows.

(2.3) print them to html table? starting from last image_id.                        //Also need help


-i guess i will a some kind of while loo?
while(there are no images left)
{

}

Edited by hwoarang69

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by jeremym001
1

Hi,

Here's one way to print a table with four columns and however many rows you need:

echo '<table>'; // Your table
echo '<tr>'; // first table row

$count = 0;
while($image = mysql_fetch_assoc($image_result))
{
    // Output your image here in a <td> etc

    $count++;
    if($count == 4)
    {
        echo '</tr><tr>'; // Start a new row at 4 cells
        $count = 0;
    }
}

echo '</tr>';
echo '</table>';

Hope this helps

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.