How do i get my jquery variable in to a php variable, I've made a php document with jquery in it, after clicking the image the css will change and you will see a bigger image next to it. I need to have the image source of the big image in a php variable to get information about the image from the database.
Codes in the php file:
<div id="box-content">
<?php
$con=mysqli_connect("localhost","root","root","database");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM image");
while($row = mysqli_fetch_array($result)) {
echo "<img src='". $row['url'] ."' class='media-image' />";
}
mysqli_close($con);
?>
</div>
<div id="image-info">
<div id="image">
<img src="" id="bigimage"/>
</div>
Code in js file:
$(function () {
"use strict";
$('.media-image').click(function () {
$(this).toggleClass('media-image-selected');
});
$('.media-image').click(function () {
var src = $(this).attr('src');
$('#bigimage').attr('src', src);
});
});