kafia Posted September 9, 2009 Share Posted September 9, 2009 hellow every one i makle script to uplaod image on my web page and next to see and manage the image galery its printing the category list but i like to have a thumbnail image disply with the catory and on every click that image should be changed. can any guy sole my this problem my code is as below. <?php include("config.inc.php"); // initialization $result_array = array(); $counter = 0; $cid = (int)($_GET['cid']); $pid = (int)($_GET['pid']); // Category Listing if( empty($cid) && empty($pid) ) { $number_of_categories_in_row = 4; $result = mysql_query( "SELECT c.category_id,c.category_name,COUNT(photo_id) FROM gallery_category as c LEFT JOIN gallery_photos as p ON p.photo_category = c.category_id GROUP BY c.category_id" ); while( $row = mysql_fetch_array( $result ) ) { $result_array[] = "<a href='viewgallery.php?cid=".$row[0]."'>".$row[1]."</a> "."(".$row[2].")"; } mysql_free_result( $result ); $result_final = "<tr>\n"; foreach($result_array as $category_link) { if($counter == $number_of_categories_in_row) { $counter = 1; $result_final .= "\n</tr>\n<tr>\n"; } else $counter++; $result_final .= "\t<td>".$category_link."</td>\n"; } if($counter) { if($number_of_categories_in_row-$counter) $result_final .= "\t<td colspan='".($number_of_categories_in_row-$counter)."'> </td>\n"; $result_final .= "</tr>"; } } // Thumbnail Listing else if( $cid && empty( $pid ) ) { $number_of_thumbs_in_row = 5; $result = mysql_query( "SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."'" ); $nr = mysql_num_rows( $result ); if( empty( $nr ) ) { $result_final = "\t<tr><td>No Category found</td></tr>\n"; } else { while( $row = mysql_fetch_array( $result ) ) { $result_array[] = "<a href='viewgallery.php?cid=$cid&pid=".$row[0]."'><img src='".$images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' /></a>"; } mysql_free_result( $result ); $result_final = "<tr>\n"; foreach($result_array as $thumbnail_link) { if($counter == $number_of_thumbs_in_row) { $counter = 1; $result_final .= "\n</tr>\n<tr>\n"; } else $counter++; $result_final .= "\t<td>".$thumbnail_link."</td>\n"; } if($counter) { if($number_of_photos_in_row-$counter) $result_final .= "\t<td colspan='".($number_of_photos_in_row-$counter)."'> </td>\n"; $result_final .= "</tr>"; } } } // Full Size View of Photo else if( $pid ) { $result = mysql_query( "SELECT photo_caption,photo_filename FROM gallery_photos WHERE photo_id='".addslashes($pid)."'" ); list($photo_caption, $photo_filename) = mysql_fetch_array( $result ); $nr = mysql_num_rows( $result ); mysql_free_result( $result ); if( empty( $nr ) ) { $result_final = "\t<tr><td>No Photo found</td></tr>\n"; } else { $result = mysql_query( "SELECT category_name FROM gallery_category WHERE category_id='".addslashes($cid)."'" ); list($category_name) = mysql_fetch_array( $result ); mysql_free_result( $result ); $result_final .= "<tr>\n\t<td> <a href='viewgallery.php'>Categories</a> > <a href='viewgallery.php?cid=$cid'>$category_name</a></td>\n</tr>\n"; $result_final .= "<tr>\n\t<td align='center'> <br /> <img src='".$images_dir."/".$photo_filename."' border='0' alt='".$photo_caption."' /> <br /> $photo_caption </td> </tr>"; } } // Final Output echo <<<__HTML_END <html> <head> <title>Gallery View</title> </head> <body> <table width='100%' border='0' align='center' style='width: 100%;'> $result_final </table> </body> </html> __HTML_END; ?> Link to comment https://forums.phpfreaks.com/topic/173624-image-listing-problem-urgent-help-needed/ Share on other sites More sharing options...
pacholo Posted September 9, 2009 Share Posted September 9, 2009 here is a complete code!!!! have fun on it God bless. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <link rel="stylesheet" href="backbox.css" type="text/css" /> <script type="text/javascript" src="js/prototype.compressed.js"></script> <script type="text/javascript" src="js/scriptaculous.js?load=effects"></script> <script type="text/javascript" src="js/lightbox.js"></script> <script type="text/javascript" src="js/dhtmlHistory.js"></script> <script type="text/javascript" src="js/customsignsheader.js"></script> </head> <body> <br /> <fieldset align="left" style="width:600px; " > <legend> <span >(2)2008 Mass Commencement Exercises </span> </legend> <br /> <div style="width:600px; "> <? $handle = @opendir("images4"); $x=1; if(!empty($handle)) { while(false !== ($file = readdir($handle))) { //images4/" . $file(content of the picture if(is_file("images4/" . $file)) $rawPhoneNumber = $file; $ph = explode(".", $rawPhoneNumber); if(($ph[1]!="" && $ph[1]!="db") || $ph[1]=="jpeg" || $ph[1]=="bmp" || $ph[1]=="jpg" ){ ?> <div onclick="dhtmlHistory.add('location1',{message: 'backbox'});countdown()" style="width:125px; float:left; margin-left:3px; margin-top:3px; border-color:#CCCCCC; border-style:solid; border-width:3px; " > <a href= "<? echo "images4/" . $file; ?> " rel="lightbox[slide]" caption=" <? echo "Alumni Tracer System"; ?>"> <img src="<? echo "images4/" . $file; ?>" width="125" height="125" border="0" /></a></div> <a href="<? echo "images4/" . $file; ?> " rel="lightbox[slide]" caption="Waterfall"></a> <? $x++; } } } closedir($handle); ?> <script type="text/javascript" src="js/customsignsfooter.js"></script> </div> </fieldset> </body> </html> Link to comment https://forums.phpfreaks.com/topic/173624-image-listing-problem-urgent-help-needed/#findComment-915283 Share on other sites More sharing options...
kafia Posted September 9, 2009 Author Share Posted September 9, 2009 okz thank you for your reply but can you send me the complete code with java script files and css code. Link to comment https://forums.phpfreaks.com/topic/173624-image-listing-problem-urgent-help-needed/#findComment-915429 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.