Username:

Password:

Author Topic: PHP/HTML Image Problem  (Read 818 times)

Maggot

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 1
PHP/HTML Image Problem
« on: January 28, 2011, 06:53:26 PM »
First off, hello everyone. I'm new to this Forum and I could really use some assistance.

I've recently set-up PHP5 and Apache 2.2x and well I'm having some trouble with images that I cant for the life of me figure out. Lemme break it down for you. I'm working on designing a site on my machine to eventually make public.

Site Root directory:
C:/Design


I have 2 sub-directories /Main and /images.
The problem I'm having is with my images. I'm very familier with HTML, CSS, and javascript. However, this is my first attempt at manually scripting a page from PHP. I've used phpBB before mainly for forums.

The images will show when I set them in the body tag for backgrounds but when I try to place them on the page they dont show. I dont get a broken image box, but insted a little box that looks like a .BMP icon. The Image size is even outlined. I've tried moving the images to several differant directories but nothing. I'm not sure if its something in my PHP.ini file or my Apache config. I'm placing the images the same as you would a standard HTML document
Code: [Select]
<img src="c:/main/images/mainimage.jpg" alt="Title Image" height="150" width="800"> and I get nothing. I've tried using file://, and absolute but nothing. I've used the same images for a .HTML page to test them and they show perfectly. As soon as I add them to my .php page nothing. Getting a little frustrated so ANY help would be appreciated. Thanx in advance.

Maggot
Logged

Jackodye

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 1
Re: PHP/HTML Image Problem
« Reply #1 on: August 17, 2011, 02:43:21 AM »
I had the same problem about 2 months ago, And can't resolve it until now.

cashcars

  • Full Member
  • ***
  • Karma: +0/-0
  • Posts: 196
Re: PHP/HTML Image Problem
« Reply #2 on: February 02, 2012, 09:43:03 AM »
This problem will require you to create a single page that takes images from a directory and display them on a single page using a class. The page will show the smaller images in a table format. When an image is clicked it will open the larger version of the image in a new window.

Display six images per page by default. The user should be able to select between 4, 6, 8, or 10 images per page.

Here is the basic structure of the class I created. Created the file Gallery_class.php

code:

<?php

class Gallery {
private $directory;
private $images;
private $img_per_page;

function __construct($dir, $ipp=6) {
$this->images = array();
$this->directory = $dir;
$this->images_per_page($ipp);

}

# Opens the directory and reads in the files to be displayed
private function get_images() {

}

# Outputs HTML for the page with the images
public function display_page() {

print "<table>";

#loop thru images equal to $this->img_per_page
# if ( $i is even )
# print "</tr><tr>";
# print image tag with filename to image

print "</table>";

}

# Outputs HTML for just a single image, the large one
public function display_image($file) {

}

# Sets the number of images per page
public function images_per_page($num) {
# if $num is a valid number of images
# set $this->img_per_page to $num
# else
# set $this->img_per_page to 6
}

}

?>







PHP script. Create the file :- gallery.php

code:

<HTML><HEAD></HEAD><BODY>

<?php

require "_Gallery_class.php";

$dir = "images";
$ipp = @$_GET['ipp'];

# <a href="http://russet/gallery.php?ipp=6">6</a>
$image = @basename($_GET['file']); # just the filename

$gallery = new Gallery($dir, $ipp);

if ($image) {
$gallery->display_image($image);
} else {
$gallery->display_page();
}

?>
</BODY></HTML>




ANd third file will be gallery.html where I will have my interface.

code:

where I will have select button with option vlaue 4 6 8 10 and if user hits the button "displayimage" respective num of images will be displayed.

I am not able to configure how my .html .php and third file gallery_class.php will interact with each other.

Anybody can please help in this problem.I had written in text my logic but not able to create html file and interaction between them