TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 238
  • Total: 238

Tricky Block Request

Started by Xarcell, June 01, 2006, 04:18:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jacortina

You need something to be able to grab onto to trigger the 'break' from the first column (table cell) and the second.

Rus

or perhaps go left, right, left right, under a category?

jacortina

Well ... that's not how HTML works (and php puts out HTML; that's what it is, a hypertext preprocessor). You can't go back to a previous element that's already been output. You may (with a lot of work) do something to build each side and hold them in arrays/conacatentaed strings before then echoing those out.

But, it's hard to see how to retain the nesting of child/sub boards in that kind of presentation.

Rus

Ahhhh, in my attempt I tried to use a table with 2 td and a tr and it didnt work.

jacortina

That's the thing, you put something in the first td, then switch to the second and you can't really go back to the first.

That's why you'd have to cahce the output some way, building the two strings or arrays, and only after they're built do you output one to the first td and the other to the second td.

JPDeni

Or you could have each item in its own cell:


item 1item 2
item 3item 4
item 5item 6
item 7item 8
item 9item 10

Rus

thats what I tried but it kept failing before it output the first row

JPDeni

I'd have to see your code in order to know what you did wrong.

Rus

I got frustrated and deleted it already.  Basically I tried starting a table before the query used on page 2 of this thread and inside the while statement tried using a counter to make only 2 columns with with tds and then when the counter hit 2 reset it to 1 and put in a tr.

That didnt work.  Do you think you could make something that would work?

IchBin

Here's some code I did hacked on for recent articles that gave 3 columns, then starts a new row. Perhaps that can help you understand how it works.

// ÃÅ"bersicht Tauchplätze österreich
global $db_prefix, $scripturl;

$category = 1; // Tauchplatzkategorie

$query = db_query(
    "SELECT id, subject
     FROM {$db_prefix}tp_articles
     WHERE category = $category
     AND off = 0
     AND approved = 1
     ORDER BY subject", __FILE__, __LINE__);
echo '<div style="overflow: auto; width: 100%;">';

$i = 0;

echo '<table cellspacing="0" cellpadding="0">
<tr>';
while ($row = mysql_fetch_assoc($query)){
  echo '<td style="padding-left: 20px;"><a href="' . $scripturl . '?page=' . $row['id'] . '">' . $row['subject'] . '</a></td>'; 
$i++;
if ($i > 2){
echo '</tr><tr>';
$i = 0;
}
}
echo '</tr></table>';
echo '</div>';

This website is proudly hosted on Crocweb Cloud Website Hosting.