PHP - Link Image Php
Similar TutorialsHi I've got this database I created with fields ProductId ProductName Image I've managed to get it to list the ID,productname, and Image urls in a list. My next step is to have the image field actually display an image and make it clickable: heres what I've done so far: Code: [Select] <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("productfeed", $con); $result = mysql_query("SELECT * FROM productfeeds"); echo "<table border='0'> <tr> <th>Firstname</th> <th>Lastname</th> <th>Image</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ProductID'] . "</td>"; echo "<td>" . $row['ProductName'] . "</td>"; echo "<td>" . $row['ImageURL'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Heres what I want to do: Code: [Select] while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ProductID'] . "</td>"; echo "<td>" . $row['ProductName'] . "</td>"; // my changes beneath echo "<td>" . <a href="<?php echo $row['ImageURL'];?>"> <img src="<?php echo $row['LinkURL']; ?>"> </a>. "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Can you guys point me in the right direction? Many thanks I have a line like this it prints text link but I prefer image link how should i edit it I would appreciate some feedback Code: [Select] $templates['etiket'] = array('name' => t('ETİKET'), 'module' => 'uc_invoice_pdf', 'path' => $templates_uc_invoice_pdf_path, 'pdf_settings' => $pdf_settings); Hi, I've read a lot of places that it's not recommended to store binary files in my db. So instead I'm supposed to upload the image to a directory, and store the link to that directory in database. First, how would I make a form that uploads the picture to the directory (And what kinda directories are we talking?). Secondly, how would I retrieve that link? And I guess I should rename the picture.. I'd appreciate any help, or a good tutorial (Haven't found any myself). It is easy to get image or link by DomDocument, but I did not find a way to get image with its target link. Imagine a html as Code: [Select] <div class=image> <a href='http://site.com'><img src='imagelink.jpg'></a> </div>How to get both the image link and href? $dom = new DOMDocument(); @$dom->loadHTML($html); $xpath = new DOMXPath($dom); $hrefs = $xpath->evaluate("/html/body//div[@class='image']"); for ($i = 0; $i < $hrefs->length; $i++) { $href = $hrefs->item($i); Now to get the image and its href, we need first getElementsByTagName('a') and getElementsByTagName('img') but they do not work inside foreach. What's your idea? Hello. Well I haven't any code for this, but its only a question. Do you think it would be possible for PHP, to make and image or draw one from just a blank JPG. Then placing text on the image. That is possible and quite simple. But do you think it is possible to say. Say if you have 3 different set of texts on the image. Click here for 1 Click here for 2 Click here for 3 And also for the script to link those text to different web addresses. But all still workable with a dynamic signature EG [ img ] [ / img ] Basically its a dynamic signature with links on it is what i am trying to say. Do you think its possible? Or am I thinking to big. What I'm trying to do is have it match up the image file name wiht the same name as the link. Sometimes it does but sometimes obviously the image is random. Any ideas? Code: [Select] function spotlight($dbc){ $query = " SELECT * FROM characters WHERE characters.statusID = 1 AND characters.styleID = 1 ORDER BY RAND() LIMIT 1"; $result = mysqli_query($dbc, $query); $row = mysqli_fetch_array($result); $shortName = $row[ 'shortName' ]; $labels = array('shortName'); $img = array(); if($handle = opendir('images/spotlight/')) { $count = 0; while (false !== ($file = readdir($handle))) { if(strlen($file) > 2){ $img[$count] = $file; $count++; } } } echo "<a href='bio.php?shortName=" . $shortName . "'><img src='/images/spotlight/".$img[rand(0, (count($img)-1))]."' alt=Spotlight border=0 /></a>"; } Hello guys, I have created a mini image hosting website. Well, I have successfully coded the file upload, including security to allow certain image extensions and size as a beginner in PHP. However, only one thing remains is the image link. You can view the website on this address http://mini-image-hosting.99k.org/ where it is currently hosting on a free web hosting account with a free sub-domain. Right now, only the image can be uploaded and is being stored in a directory. Nevertheless, I want that when the person uploads an image, he gets also the link, for example: http://mini-image-hosting.99k.org/xxx.jpg something like that. Can you help me for this? Greetings! I have a website www.lanceronlinejobs.com/our_franchises.php I have a franchise images. I want to display each franchise record from database whenever a user click on franchise link. Here is my code. ourfranchises.php code: Code: [Select] <?php include('fconnection.php'); $sql = mysql_query("SELECT * FROM tbl_franchise ORDER BY id DESC") or die(mysql_error()); $row3 = mysql_fetch_array($sql); ?> <a href="franchiseDetails.php?city=<?php echo $row3['city'];?>"><img src="images/lbatkhela.jpg" width="150" height="150" alt="Batkhela" /></a>---------------------------------------------------------------------- franchiseDetails.php code: Code: [Select] <?php $id = $_GET['id']; $query = "SELECT * FROM tbl_franchise WHERE id = '$id' ORDER BY id DESC LIMIT 1"; $result = mysql_query($query); if (!$result) { echo "NO RECORD FOUND"; } else { while($row3 = mysql_fetch_array($result)): ?> Manager Name: <?php echo $row3['manager_name'];?> Please help me. Any help would be appreciated. Thanks. I'm wondering if anyone can help me find/create a script which allows a preview of a link to be generated? Basically I need a user to be able to simply enter a url and click submit and then a preview of that link will be shown in the form of some text and an image. Very similar to what Facebook does when a user shares a link. I think they use the description tag of the site in general. Can anyone point me in the right direction in doing this? I need to be able to do it in php/javascript alone without the use of jquery or plugins. Hi
I'm trying to change an image when a certain link is clicked. The image is a logo of a company and the links that will be clicked is english, arabic, and Chinese.
So if someone clicks on Chinese then the logo changes to the Chinese version of the normal logo.
Here is my html
<?php $langArabic=''; $langChinese=''; $langSpanish=''; $langEng=''; $linkArabic=getSEOLink($page_id); $linkChinese=getSEOLink($page_id); $linkSpanish=getSEOLink($page_id); $linkEng=getSEOLink($page_id); $queryLink = mysql_query("SELECT * FROM $_SEO_TABLE WHERE `id_page`='".$page_id."'"); if(mysql_num_rows($queryLink) > 0){ $resultLink = mysql_fetch_object($queryLink); if($resultLink->url != ''){ $linkEng = $_HTTP_ADDRESS."".$resultLink->url; if($page_id == 1 || $page_id == '1'){ $linkEng = $_HTTP_ADDRESS; } } if($resultLink->url_arabic != ''){ $linkArabic = $_HTTP_ADDRESS."".$resultLink->url_arabic; } if($resultLink->url_chinese != ''){ $linkChinese = $_HTTP_ADDRESS."".$resultLink->url_chinese; } if($resultLink->url_spanish != ''){ $linkSpanish = $_HTTP_ADDRESS."".$resultLink->url_spanish; } } switch (urlExtension()) { case 'html': $langClass = ''; $langEng='langActive'; $langTag='en'; break; case 'ar': if($page->title_arabic == ''){ $langClass = '_arabic'; }else{ $langClass = '_arabic'; } $langArabic='langActive'; $langTag='ar'; break; case 'es': $langClass = ''; $langSpanish='langActive'; $langTag='es'; break; case 'cn': $langClass = ''; $langChinese='langActive'; $langTag='cn'; break; default: $langClass = ''; $langEng='langActive'; $langTag='en'; } ?> <a class="main-logo<?php echo $langClass;?>" href="javascript:void(0);"><img src="<?php echo $_HTTP_ADDRESS;?>images/logo-letters.png" /></a> <div class="language-selection-wrapper<?php echo $langClass;?> overlay-bg<?php echo $langClass;?> border-bottom-white<?php echo $langClass;?> padding-level-one<?php echo $langClass;?>"> <div class="language-inner-wrapper<?php echo $langClass;?>"> <a class="<?php echo $langEng;?>" href="<?php echo $linkEng;?>">English</a><span>|</span> <a class="<?php echo $langArabic;?>" href="<?php echo $linkArabic;?>">العربيّة</a><span>|</span> <a class="<?php echo $langSpanish;?>" href="<?php echo $linkSpanish;?>">Español</a><span>|</span> <a class="<?php echo $langChinese;?>" href="<?php echo $linkChinese;?>">中文</a> <div class="clearboth"></div> </div> I have an image which is a complete image that has 4 titles(aquatic weeds,green algae,water quality,bottom muck) Can i write a code somehow that when i hover over those images or title i can link it to different hyperlinks? Hello i kinda new to programing mostly learning myself stuf there so i need some help to figure out. so i have lets say static link who always same and i write something in input field and press search button. so i get new link and immediately going to dat link, which means i leaving my site. in my case i working with image so my problem, is it somehow possible to display image in same page while writing someting in input field when presing button and image just change down below not going directly to link ? P.S. sory for my english
i have this code
<html> <body>
<center>
<form action="#" method="POST">
</form>
<?php require_once 'linkgenerator.php' ?>
PHP link generator code
<?php
Edited March 18, 2020 by eagle101 I basically have a PHP Search Form, and when a user fills in a form it outputs the results. Each result displays a image of a property, how could i make them images have their own unique link which will take them directly to the page of the property being shown? Im using PHP and mySQL tables Any help is appreciated, Thank You. Heres the PHP that outputs the results: Code: [Select] <?php require_once 'mstr_ref.php'; function san($input){ if(get_magic_quotes_gpc()){ $input=stripcslashes($input); } $output = mysql_real_escape_string($input); return $output; } if(isset($_POST['submit'])){ $pVars = array('area'=>$_POST['areas'], 'propType'=>$_POST['prop_type'], 'saleType'=>$_POST['ptype'], 'minB'=>$_POST['min_bedrooms'], 'maxB'=>$_POST['max_bedrooms'], 'minP'=>$_POST['min_price'], 'maxP'=>$_POST['max_price']); foreach ($pVars as $k=>$v){ $v = san($v); } $sql = new makeQuery(); $sql->manAdd('location_id', $pVars['area']); if($pVars['propType'] != 'Any'){ $sql->manAdd('catagory_id', $pVars['propType']); } if ($pVars['maxB'] > 0){ $sql->manAdd('bedrooms', $pVars['maxB'], '<='); } if($pVars['minB'] > 0){ $sql->manAdd('bedrooms',$pVars['minB'],'>='); } if($pVars['saleType'] != 'Any'){ if($pVars['saleType'] == "forsale"){ $sql->manAdd('market_type', 'sale'); if($pVars['minP'] != 0){ $pVars['minP'] = $pVars['minP'] * 1000; } if($pVars['maxP'] != 0){ $pVars['maxP'] = $pVars['maxP'] * 1000; } } if($pVars['saleType'] == 'forrent'){ $sql->manAdd('market_type', 'rent'); } } $qry = $sql->sqlStart.$sql->stmt.'Group By property.id'; $results = mysql_query($qry) or die (mysql_error()."<br />|-|-|-|-|-|-|-|-|-|-|-|-<br />$qry"); if(mysql_num_rows($results) < 1){ die ("Sorry, No Results Match Your Search."); } while($row = mysql_fetch_assoc($results)){ echo '<div class="container" style="float:left;">'; echo '<div class="imageholder" style="float:left;">'; echo "<img class='image1' src='{$row['image_path']}' alt='{$row['summary']}'> <br />"; echo '</div>'; echo '<div class="textholder" style="font-family:helvetica; font-size:14px; float:left; padding-top:10px;">'; echo "{$row['summary']}"; echo "<span style=\"color:#63be21;\"><br><br><b>{$row['bedrooms']} bedroom(s) {$row['bathrooms']} bathroom(s) {$row['receptions']} reception room(s)</b></span>"; if($row['parking'] != null){ echo "<span style=\"color:#63be21;\"><b> {$row['parking']} parking space(s)</b></span>"; } echo '</div>'; echo '<div style="clear:both"></div>'; } } else{ echo "There was a problem, please click<a href='index.php'> Here </a>to return to the main page and try again"; } ?> Hey everyone, I could use some help with this one.. I need to create some php code to switch images when a certain page loads. For example: These are the pages, test1, test2,test3, so when you click on the test1 link in the navigation a certain image would show up : something like this: If test1 exists then show image1.jpg If test2 exists then show image2.jpg If test3 exists then show image2.jpg. I am doing this in wordpress and I can't figure out the if then statement.. Does anyone have any ideas?? thanks I have a page with links to images. Currently the images open in a blank browser window, and I think this is too plain. I don't want to create an HTML file for each image. I want to have an 'image display php file' - img_temp.php. Along with the reference to the image file, in the link, I want to also be able to send a <title> to the template file. I think the code below shows kinda' what I'm trying to do, and also shows that I don't quite have a grasp on how to do it. Any tips would be appreciated. Index Page (index.php) Code: [Select] <html> <head> <title>Gallery Links</title> </head> <body> <!-- This is the page with the links to the images --> <ul> <li><a href="img_temp.php?file=images/01.jpg<?php ?title = "This is image 1"?>">Image 01</a></li> </ul> </body> </html> Image Display Template (img_temp.php) Code: [Select] <html> <head> <title><?php echo $title ?></title> </head> <body> <!-- This is the page that displays the sent image and displays the appropriate doc title --> <?php //Output the image $file echo $file; ?> </body> </html> Hi.. I am relatively new. I am trying to show an image link in my code below: $image = "<img src=<imgpg/" . $part_no . ".JPG />"; <td class = "guide_body" width = "66%"></td><td align = "center"><?php echo $image;?> There is more code but these are the problem lines I believe. Both are within the php environment.
This is producing:
It is supposed to look like this: So it is adding %3C for some reason between localhost and imgpg directory. I have no idea why this is happening. Is there something I can do to prevent this from happening? Or is there something I can do to erase the extra characters. (I'm not sure if they might be different though at some point. I have the same problem both on my local computer and the remote server.) Thanks very much for any help!! Hi, I'm not super fluent in PHP or whatnot, but I currently have a website set up with an index.php to load the content pages within it. As part of the template, it consists of a header image, links, a photo, and a video. The content of each page loads within the specified area below the "template". Here's my question: My client wants to see a specific picture when they click one of hte links. For example, if they clicked on spot removal, the image beside the navigation should show spot removal and stay there on the index page while the content page, spot removal is shown. Does this make sense? I need help and fast. Screenshot included in attachment. And like I said, I'm not super fluent in PHP/MYSQL, so be very detailed when talking about what to do. I'd appreciate the help. Thanks, Is there a way to use php to incorporate a folder of pictures as a clickable slideshow. For instance.... using a pic as a button... to go to the next pic.... except in quantities of 100... without having to manually write the code for each page...? In HTML: Code: [Select] <a href="index3.html"><img src="2.jpg" /></a> <a href="index4.html"><img src="3.jpg" /></a> <a href="index5.html"><img src="4.jpg" /></a> <a href="index6.html"><img src="5.jpg" /></a> <a href="index7.html"><img src="6.jpg" /></a> <a href="index8.html"><img src="7.jpg" /></a> <a href="index9.html"><img src="8.jpg" /></a> Something like using a basic rotating script activated on mouse click? How do i convert this into a button without making 100 pages? Code: [Select] <img src="/path/to/images/ rotate.php?img=my_static_image.jpg" /> I have come up with the rotate.php file as following: Code: [Select] <?php $folder = '/oprah/is/sofuckingfat.com/images/'; $extList = array(); $extList['gif'] = 'image/gif'; $extList['jpg'] = 'image/jpeg'; $extList['jpeg'] = 'image/jpeg'; $extList['png'] = 'image/png'; /* I believe that most of the following can be omitted once it hits the timer / countdown script */ $img = null; if (substr($folder,-1) != '/') { $folder = $folder.'/'; } if (isset($_GET['img'])) { $imageInfo = pathinfo($_GET['img']); if ( isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) && file_exists( $folder.$imageInfo['basename'] ) ) { $img = $folder.$imageInfo['basename']; } } else { $fileList = array(); $handle = opendir($folder); while ( false !== ( $file = readdir($handle) ) ) { $file_info = pathinfo($file); if ( isset( $extList[ strtolower( $file_info['extension'] ) ] ) ) { $fileList[] = $file; } } closedir($handle); if (count($fileList) > 0) { $imageNumber = time() % count($fileList); $img = $folder.$fileList[$imageNumber]; } } if ($img!=null) { $imageInfo = pathinfo($img); $contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ]; header ($contentType); readfile($img); } else { if ( function_exists('imagecreate') ) { header ("Content-type: image/png"); $im = @imagecreate (100, 100) or die ("Cannot initialize new GD image stream"); $background_color = imagecolorallocate ($im, 255, 255, 255); $text_color = imagecolorallocate ($im, 0,0,0); imagestring ($im, 2, 5, 5, "IMAGE ERROR", $text_color); imagepng ($im); imagedestroy($im); } } ?> Would be more or less converting the rotate.php script into the base for the link structure. I assume the timing element in this script would be omitted with a replacement or nothing. I can't figure out what will be the quickest way to go about making the href follow the folder contents. I just want a basic click on the pic to go to the next one until it ends. Thoughts anyone? Hello.
I have a bit of a problem. When I fetch the link field from the database.i don't see an actual link on the page.
One more thing, what type of field should I use to store the link in the database? Probably there is where I went wrong.
All help is
|