Jump to content

chadcwm

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

chadcwm's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. OK, I used modulus for this and it's doing exactly what I need it to! However, I would like to add a clear div after every fourth loops as well in order to get around some spacing issues on entries with lots of text…I did that, however, it looks like the very first result is coming up as the alternate class. Is this because the first result is coming up as 0 when $i%4? Please pardon my lack of php knowledge! Is there a way to exclude this first entry from the clear? The final goal is a portfolio site with four columns. The fourth column would not have a margin on it so that it edges up to the right margin of the page. Here's the code I'm working with now: $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $client=mysql_result($result,$i,"Client"); $type=mysql_result($result,$i,"Type"); $image=mysql_result($result,$i,"Image"); $link=mysql_result($result,$i,"Link"); if($i % 4 === 0) { // This loop should have class="projectBoxlast" $class = 'projectBoxlast'; $clear = '<div class="clear"></div>'; } else { // Others have projectBox $class = 'projectBox'; $clear = ''; } ?> <a href="<? echo "$link"; ?>"> <div class="<? echo "$class"; ?>"> <img class="thumbImage" src="http://www.cross-a.com/portfolio/thumbs/<? echo "$image"; ?>.jpg" /> <p class="thumbText"><strong><? echo "$client"; ?></strong><br /> <? echo "$type"; ?></p> <div class="clear"></div> </div> <!-- End of projectBox --> </a> <? echo "$clear"; ?> <? ++$i; } ?>
  2. Let me say this…I'm a designer and not all that knowledgeable on php. That said, I'm trying to set up a portfolio page with a 4 column grid. The last column needs to have no margin on it, so I'd like to set up for every fourth item to include a "last" class added to the "projectBox" class. Any help setting this up? I've spent a few hours looking around the net for answers, but haven't found anything that worked. Thanks for any help! Chad Here's the code I've got to begin with: <? include("includes/dbinfo.inc.php"); mysql_connect(localhost,$db_username,$db_password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM portfolio"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $client=mysql_result($result,$i,"Client"); $type=mysql_result($result,$i,"Type"); $image=mysql_result($result,$i,"Image"); $link=mysql_result($result,$i,"Link"); ?> <a href="<? echo "$link"; ?>"> <div class="projectBox"> <img class="thumbImage" src="http://www.cross-a.com/portfolio/thumbs/<? echo "$image"; ?>.jpg" /> <p class="thumbText"><strong><? echo "$client"; ?></strong><br /> <? echo "$type"; ?></p> <div class="clear"></div> </div> <!-- End of projectBox --> </a> <? ++$i; } ?>
  3. I'm setting up an update page for a database and it seems that the php is not grabbing the id from the link and using it. I've set other sites us just like this and they worked fine, but not now. The link is going to update.php?id=2 And here's the php: <? include("includes/session.php"); ?> <? include("includes/dbinfo.inc.php"); mysql_connect(localhost,$db_username,$db_password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM portfolio WHERE id='$id'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $category=mysql_result($result,$i,"category"); $client=mysql_result($result,$i,"client"); $description=mysql_result($result,$i,"description"); $image_name=mysql_result($result,$i,"image_name"); ?> <a href="work/fullsize/<? echo "$image_name"; ?>.jpg" target="_blank"><img src="http://www.cross-a.com/beta/work/fullsize/<? echo "$image_name"; ?>.jpg" height="114" width="200" title="<? echo "$description"; ?>" style="margin-bottom: 10px;"/></a> <p><strong><? echo "$client"; ?></strong><br /> <? echo "$description"; ?></p> <? ++$i; } ?> </div> </body> </html> Any help on why this is not working? If I add something like $id=2, then everything displays properly, so there's something going on there. Thanks for any help!
×
×
  • 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.