-1

How can I resize an image on mouse hover using PHP with $_GET? I know that this can easily be done with css or js but I want to know how to do it with php. I don't want to upload a file either. So let's say I have html code with an <img> tag and an image, how can I use PHP or $_GET to resize that image on hover?

EDIT: What i mean is to put the image between <a> tags and then when clicked it refreshes the page but adds the the name of the image to the url so then I could use $get to access and echo a style to resize it.

Jaap
  • 81,064
  • 34
  • 182
  • 193
buttonSmasher96
  • 133
  • 1
  • 11
  • That would involve Javascript and the file being transfered to the server. `$_GET` **is** a superglobal variable **in PHP**. – Charlotte Dunois Oct 30 '16 at 17:29
  • Read through the PHP manual about GD https://secure.php.net/GD – Charlotte Dunois Oct 30 '16 at 17:31
  • PHP is a server side language, it does not change anything in the users browser. So, as referenced by Charlotte above, what you're probably looking for is something involving **Javascript** as a form of CSS manipulation, which are both done *client side* (browser) rather than server side (PHP). You could use PHP to achieve a similar effect (with `$_GET`) using `AJAX` but that's horrifically longwinded: using Javascript to use PHP to talk to the server to do something that all the which can be done far easier and cleaner with simply *just* javascript. – Martin Nov 02 '16 at 14:59
  • The fact you ask this question at all tends to suggest using an Ajax Javascript/PHP routine will probably cause you more issues than you will solve, rather than just using a basic **Javascript** DOM manipulator. (And all references to Javascript in my comments I am also including JQuery) – Martin Nov 02 '16 at 15:01
  • Edit: Sorry I didn't read that you do intend the page to refresh, I was thinking you *didn't* want the page to refresh. My Misreading. `:-/` – Martin Nov 02 '16 at 15:03

2 Answers2

0

Resize question on Stack Overflow

PHP is server side and you would have to refresh your page to display a resized image on hover(although I'm not sure if you can implement action on hover without js) and if you don't want to refresh you need to use AJAX(and that requires Javascript)

Community
  • 1
  • 1
ii7scw
  • 351
  • 1
  • 3
  • 17
0

Going off of your edit, are you looking for something like this?

<?php

if(isset($_GET['image'])){
    echo "<img src={$_GET['image']} style='height: 100px; width: 100px;' />";
}
?>

<a href="?image=image_name.jpg"><img src="image_name.jpg" /></a>
Martin
  • 22,212
  • 11
  • 70
  • 132
Nathan
  • 366
  • 1
  • 6
  • Err, I would add some `$_GET` cleaning functionality to that code, which it does what the OP asks for, it doesn't do any checks on the data given to it, and no checks that the given values are valid or that they exist. – Martin Nov 02 '16 at 15:05