Jump to content

alternate display problems


proctk

Recommended Posts

Hi The below code is supposed to display tables side by side so to per row, It's kind of working until it gets to the last entry.  In my sample query The divs are

 

1. left

2. right

3.left

4. left

 

nuber 4 should be right.

 

Any ideas why its not working

 

$i = 0
  $col = ($i % 2) ? 'right' : 'left';
    echo "<div class=\"$col\">";?>
    
<table class="table" style="width:99%;">
  <tr>
    <td rowspan="3" style="width:20%;" valign="top">
        <a href="albumPhotos.php?photos=<?php echo $album['album'];?>&bid=<?php echo $buddy_id; ?>"><img src="../user_images/<?php echo $album['album_cover']; ?>" width="<?php echo $newwidth; ?>" height="<?php echo $newheight; ?>" alt="<?php echo $album['album_cover']; ?>" /></a>
        </td>
    <td style="width:30%;" class="eventSub">Album:</td>
    <td valign="top"><?php echo $album['album']; ?></td>
  </tr>
  <tr>
    <td style="width:25%;" class="eventSub">Owner:</td>
    <td><a title="Go to members profile" class="linkText" href="../profile.php?=id=<?php echo $album['user_id']; ?>"><?php echo $buddy_info['first_name'].' '.$buddy_info['last_name'];?></a></td>
  </tr>
  <tr>
    <td style="width:25%;" class="eventSub">Created:</td>
    <td><?php echo $album['createdate']; ?></td>
  </tr>
</table>
        
    <? echo "</div>";
    $i++;
  } ?>
  
  <?php }
  
}?> 

Link to comment
Share on other sites

here is the complete code for the page

<?php
/* Check User Script */
session_start();  // Start Session
include ("../Connections/db.php");
//check if user is already logged in
if (!isset($_SESSION['user_id'])){

$msg = 'You tryed to access a members only page. Login or become a registered member to access that page!';

header("Location: ../index.php?msg=".$msg); 
}
//Checks if the profile request is for a new login or someone requesting
if(isset($_GET['id'])){
$id = $_GET['id'];
}else{
$id = $_SESSION['user_id'];
}
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/twoCoumn.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Family Click|Album Photos</title>
<!-- InstanceEndEditable -->
<link rel="stylesheet" href="../design/tabbler.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../design/tabbler-print.css" type="text/css" media="print" />
<link rel="stylesheet" type="text/css" href="../design/layout.css" />
<link rel="stylesheet" type="text/css" href="../design/design.css" />
<script type="text/javascript" src="../design/tabber.js"></script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>

<body>
<div id="outer">
<div id="hdr">
  <div id="logo-div">
	<h2 id="logo"><a href="../index.php">Family Click</a></h2>
  	<h4 id="slogan-text">Keeping Families Connected</h4>
  </div>
  <div class="headerText">
  <h5> </h5>
  </div>
</div>
<div style="clear:left"></div>
<div id="bar"><!-- InstanceBeginEditable name="Bar" --><?php include('../design/bar.php'); ?><!-- InstanceEndEditable --></div>

<div id="bodyblock" align="right">
<div id="l-col" align="left"><!-- InstanceBeginEditable name="Left Column" --><?php include('../searchMembers.php'); ?><!-- InstanceEndEditable --></div>
<div id="cont"><!-- InstanceBeginEditable name="Body Content" -->
<?php
$msg = (isset($_GET['msg']) AND $_GET['msg']<> "") ? urldecode($_GET['msg']) : ''; 
if ($msg <> "") {
  if (get_magic_quotes_gpc()) {
    $msg = stripslashes($msg);
  }
  echo "<div id='alertMessage'><p style='margin-left:40px;'>$msg</p></div>";
}
  // Get buddies
$query_get_buddy = ("SELECT * from buddylink WHERE owner_id = '$id' AND status = '2'");
$get_buddy = mysql_query($query_get_buddy)or die("SQL Error: $query_get_buddy<br>" . mysql_error());

 while ($buddy = mysql_fetch_assoc($get_buddy)){

$buddy_id = $buddy['buddy_id'];

//Get buddy information
$query_get_buddy_info = ("SELECT * FROM users WHERE user_id = '$buddy_id'");
$get_buddy_info = mysql_query($query_get_buddy_info)or die("SQL Error: $query_get_buddy_info<br>" . mysql_error());

while($buddy_info = mysql_fetch_assoc($get_buddy_info)){
//Get Buddies Albums
$query_buddy_albums = ("SELECT * FROM albumNames WHERE user_id = '$buddy_id'");
$buddy_album = mysql_query($query_buddy_albums)or die("SQL Error: $query_buddy_albums<br>" . mysql_error());


$i = 0;
  while($album = mysql_fetch_assoc($buddy_album)){
  		
  		$image = "../user_images/".$album['album_cover'];
	$tempimg = getImageSize($image);
	$size = $tempimg[3];
	$size = explode("\"",$size);
	$width = $size[1];
	$height = $size[3];

	$newwidth=75;
	$newheight=($height/$width)*75;
	//////////
  $col = ($i % 2) ? 'right' : 'left';
    echo "<div class=\"$col\">";?>
    
<table class="table" style="width:99%;">
  <tr>
    <td rowspan="3" style="width:20%;" valign="top">
        <a href="albumPhotos.php?photos=<?php echo $album['album'];?>&bid=<?php echo $buddy_id; ?>"><img src="../user_images/<?php echo $album['album_cover']; ?>" width="<?php echo $newwidth; ?>" height="<?php echo $newheight; ?>" alt="<?php echo $album['album_cover']; ?>" /></a>
        </td>
    <td style="width:30%;" class="eventSub">Album:</td>
    <td valign="top"><?php echo $album['album']; ?></td>
  </tr>
  <tr>
    <td style="width:25%;" class="eventSub">Owner:</td>
    <td><a title="Go to members profile" class="linkText" href="../profile.php?=id=<?php echo $album['user_id']; ?>"><?php echo $buddy_info['first_name'].' '.$buddy_info['last_name'];?></a></td>
  </tr>
  <tr>
    <td style="width:25%;" class="eventSub">Created:</td>
    <td><?php echo $album['createdate']; ?></td>
  </tr>
</table>
        
    <? echo "</div>";
    $i++;
  } ?>
  
  <?php }
  
}?> 
<div class="contentBottomSpace"></div>
<!-- InstanceEndEditable --></div>
</div>
<div id="ftr"><!-- InstanceBeginEditable name="Footer" --><?php include('../design/ftr.php'); ?>
<!-- InstanceEndEditable --></div>

</div>

</body>
<!-- InstanceEnd --></html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.