Jump to content

Timalan

New Members
  • Posts

    1
  • Joined

  • Last visited

Timalan's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am a Noob at javascript so here goes. I have a slider carousel that is displayed when the webpage loads. It displays a line of images that when clicked on are displayed in larger form below it. I just want know how to automatically load (when the page firsts loads) the last uploaded on the page and then when another image is clicked from the slider carousel its loaded in its place? 2 files index and getuser.php index.php < script type="text/javascript"> jQuery(document).ready(function() { jQuery('.first-and-second-carousel').jcarousel() jQuery('#mycarousel').jcarousel({ start: 5 }); }); function showUser(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft\l ".XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getuser.php?q="+str,true); xmlhttp.send(); } </script> <ul id="first-carousel" class\l "="first-and-second-carousel jcarousel-skin-tango"> <li><?php $con = mysql_connect("localhost","base","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("users", $con); $sql = "SELECT * FROM contest ORDER BY member_id DESC"; $result = mysql_query($sql); while($file = mysql_fetch_array($result)){ echo '<li>'; echo '<a href="#" id="'.$file['member_id'].'" onclick="showUser(this.id)"><img src="'.$file['filelocation'].'" width="80" height="95" border="1"></a>'; echo '</li>'; } mysql_close($con); ?></li></ul> <div id="txtHint" style="text-align: center;"> </div> -------------------------------------------------------------------- getuser.php < ?php $q=$_GET["q"]; $con = mysql_connect("localhost","base","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("users", $con); $sql="SELECT * FROM contest WHERE member_id = '".$q."'"; $result = mysql_query($sql); while($file = mysql_fetch_array($result)){ echo '<div align="center" ><img src="'.$file['filelocation'].'" width="650" height="500" border="0"><br> < td>'.$file['title'].'</td><td><br> < td>'.$file['description']. '</td> < /div>'; } mysql_close(); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.