Page 1 of 1

SIDE by SIDE

Posted: Wed Aug 01, 2007 8:13 pm
by phpretard
The code may not be pretty, but at least it doesn't work. Actually it works fine but...

I need this to display the information in 2 columns and then repeat.

Well all it does is repeat one table verticaly.

Can someone please help with this?

Code: Select all

//$it logs into the database

//and then...

$query = "SELECT * FROM artcarve";
$result = mysql_query($query);

while($row = mysql_fetch_array($result))
{

  echo "<table border=1 id=table1><table border=1 class=itemleft>";
  echo "<tr><td class=itemnum>ITEM NUMBER:" . $row['item'] . "</td></tr>";
  echo "<tr><td class=img><img src=http://www.website.com/shop/thumbs/".($row['item']).".JPG></img></td></tr>";
  echo "<tr><td class=title>" . $row['title'] . "</td></tr>";
  echo "<tr><td class=desclink><a href=# onClick=\"return overlay(this, '".($row['item'])."', 'leftbottom')\">Description</a>";
  echo "|";
  echo "<a href=\"javascript:popImage('http://www.website.com/shop/images/".($row['item']).".JPG')\">Enlarge Photo</a>";
  echo "<tr><td></td></tr>";
  echo "<tr><td class=price>" . $row['price'] . "</td></tr>";
  echo "<tr><td>";

echo "<form target=>";
echo "<input type=hidden name=add value=1>";
echo "<input type=hidden name=cmd value=_cart>";
echo "<input type=hidden name=business value=>";
echo "<input type=hidden name=item_name value=\"".($row['title'])."\">";
echo "<input type=hidden name=item_number value=".($row['item']).">";
echo "<input type=hidden name=amount value=".($row['price']).">";
echo "<input type=hidden name=no_shipping value=0>";
echo "<input type=hidden name=no_note value=1>";
echo "<input type=hidden name=currency_code value=>";
echo "<input type=hidden name=lc value=US>";
echo "<input type=hidden name=bn value=>";
echo "</form>";    
    
echo "</td></tr>";

echo "<DIV id=".($row['item'])." style=\"position:absolute; display:none; border: 9px solid black; background-color: lightyellow; width: 210px; height: 85px; left:12px; top:11px\">";
echo $row['description'];
echo "<div align=right><a href=# onClick=\"overlayclose('".($row['item'])."'); return false\">Close Box</a></div>";
echo "</DIV>";

echo "</table>";


}

mysql_close($con);

?>

hawleyjr | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Aug 01, 2007 8:47 pm
by iknownothing
it looks like you have used <tr> (TABLE ROW) too many times for the use of columns. to get a 2 column table you'll need something like this:

Code: Select all

<table>
     <tr>  // a Row
          <td></td>  // 2 Table Divisions on 1 Row (1)
          <td></td>  // (2)
     </tr>
</table>
Also, you may have problems with the Div if its Position: Absolute, everytime it loops, another Div will be placed in the same position (maybe on top, or below) as the one previous.

I thought it was something to do with a loop.

Posted: Wed Aug 01, 2007 8:53 pm
by phpretard
I have made it work before but I can't find my or remember how I did it. I will go look at the rows and columns again with your reply in mind. Thank you for the reply!

-Anthony

Posted: Wed Aug 01, 2007 8:55 pm
by John Cartwright
I like to use a float because you avoid having to do any calculations at all

Code: Select all

while ($row = mysql_fetch_assoc($result)) {
   echo '<div style="float: left; width: 49%;"> Foo </div>';
}
This will display two columns per row

Posted: Wed Aug 01, 2007 9:07 pm
by phpretard
That worked great!!!

$much = 1million

Thanks " . $much . ";

-Anthony