shyish Posted March 25, 2010 Share Posted March 25, 2010 Ok, I'll start with the basics. The website is all dynamic, based from one page with javascript used to make the content pages slide in and out. One such page on this is a portfolio page, on which there is an image slider. Now then, for this to work, each image slider needs an individual ID etc.; Not a problem. The problem is with the query for the arrays, The images that'll be used in the image slider. Earlier I had it working fine, but this was with just one "page" for the portfolio, now I am adding more as it will need it in future, and it broke because of various things most of which I fixed (mainly forgetting to change the variables) So anyway, it wasn't working because it was using the same variables in the two queries, so I changed them, and now the second query - the one for arrays - does not work at all. So here is the array query <?php $gquery="SELECT * FROM images WHERE $id=siteid"; $gresult=mysql_query($gquery); $gnum=mysql_numrows($gresult); mysql_close(); $g=0; while ($g < $gnum) { $site=mysql_result($result,$g,"site"); $imageurl=mysql_result($result,$g,"imageurl"); ?> ["images/sites/<?php echo $site?>/<?php echo $imageurl ?>", "", "", "The website homepage"]<?php if ($g < $gnum) echo , ?> <?php $g++; } ?> If that's not enough to guess, here is the full script <!-- Database connect --> <?php $host="localhost"; $username="velociv4_root"; $password="deathy13"; $database="velociv4_char"; mysql_connect($host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); ?> <!-- Begin First Query --> <?PHP $query="SELECT * FROM portfolio ORDER BY id ASC"; $result=mysql_query($query); $num=mysql_numrows($result); $i=0; while ($i < $num) { $title=mysql_result($result,$i,"name"); $thearticle=mysql_result($result,$i,"info"); $id=mysql_result($result,$i,"id"); $image=mysql_result($result,$i,"imageurl"); ?> <div class="item-content"> <h1><?PHP echo $title ?> </h1><br /><br /> <script type="text/javascript"> var mygallery=new fadeSlideShow({ wrapperid: "fadeshow<?PHP echo $id?>", //ID of blank DIV on page to house Slideshow dimensions: [550, 300], //width/height of gallery in pixels. Should reflect dimensions of largest image imagearray: [ <!-- Begin Second Query --> <?php $gquery="SELECT * FROM images WHERE $id=siteid"; $gresult=mysql_query($gquery); $gnum=mysql_numrows($gresult); mysql_close(); $g=0; while ($g < $gnum) { $site=mysql_result($result,$g,"site"); $imageurl=mysql_result($result,$g,"imageurl"); ?> ["images/sites/<?php echo $site?>/<?php echo $imageurl ?>", "", "", "The website homepage"]<?php if ($g < $gnum) echo , ?> <?php $g++; } ?> ], displaymode: {type:'manual', pause:3000, cycles:0, wraparound:true}, persist: false, //remember last viewed slide and recall within same session? fadeduration: 300, //transition duration (milliseconds) descreveal: "always", togglerid: "fadeshow<?PHP echo $id?>toggler" }) </script> <div id="fadeshow<?PHP echo $id?>toggler" style="width:600px; text-align:center; margin:10px"> <table width="600" border="0" cellspacing="0" cellpadding="0"> <tr> <td><div align="left"><a href="#" class="prev"><img src="images/left.png" style="border-width:0" /></a></div></td> <td> <div id="fadeshow<?PHP echo $id?>"></div> </td> <td><div align="right"><a href="#" class="next"><img src="images/right.png" style="border-width:0" /></a></div></td> </tr> <tr> <td colspan="3"><span class="status" style="margin:0 50px; font-weight:bold"></span></td> </tr> </table> </div> <?PHP echo $thearticle?></div> <?php $i++; } ?> I look forward to hearing from you, Many thanks, Robin N. Quote Link to comment Share on other sites More sharing options...
schilly Posted March 25, 2010 Share Posted March 25, 2010 Is this correct? $gquery="SELECT * FROM images WHERE $id=siteid"; or do you mean $gquery="SELECT * FROM images WHERE siteid=$id"; Quote Link to comment Share on other sites More sharing options...
shyish Posted March 25, 2010 Author Share Posted March 25, 2010 The latter, Fixed that... And I realised another part of the problem "$site=mysql_result($gresult,$g,"site"); $imageurl=mysql_result($gresult,$g,"imageurl");" before it was missing the g on result. Still though, it does not work. Quote Link to comment Share on other sites More sharing options...
schilly Posted March 25, 2010 Share Posted March 25, 2010 $gnum=mysql_numrows($gresult); should be $gnum=mysql_num_rows($gresult); Quote Link to comment Share on other sites More sharing options...
shyish Posted March 25, 2010 Author Share Posted March 25, 2010 You sure? Because it works the other way. Changed it anyway, nothing changed. I've got it at the point where it just works on the first copy, then for the other two times the query cuts out and does nothing. Quote Link to comment Share on other sites More sharing options...
schilly Posted March 25, 2010 Share Posted March 25, 2010 mysql_numrows is not a function unless you created it. any calls to mysql_numrows should be changed to mysql_num_rows(). put this at the top of your file as well and it should give you some useful errors. ini_set ("display_errors", "1"); error_reporting(E_ALL); and change any of your query calls to mysql_query($gquery) or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
shyish Posted March 25, 2010 Author Share Posted March 25, 2010 Changed it as you said, did the same in my php.ini file, and still not displaying errors, just not working. Quote Link to comment Share on other sites More sharing options...
schilly Posted March 25, 2010 Share Posted March 25, 2010 can you post your most recent code? Quote Link to comment Share on other sites More sharing options...
shyish Posted March 25, 2010 Author Share Posted March 25, 2010 <!-- Database connect --> <?php $host="localhost"; $username="velociv4_root"; $password="#"; $database="velociv4_char"; mysql_connect($host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM portfolio ORDER BY id ASC"; $result=mysql_query($query) or die(mysql_error());; $num=mysql_num_rows($result); $i=0; while ($i < $num) { $title=mysql_result($result,$i,"name"); $thearticle=mysql_result($result,$i,"info"); $id=mysql_result($result,$i,"id"); ?> <div class="item-content"> <h1><?PHP echo $title ?> </h1><br /><br /> <script type="text/javascript"> var mygallery=new fadeSlideShow({ wrapperid: "fadeshow<?PHP echo $id?>", //ID of blank DIV on page to house Slideshow dimensions: [550, 300], //width/height of gallery in pixels. Should reflect dimensions of largest image imagearray: [ <!-- Begin Second Query --> <?php $host="localhost"; $username="velociv4_root"; $password="#"; $database="velociv4_char"; mysql_connect($host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query2="SELECT * FROM images WHERE siteid=$id ORDER BY id ASC"; $result2=mysql_query($query2) or die(mysql_error()); $num2=mysql_num_rows($result2) or die(mysql_error()); mysql_close(); $i2=0; while ($i2 < $num2) { $site=mysql_result($result2,$i2,"site"); $imageurl=mysql_result($result2,$i2,"imageurl"); ?> ["images/sites/<?php echo $site?>/<?php echo $imageurl ?>", "", "", "The website homepage"], <?php $i2++; } ?> ], displaymode: {type:'manual', pause:3000, cycles:0, wraparound:true}, persist: false, //remember last viewed slide and recall within same session? fadeduration: 300, //transition duration (milliseconds) descreveal: "always", togglerid: "fadeshow<?PHP echo $id?>toggler" }) </script> <div id="fadeshow<?PHP echo $id?>toggler" style="width:600px; text-align:center; margin:10px"> <table width="600" border="0" cellspacing="0" cellpadding="0"> <tr> <td><div align="left"><a href="#" class="prev"><img src="images/left.png" style="border-width:0" /></a></div></td> <td> <div id="fadeshow<?PHP echo $id?>"></div> </td> <td><div align="right"><a href="#" class="next"><img src="images/right.png" style="border-width:0" /></a></div></td> </tr> <tr> <td colspan="3"><span class="status" style="margin:0 50px; font-weight:bold"></span></td> </tr> </table> </div> <?PHP echo $thearticle?></div> <?php $i++; } ?> Quote Link to comment Share on other sites More sharing options...
shyish Posted March 25, 2010 Author Share Posted March 25, 2010 Ok I think I've figured out the reason for the problem. Each time the code for the Main container "page" is repeated, it is calling upon the same code for the image slider. This means that each instance of $gquery is appearing 3 times, so only working on the first. What I need is a way for each variable to have an idividual ID each time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.