Page 1 of 1
how to make query filtered
Posted: Mon Apr 05, 2010 2:50 am
by eiwans
Hi Guys, Im trying to list portfolio which only has large image, no error but i dont know where is my mistake.
<div id="slideshow">
<?php include('connection.php');
$dbtableSlide = "x_portfolio_db";
$querySlide = "SELECT * FROM $dbtableSlide WHERE imgLarge = true";
$resultSlide = mysql_query($querySlide);
if (!$resultSlide) {
echo "there was an problem";
} else {
$num_resultsSlide = mysql_num_rows($resultSlide);
}?>
<ul id="portfolio">
<?php for($i=0; $i < $num_resultsSlide; $i++) {
$row = mysql_fetch_array($resultSlide);?>
<li><a href="portfolio.php"><img src="<?php echo $row['imgLarge']?>" alt="Latest work" /></a></li>
<?php } ?>
</ul>
</div>
Thanks
Re: Loop only have large image
Posted: Mon Apr 05, 2010 2:56 am
by kasim.badami
Code: Select all
<ul id="portfolio">
<?php for($i=0; $i < $num_resultsSlide; $i++) {
$row = mysql_fetch_array($resultSlide);?>
<li><a href="portfolio.php"><img src="<?php echo $row['imgLarge']?>" alt="Latest work" /></a></li>
<?php } ?>
</ul>
</div>
Try mysql_fetch_assoc instead of mysql_fetch_array, this might solve your problem.
Re: how to make query filtered
Posted: Mon Apr 05, 2010 3:56 am
by Architek
does your sql return fine its just not being parsed out of the array correctly?
I might throw single quotes around the value of true like follows...
Code: Select all
$querySlide = "SELECT * FROM $dbtableSlide WHERE imgLarge = 'true'";
Re: how to make query filtered
Posted: Mon Apr 05, 2010 6:46 am
by eiwans
When i
echo $resultSlide ---> 6
echo $num_resultsSlide ----> 0
dont understand...
Re: how to make query filtered
Posted: Mon Apr 05, 2010 9:39 am
by lunarnet76
just in case you should use
Code: Select all
while($row=mysql_fetch_array($resultSlide)){
?>
<li><a href="portfolio.php"><img src="<?php echo $row['imgLarge']?>" alt="Latest work" /></a></li>
<?php
}
instead of
Code: Select all
for($i=0; $i < $num_resultsSlide; $i++) {
$row = mysql_fetch_array($resultSlide);?>
<li><a href="portfolio.php"><img src="<?php echo $row['imgLarge']?>" alt="Latest work" /></a></li>
<?php }
but otherwise your code works so it must code from your
Code: Select all
$querySlide = "SELECT * FROM $dbtableSlide WHERE imgLarge = 'true'";
or from a stupid mistake like a wrong field name : imgLarge instead of imglarge, the database is case insensitive, but php is!
Re: how to make query filtered
Posted: Mon Apr 05, 2010 11:22 am
by Architek
I know many times I have returned picture variables but forgot to state a folder path for the src
<img src="images/<?php echo $row['imgLarge']?>" alt="Latest work" />
Re: how to make query filtered
Posted: Mon Apr 05, 2010 6:02 pm
by eiwans
Still no luck

, Its brings up 6 files (correct) but the file path comes up blank.
http://dl.dropbox.com/u/2527203/Screen% ... 202010.png
Re: how to make query filtered
Posted: Mon Apr 05, 2010 6:53 pm
by lunarnet76
do a print_r($row), what does it gives you!?