Ciao, ho uno script che il quale mostra nella index.php le immagini prelevate dal database, fin qui ci sono riuscito perfettamente. 
La parte di codice è questo:
	
	
	
		
Ora vorrei che ogni immagine avesse la sua relativa pagina, come vedete ho gia puntato ogni immagine al loro teorico link "show.php?id=" va perfettamente, ma il dunque appunto è quello di costruire la pagina show.php
Come fare? incollo quello che sarebbe ASPhoto.php
	
	
	
		
Vi prego, chiedo il vostro aiuto se è necessario qualcos altro non ci sono problemi,
grazie mille
				
			La parte di codice è questo:
		PHP:
	
	                    <?php $ASPhoto = new ASPhoto(); ?>
                    <?php $photo = $ASPhoto->getFilename(); ?>
                    <?php foreach($photo as $filename): ?>
                    <div class="col-lg-3 col-md-4 col-xs-6 thumb">
                    <a href="show.php?id=<?php echo $filename['photo_id']; ?>" class="thumbnail"><img src="http://forum.mrwebmaster.it/images/<?php echo e($filename['filename']); ?>" class="img-responsive"/></a>
                    <div class="caption">
                    <h3><?php echo e($filename['posted_by_name']); ?> </h3>
                    <p><?php echo ASLang::get('at'); ?> <?php echo $filename['post_time']; ?></p>
                    </div>
                    </div>
                    <?php endforeach; ?>
	Ora vorrei che ogni immagine avesse la sua relativa pagina, come vedete ho gia puntato ogni immagine al loro teorico link "show.php?id=" va perfettamente, ma il dunque appunto è quello di costruire la pagina show.php
Come fare? incollo quello che sarebbe ASPhoto.php
		PHP:
	
	/**
 * Photos class.
 */
class ASPhoto {
    /**
     * @var Instance of ASDatabase class itself
     */
    private $db = null;
    /**
     * Class constructor
     */
    function __construct() {
        $this->db = ASDatabase::getInstance();
    }
    /**
     * Inserts photos into database.
     * @param int $userId Id of user who is posting the photo.
     * @param string $filename
     * @return string JSON encoded string that consist of 3 fields:
     * user,filename and postTime
     */
    public function insertFilename($userId, $filename) {
        $user     = new ASUser($userId);
        $userInfo = $user->getInfo();
        $datetime = date("Y-m-d H:i:s");
        $this->db->insert("as_photo",  array(
            "posted_by"      => $user->id(),
            "posted_by_name" => $userInfo['username'],
            "filename"        => strip_tags($filename),
            "post_time"      => $datetime
        ));
        $result = array(
            "user"      => $userInfo['username'],
            "filename"   => stripslashes( strip_tags($filename) ),
            "postTime"  => $datetime
        );
        return json_encode($result);
    }
    /**
     * Return all photos left by one user.
     * @param int $userId Id of user.
     * @return array Array of all user's photos.
     */
    public function getUserPhoto($userId) {
        $result = $this->db->select(
                    "SELECT * FROM `as_photo` WHERE `user_id` = :id",
                    array ("id" => $userId)
                  );
        return $result;
    }
    /**
     * Return last $limit (default 10) photos from database.
     * @param int $limit Required number of photos.
     * @return array Array of photos.
     */
    public function getFilename($limit = 10) {
        return $this->db->select("SELECT * FROM `as_photo` ORDER BY `post_time` DESC LIMIT $limit");
    }
}
	Vi prego, chiedo il vostro aiuto se è necessario qualcos altro non ci sono problemi,
grazie mille
			
				Ultima modifica di un moderatore: