jquery - How to load image from mysql database in NivoSlider -
how can load image mysql database in nivoslider. can't seem find solution this. create jquery image slider. need dynamically load images stored on mysql database.
any suggestions appreciated.
here script:
</script></div> <div class="jquery-script-clear"></div> </div> </div> <h1 style="margin-top:150px;" align="center">jquery nivo slider demo</h1> <div id="wrapper"> <div class="slider-wrapper theme-default"> <div id="slider" class="nivoslider"> <?php $connection = mysql_connect("localhost", "root", ""); // establishing connection server $db = mysql_select_db("user"); // selecting database $sql = mysql_query("select * images order image desc limit 10") or die(mysql_error()); while($row = mysql_fetch_array($sql)){ $image = $row['image']; $id = $row['id']; $pic = "upload/$image"; if (file_exists($pic)) { print '<img src=\"upload/$image\"/>'; $i++; } } ?> </div> </div> </div> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript" src="jquery.nivo.slider.js"></script> <script type="text/javascript"> $(window).load(function() { $('#slider').nivoslider(); }); </script> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setaccount', 'ua-36251023-1']); _gaq.push(['_setdomainname', 'jqueryscript.net']); _gaq.push(['_trackpageview']); (function() { var ga = document.createelement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getelementsbytagname('script')[0]; s.parentnode.insertbefore(ga, s); })(); </script>
updated code:
<?php $connection = mysql_connect("localhost", "root", ""); // establishing connection server $db = mysql_select_db("user"); // selecting database $sql = mysql_query("select * images order image desc limit 10")or die(mysql_error()); while($row = mysql_fetch_array($sql)){ $image = $row['image']; $id = $row['id']; $pic = "upload/".$image"; if (file_exists($pic)) { print '<img src=\"upload/$image\"/>'; $i++; } } ?>
for doing need server-side codes(like php, nodejs, asp.net).
the procedure this
1) create endpoint in server loading image data database. 2) write data client load , show image database using php
3) using images in sliders.
Comments
Post a Comment