PHP - What And How Is The Best Way To Use Lightbox For My Images?
Hi there to everyone
I have a bit of an issue, I am still new to all this coding, I need help on to display my images in my uploads folder with some sort of image lightbox viewer:
<?php
Similar Tutorialsok so for the second issue of the night, has anyone used lightbox with images that are fetched from a database (mysql)?? i have the following but it opens at the bottom of the page and not in a lightbox... echo '<a href="' . $row['image'] . '" rel="lightbox[roadtrip]"><img src="' . $row['image'] . '" width="100" alt=""></a>'; full code on attachment Hello! I have a simple form in a html popup window with javascript and i want to make the form to load in a lightbox and not in popup window I will use php to get the data from the form. Is this possible ? Have you got any reference on a tutorial about this ? I search in the web but things looks What are you suggesting me ? Thanks in advance! Doing a horizontal scrolling site project and trying to use Lightbox to show portfolio images. Here's the deal--I have everything working but there's one wrinkle. I have the gallery content loading in an iframe because that works best in the horizontal scrolling design. When you click on a thumbnail you can't go to another page like in a normal design because the site is one big page. So the page "album.php" loads in an iframe. However once it's loaded and you click on an image, the Lightbox loads in the iframe too which is not big enough to have the full screen effect I need. That's the wrinkle. Is there a way to modify the PHP code to have the lightbox content load in the full screen, something like target="parent" instead of in the iframe? Here's the link so you can see what I mean: http://staging.workshop-marketing.com/index-current.php#Approach The page in question, not in the iframe showing the full screen effect I need: http://staging.workshop-marketing.com/album.php Here's the code I think needs to be modified, however I'm not a PHP coder: <?php <br /> if(isset($_GET['s'])) { $opts = array( 'template' =>'c_list_image.html' ); perch_gallery_album($_GET['s'], $opts); } ?> Thanks for any suggestions and help-- Hi everyone, As a last resort to trying to figure out my problem I have made an account on phpfreak I'm wondering if anyone can help me with a problem that has been getting on my nerves for quite a few days now, I'll explain a little bit about it. I am having problems getting lightbox (or rather greybox) to work with my php script. I tested out the lightbox method on a blank html page and got it to work, but when i try and integrate it into my php coding where i echo out the pictures from the gallery echo "<a href='".$row['5']."'><img style='width:101px; height:101px; float:left; margin:5px;' src=' ".$row['4']. "' /></a> "; But when i put in the neccesary rel='gb_imageset[nice_pics]' into the code, it stops the gallery from working and posting any results from the database. If anyone could help me with this, i would greatly appreciate it. I'm sorry i cannot explain things any better, i admit to not being quite so proficient with php/sql, if it would help then someone COULD contact me on msn by protentus@hotmail.co.uk to request source files. Thanks for any help or even just a responce This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=333153.0 This question is PHP and javascript/jQuery so I wasn't sure where to post it, but anyway... Here is the code I am using so far. Currently it just displays a larger version of the image in a new window. I would like a lighbox instead. I have tried this with "FancyBox" but couldn't get it to work on all the images, just the first one. Any suggestions? Code: [Select] <?php //GET PRODUCT VAR etc. ^^ $directory = "Images/items/$product/"; //get all image files with a .jpg extension. $images = glob($directory . "*.jpg"); $imgone = $images[0]; $gallery = ''; foreach($images as $image) { $tn = explode("/", $image); $tnname = $tn[3]; $gallery .= '<a href="#" rel="'.$image.'" class="image" title="Images/items/'.$product.'/large/'.$tnname.'" alt="'.$product.'"><img src="Images/items/'.$product.'/thumbs/'.$tnname.'" class="thumb" border="1" style="margin-bottom:7px;"/></a> '; } if(is_dir("Images/items/".$product)){ $gallery .= "<div id='image' class='bigimg' align='left'>"; $gallery .= '<a href="largeimg.php?id='.$product.'&i=Images/items/'.$product.'/large/0main_img.jpg" target="_new"> <img src="Images/items/'.$product.'/0main_img.jpg" border="0" alt='.$name.'/> <span class="more"><img src="Images/zoom.png" /></span></a></div>'; } ?> <!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=utf-8" /> <title><?php echo $name; ?></title> <script type="text/javascript" src="js/ddsmoothmenu.js"></script> <script type="text/javascript" src="js/jquery.js"></script> <link href="CSS/style.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="CSS/ddsmoothmenu.css" /> </head> <body> <div class="hidden"> <script type="text/javascript"> $(function() { $(".image").click(function() { var image = $(this).attr("rel"); var large = $(this).attr("title"); var product = $(this).attr("alt"); $('#image').hide(); $('#image').fadeIn('slow'); $('#image').html('<a href="largeimg.php?id='+ product +'&i=' + large + '" target="_new"><img src="' + image + '"/><span class="more"><img src="Images/zoom.png" /></span></a>'); return false; }); }); </script> Hi all, I'm not sure if this is a PHP question or javascript, so if it needs to be moved can an admin please do so... Anyway, basically I have the following code: Code: [Select] <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">View Availability</a> This pops up a divs with a black alpha background, so that it appears the new content is displaying over the top of the current content. This all works fine, however the content I am displaying in the top level div is (or should be) dynamic. In order for the content to be useful I need to grab the id. Normally I would simply do this: Code: [Select] <a href = "[b]url.php?uniqueidentifier=<?php echo $row['id'];?>[/b]" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">View Availability</a> However what happens in this instance is that the page loads with the javascript and the id in the url but it then disappears... Has anyone got any ideas on how I might be able to get around this? Many thanks, Greens85 I have this script from http://lampload.com/...,view.download/ (I am not using a database) I can upload images fine, I can view files, but I want to delete them. When I press the delete button, nothing happens
http://www.jayg.co.u...oad_gallery.php
<form>
<?php $dir = dirname(__FILENAME__)."/images/gallery" ; $files1 = scandir($dir); foreach($files1 as $file){ if(strlen($file) >=3){ $foil = strstr($file, 'jpg'); // As of PHP 5.3.0 $foil = $file; $pos = strpos($file, 'css'); if ($foil==true){ echo '<input type="checkbox" name="filenames[]" value="'.$foil.'" />'; echo "<img width='130' height='38' src='images/gallery/$file' /><br/>"; // for live host //echo "<img width='130' height='38' src='/ABOOK/SORTING/gallery-dynamic/images/gallery/ $file' /><br/>"; } } }?> <input type="submit" name="mysubmit2" value="Delete"> </form>
any ideas please?
thanks
Hi guys I just want to know something. With php you can handle excel files by saving them as .csv files. Then the php script reads it line by line, and commas separating the fields. But is it possible that I can insert an image (small jpg or png) file in one of these fields...and then handle the image in the php script? Just for intrest I inserted an image in excel worksheet and it did not insert it into a cell, it float. Is there maybe another to insert it in the cell and then control it with php?? Thanx in advance Hey every i'm just trying to change my 'Read More' text after a blog post on my site into am image. Got some code that lets me change the actual text to something else, just can't find how to change the text into an image. Code: [Select] add_filter( 'the_content_more_link', 'child_content_more_link', 10, 2 ); function child_content_more_link( $more_link, $more_link_text ) { return str_replace( $more_link_text, 'my new read more text', $more_link ); } Thanks, Matty44m Ok, I have a GD image that is then rewrote as a png. My question is, is it possible to find out what site is requesting the image and then use it on the php image. Example, if I didn't want a domain to use my images, could I somehow me able to restirict that site? I'm creating a funeral home site and on the side of the page I would like to display the last 5 funeral obituaries that are in mySQL database (name and certain sized image (images are in "image" field) w/ a link to an "obituaries detail page for the individual deceased person"). I am able to do this successfully listing only the names....how can I list the image associated with the name? This is what I have so far: Code: [Select] <?php include("connect.php"); ?> Code: [Select] <?php $query = "SELECT id, deceased_name, deceased_date, DATE_FORMAT(deceased_date, '%M %D, %Y') as datetext"; $query .= " FROM scales_obits ORDER BY deceased_date DESC LIMIT 5"; $listings = mysql_query($query); if (!listings) { echo("<p>Error retrieving listings from lookup table<br>". "Error: " . mysql_error()); exit(); } echo("<table border=\"0\" width=\"100%\" class=\"obit\">"); while ($listing = mysql_fetch_array($listings)) { $deceased_name = $listing["deceased_name"]; $deceased_date = $listing["datetext"]; $id = $listing["id"]; echo("<tr><td width=\"100%\"><a href=\"obitdetail.php?id=".$id."\"><strong>".$deceased_name."</strong></a></td><td> </td>"); } echo("</table>"); ?> I had this page working fine where it retrieves a set of images from the database depending on what thumbnail was click on the previous page. Now I am trying to add an edit and delete button to each of the pictures and it will not display any of it now! This is the code I am using: Code: [Select] <?php $id = $_GET[id]; ?> <?php $max_items = 16; /* max number of news items to show */ require_once('config.php'); $db = mysql_connect (DB_HOST,DB_USER,DB_PASSWORD); if(!$db) { die('Failed to connect to server: ' . mysql_error()); } mysql_select_db (DB_DATABASE,$db); function displayNews($all = 0) { global $db, $max_items; if ($all2 == 0) { /* query for news up to $max_items */ $query13 = "SELECT image,id,description,projectcode,thumbnail " . "FROM project WHERE projectcode='$id' ORDER BY id DESC LIMIT $max_items"; } else { /* query for all news */ $query13 = "SELECT image,id,description,projectcode,thumbnail " . "FROM project WHERE projectcode='$id' ORDER BY id DESC"; } $result13 = mysql_query($query13) or print("<p>Error fetching entries from the database, error: " . "Statement: " . $query13 . "</p>" . mysql_error()); while ($row13 = mysql_fetch_array($result13)) { $title = htmlentities ($row13['description']); $news = nl2br (strip_tags ($row13['projectcode'], '<a><b><i><u>')); $image = $row13['image']; $thumbnail = $row13['thumbnail']; $id = $row13['id']; /* display the data */ echo "<div class='portfolioproject'>";?> <div class='boxgrid captionfull'> <a id="<?php echo $id ?>" class="example_group" href="images/gallery/<?php echo $image ?>" title="<?php echo $title ?>" rel="gallery"><img alt="" src="images/gallery/<?php echo $thumbnail ?>" width="122px" height="122px"</a> </a>} <?php //Check whether the session variable SESS_MEMBER_ID is present or not if(isset($_SESSION['SESS_MEMBER_ID']) || (!trim($_SESSION['SESS_MEMBER_ID']) == '')) { echo "<form class='editbtn' action='editportfolio.php' method='POST'>"; echo "<input type='hidden' name='idf' value='$id' />"; echo "<input src='images/editbtn.png' type='image' value='Edit' />"; echo "</form>"; echo "<form class='editbtn' action='deleteportfolio.php' method='POST'>"; echo "<input type='hidden' name='ide' value='$id' />"; echo "<input src='images/delbtn.png' type='image' value='Delete' />"; echo "</form>"; } else { echo ""; } echo "</div>"; } /* if not displaying all news, give a link to do so */ if ($all == 0) { echo "<div class='show_all'><a class='show' href=\"{$_SERVER['PHP_SELF']}" . "?action=all\">Show all</a></div>\n"; } } /* this is where the script decides what do do */ echo "\n"; switch($_GET['action']) { case 'all': displayNews(1); break; default: displayNews(); } echo "\n"; ?> <?php //Check whether the session variable SESS_MEMBER_ID is present or not if(isset($_SESSION['SESS_MEMBER_ID']) || (!trim($_SESSION['SESS_MEMBER_ID']) == '')) { echo "<span class='show_all'>"; echo "<a class='show' href='admincp.php'> Admin</a>"; echo "</span>"; echo "<span class='show_all'>"; echo "<a class='show' href='logout.php'> Logout</a>"; echo "</span>"; } else { echo ""; } ?> No error messages are displayed, only the 'show all' button, and the 'admin' and 'logout' buttons if signed in! Any help on this would be much appreciated! Thank you Martin Hi guys I have got this code here, giving quite a few errors and was wondering if anyone could help me sort it out, the script (should) run straight away just have to edit the database connect, I've tried manually creating the table and taking out the create table but when I try and upload an image I get these errors: Warning: move_uploaded_file(latest.img) [function.move-uploaded-file]: failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/php/image.php on line 23 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/Applications/XAMPP/xamppfiles/temp/php2lgspw' to 'latest.img' in /Applications/XAMPP/xamppfiles/htdocs/php/image.php on line 23 Warning: fopen(latest.img) [function.fopen]: failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/php/image.php on line 24 Warning: filesize() [function.filesize]: stat failed for latest.img in /Applications/XAMPP/xamppfiles/htdocs/php/image.php on line 25 Warning: fread() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/php/image.php on line 25 here is the code: Code: [Select] <?php // Connect to database $errmsg = ""; if (! @mysql_connect("localhost","root","")) { $errmsg = "Cannot connect to database"; } @mysql_select_db("test"); // First run ONLY - need to create table by uncommenting this // Or with silent @ we can let it fail every subsequent time ;-) $q = < < <CREATE create table pix ( pid int primary key not null auto_increment, title text, imgdata longblob) CREATE; @mysql_query($q); // Insert any new image into database if ($_REQUEST[completed] == 1) { // Need to add - check for large upload. Otherwise the code // will just duplicate old file ;-) // ALSO - note that latest.img must be public write and in a // live appliaction should be in another (safe!) directory. move_uploaded_file($_FILES['imagefile']['tmp_name'],"latest.img"); $instr = fopen("latest.img","rb"); $image = addslashes(fread($instr,filesize("latest.img"))); if (strlen($image) < 149000) { mysql_query ("insert into pix (title, imgdata) values (\"". $_REQUEST[whatsit]. "\", \"". $image. "\")"); } else { $errmsg = "Too large!"; } } // Find out about latest image $gotten = @mysql_query("select * from pix order by pid desc limit 1"); if ($row = @mysql_fetch_assoc($gotten)) { $title = htmlspecialchars($row[title]); $bytes = $row[imgdata]; } else { $errmsg = "There is no image in the database yet"; $title = "no database image available"; // Put up a picture of our training centre $instr = fopen("../wellimg/ctco.jpg","rb"); $bytes = fread($instr,filesize("../wellimg/ctco.jpg")); } // If this is the image request, send out the image if ($_REQUEST[gim] == 1) { header("Content-type: image/jpeg"); print $bytes; exit (); } ?> <html><head> <title>Upload an image to a database</title> <body bgcolor=white><h2>Here's the latest picture</h2> <font color=red><?= $errmsg ?></font> <center><img src=?gim=1 width=144><br> <b><?= $title ?></center> <hr> <h2>Please upload a new picture and title</h2> <form enctype=multipart/form-data method=post> <input type=hidden name=MAX_FILE_SIZE value=150000> <input type=hidden name=completed value=1> Please choose an image to upload: <input type=file name=imagefile><br> Please enter the title of that pictu <input name=whatsit><br> then: <input type=submit></form><br> <hr> By Graham Ellis - graham@wellho.net </body> </html> please help me to solve this problem : when my client want to remove a record all the related images must be deleted with it ,is that possible?? Hello I'm trying to make a php script that when run updates an image folder based on a photobucket feed. Here is my code so far. Code: [Select] <?php function download_feed($path) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $path); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 15); $retValue = curl_exec($ch); curl_close($ch); return $retValue; } $sXML = download_feed('http://feed242.photobucket.com/albums/ff185/xivanari/account.rss'); $oXML = new SimpleXMLElement($sXML); foreach($oXML-> channel->item as $oDocuments) { $fileName = $oDocuments->title; $fileTmpLoc = $oDocuments->link; if(!file_exists("album1/".$fileName."/")) { if(!mkdir("album1/".$fileName)) $upload_location = "album1/".$fileName; $moveResult = move_uploaded_file($fileTmpLoc, $upload_location); } } ?> Why is it that only certain images come through. I made sure all extensions were there but some jpegs come through others don't some pngs not others. Any thoughts? Code: [Select] <?php $hostname='yobb'; $username='ybbb'; $password='Anbbbb!'; $dbname='b29'; $usertable='bbbb; $myconn=mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.'); if ((($_FILES["file"]["type"] =="image/gif") || ($_FILES["file"]["type"] =="image/jpeg") || ($_FILES["file"]["type"] =="image/pjpeg") || ($_FILES["file"]["type"] == "image/png")) && ($_FILES["file"]["size"]< 200000)) { if ($_FILES["file"]["error"] >0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br/>"; } else { if (file_exists("uploads/" . $_FILES["file"]["name"])) { echo "File already exists. Choose another name."; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]); } } } else { echo "Invalid file"; } $path="uploads/" . $_FILES["file"]["name"]; $name=$_POST["name"]; $state=$_POST["state"]; if (!myconn) { die ('Could not connect: ' . $mysql_error()); } $db_selected=mysql_select_db('your1729',$myconn); if (!$db_selected) { die ('Can\'t use your1729 : ' . mysql_error()); } mysql_query("INSERT INTO photo(name,photopath,state) VALUES ('$name','$path','$state')") or die(mysql_error()); mysql_close($myconn); ?> Hi there, I need a little help...
I have simple form/code for upload image and insert it into db, and its working.
<form name="unos" action="" method="post" enctype="multipart/form-data"> <select name="kategorija"> <option value="1">Album</option> </select> <input type="file" name="uploaded_file[]" id="file" > </form> <?PHP include "config.php"; $uploads_dir = 'slike'; foreach ($_FILES["uploaded_file"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["uploaded_file"]["tmp_name"][$key]; $name = $_FILES["uploaded_file"]["name"][$key]; move_uploaded_file($tmp_name, "$uploads_dir/$name"); } } $sql="INSERT INTO galerija_slike (kategorija_id, url_slike) VALUES ('".$_POST['kategorija']."', '".$_FILES['uploaded_file']['name'][$key]."')"; if (mysql_query($sql)) { echo "success"; } else { echo "error" . mysql_error(); } ?>How can I store more image url's from input fields? When I add more input fields..... move_uploaded_file(): uploads all images, but I don't know how to also add them in db? I need something like this: <input type="file" name="uploaded_file[]" id="file" > <input type="file" name="uploaded_file[]" id="file" > <input type="file" name="uploaded_file[]" id="file" > <input type="file" name="uploaded_file[]" id="file" > <input type="file" name="uploaded_file[]" id="file" >Thanks Edited by Hrvoje, 02 February 2015 - 12:17 AM. |