I am trying to send an array value in a parameterised function but i dont know why i am not able to do it. The sample code is :
<ul>
<?php
while ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) {
$photoname = $row['photoname'];
$string = array();
$recreated = 'cmVjcmVhdGVk/';
$thumb = 'dGh1bWI=/';
$original = 'b3JpZ2luYWw=/';
$filePath = "albums/$album/$album$thumb";
$dir = opendir($filePath);
while ($file = readdir($dir)) {
$info = pathinfo($file);
if (($info["extension"] == "jpg") || ($info["extension"] == "gif") || ($info["extension"] == "png")) {
$string[] = $file;
}
}
}
while (sizeof($string) != 0) {
$img = array_pop($string);
$fileBigPath = "albums/$album/$album$recreated";
echo "<li class='ui-state-default'><a href='#' onclick='details(" . $img . "); return false'><img src='$filePath$img'></li>";
}
?>
</ul>
</div></div>
<script>
function details(id) {
alert(id);
params = "id=" + encodeURIComponent(id);
alert(params);
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
lBackground = document.createElement('div')
lBackground.className = "lBackground";
lBackground.setAttribute("id", "lBackground");
lBox = document.createElement('div');
lBox.className = "lBox";
lBox.setAttribute("id", "lBox");
lContents = "";
lContents = xmlhttp.responseText;
lBox.innerHTML = lContents;
document.body.appendChild(lBox);
document.body.appendChild(lBackground);
}
}
xmlhttp.open("POST", "abc.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send(params);
}
</script>
this is the sample code.
What i want is, i want the file name to be send as a param