how to make query filtered
Moderator: General Moderators
how to make query filtered
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
<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
Last edited by eiwans on Mon Apr 05, 2010 3:06 am, edited 1 time in total.
-
kasim.badami
- Forum Newbie
- Posts: 4
- Joined: Wed Mar 24, 2010 5:50 am
Re: Loop only have large image
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>
Re: how to make query filtered
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...
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
When i
echo $resultSlide ---> 6
echo $num_resultsSlide ----> 0
dont understand...
echo $resultSlide ---> 6
echo $num_resultsSlide ----> 0
dont understand...
-
lunarnet76
- Forum Commoner
- Posts: 67
- Joined: Sun Apr 04, 2010 2:07 pm
- Location: Edinburgh
Re: how to make query filtered
just in case you should use
instead of
but otherwise your code works so it must code from your
or from a stupid mistake like a wrong field name : imgLarge instead of imglarge, the database is case insensitive, but php is!
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
}
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 }Code: Select all
$querySlide = "SELECT * FROM $dbtableSlide WHERE imgLarge = 'true'";Re: how to make query filtered
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" />
<img src="images/<?php echo $row['imgLarge']?>" alt="Latest work" />
Re: how to make query filtered
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
http://dl.dropbox.com/u/2527203/Screen% ... 202010.png
-
lunarnet76
- Forum Commoner
- Posts: 67
- Joined: Sun Apr 04, 2010 2:07 pm
- Location: Edinburgh
Re: how to make query filtered
do a print_r($row), what does it gives you!?