3 Replies - 3701 Views - Last Post: 12 January 2009 - 10:22 AM Rate Topic: -----

#1 Ghost rider  Icon User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 158
  • Joined: 29-October 08

How to use this script with tab

Posted 07 January 2009 - 02:10 PM

The script images1.php is display images that are uploaded on directory(server) after been run. How can I intregate this script on tab.php script? I meant when I click on tab I can be able to view images that are upload in images1.php script. Thank in advance.

images1.php
<?php 
// Get our database connector
require("conn.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	 <head>
		  <title>List of Images</title>
	 </head>

	 <body>
	 
		  <div>

			   <?php	 
					// Grab the data from our upload2 table
					$sql = "select * from upload2";
					$result = mysql_query($sql) or die ("Could not access DB: " . mysql_error());
			
			echo "<table border=1>";
					while ($row = mysql_fetch_assoc($result))
					{
						// echo "<div class=\"picture\">";
						// echo "<p>";
			
			echo "<tr><td width=150>";
						 // Note that we are building our src string using the filename from the database
			 echo $row['name'] . " <br />";
						
			 echo "<img src=\"images/". $row['name'] . "\" alt=\"\" height=\"150px\" width=\"200px\" /> <br /></td></tr>"; 
						
						 // echo "</p>";
						 // echo "</div>";
					}
			echo"</table>";
			   ?>
		  
		  </div>
	 </body>
</html>

Here some part tab.php of code where I would like to intregate images1.php script
tab.php
<html>
<head>
		  <title>tabs</title>
	 </head>
<body>
<li><a href="#" rel="country3">Videos</a></li>
<div id="country3" class="tabcontent">Tab content 4 here<br />Tab content 4 here<br />
</body>
</html>


Is This A Good Question/Topic? 0
  • +

Replies To: How to use this script with tab

#2 pr4y  Icon User is offline

  • Location: 127.0.0.1
  • member icon

Reputation: 35
  • View blog
  • Posts: 621
  • Joined: 19-September 08

Re: How to use this script with tab

Posted 08 January 2009 - 04:43 PM

I'm not 100% sure what you are asking, but I think you are looking for something like this:

<?php
// code starts here
// then when you want to include your images file...

include('images.php');

// TA DA!
// rest of file code
?>


Was This Post Helpful? 0
  • +
  • -

#3 Ghost rider  Icon User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 158
  • Joined: 29-October 08

Re: How to use this script with tab

Posted 09 January 2009 - 05:37 AM

Thanks for your replay. I would try to explain step by step.

1- I create a tabs menu(photos, videos,etc) where users can choose which contents on tab they want to view.

2- I managed to create an images1.php script where the users can view pictures that they uploaded on system.

3-How can I intregate the images1.php script on tab menu(photos)? When users click on tab(photos) to display the pictures that are in images1.php script.

Thanks very much and if you have some doubts let me know.
Was This Post Helpful? 0
  • +
  • -

#4 pemcconnell  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 54
  • View blog
  • Posts: 472
  • Joined: 05-August 08

Re: How to use this script with tab

Posted 12 January 2009 - 10:22 AM

force the uploads into folders that are dedicated to the category.

e.g.

Uploads/images/

Uploads/videos/

Uploads/sound/

Then use a file loop to grab em all:

e.g.

This is a quick example which will grab any images in a folder:

<?php
$dir = '../Images/'; // SELECT FOLDER
$images = dirList($dir);

function right($value, $count){
	$value = substr($value, (strlen($value) - $count), strlen($value));
	return $value;
}

function dirList ($startdir) 
{
	$results = array();
	$handler = opendir($startdir);
	while ($file = readdir($handler)) {
		if ($file != '.' && $file != '..')
			$results[] = $file;
	}
	closedir($handler);
	return $results;

}

$lastmod = array();
function lastMod($file){
	global $lastmod;
	$lastmod[] = "'<'+'br/>".date('l jS \of F Y', filemtime($file))."<'+'br/>".date('h:i:s A', filemtime($file))."</'+'strong>'";
}
$filesize = array();
function ffileSize($file){
	global $filesize;
	$filesize[] = filesize($file);
}
$fileheight = array();
$filewidth = array();
function ffileDims($file){
	global $fileheight;
	global $filewidth;
	list($width, $height, $type, $attr) = getimagesize($file);
	$fileheight[] = $height." px'";
	$filewidth[] = $width." px'";
}

$x = 0;
foreach($images as $image){
	if((right($image, 3)=='gif') || (right($image, 3)=='jpg') || (right($image, 3)=='bmp') || (right($image, 3)=='tff')){
		lastMod($dir.$image);
		ffileSize($dir.$image);
		ffileDims($dir.$image);
			$imgs .= $dir.''.$image.'<br/>';
		$x++;
	}
}

if((strlen($imgs)<1)&&(strlen($initimgs)<1)){
	$imgs = 'No images in this folder.';
}else{
	$imgs = '<hr/><p><strong>Images:</strong></p>'.$imgs;
}
echo $initimgs.$imgs; ?>



For the videos, sounds etc... you just change the directory and the file types - you can pass these through to the script using GET / POST etc....

I also chucked in some image handling functions incase you want to return height, width and filesize... customise away matey :)

This post has been edited by pemcconnell: 13 January 2009 - 08:18 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1