Jump to content


Photo

a to z


  • Please log in to reply
1 reply to this topic

#1 brown2005

brown2005
  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 23 March 2006 - 12:07 PM

Hi,

I have an a to z list that takes the field topics_topic and prints an a to z list like:-

E

elephants

L

lions
lymas

that is fine but what i wanna do is instead of having

lions
lymas

like that

i want it like

lions lymas


in a table..

any ideas please?

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 23 March 2006 - 01:10 PM

well, creating dynamic tables can be pretty complicated, but not exessively so. you need to determine how many columns you want to display before the table goes on to the next row. once you've done that, you're really pretty much set to go with something like this:
// assuming you already have your SQL results in variable $results

$columns = 5; // number of cells before we start next row
$count = 0;

echo "<table>\n";
while ($row = mysql_fetch_array($results)) {
  if ($count % $columns == 0)
    echo "<tr>\n";
  echo "<td>$row[word]</td>\n";
  $count++;
  if ($count % $columns == 0)
    echo "</tr>\n";
}

echo "</table>\n";

hope this helps! good luck
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users