Forum Moderators: coopster
I have one set of data from one column in my mySQL database and I want to set up a page for it to display like this:
¦--------¦ ¦--------¦
¦This is ¦ ¦at how ¦
¦a bunch ¦ ¦it is ¦
¦of text.¦ ¦in two ¦
¦But ¦ ¦columns.¦
¦look ¦ ¦ ¦
¦--------¦ ¦--------¦
I'm wondering if this is possible to do in php. From what I can tell CSS or html wont help me out with doing this, maybe Javascript, but I'm not as adept with JS as I am with php, html and css.
This is something I thought up, but does not work...
Also, the Content is just text, there is no special data in it. Imagine a book, where the text spills over on to the next page. How do I do this?
$result = mysql_query("select * from Content");$count = 1;
$column = 1;
//loop statement
while ($myrow = mysql_fetch_array ($result))
{
// first column display
if ($column == 1)
{
//field is the column in your table
printf("<tr><td>%s</td>",$myrow["Text"]);
}
else{
//second column display
printf("<td>%s</td></tr>",$myrow["Text"]);
}
$count += 1;
$column = $count % 2;
}
$href = 'http://www.example.com';
$n = array();
$numRows = count($rows);
if ($numRows > 0) {
$columns = 2;
$numRows = ceil($numRows/$columns);
foreach ($rows as $row) {
$nam = htmlentities($row['name']);
$uri = urlencode($row['link']);
$n[] = "<a href=\"{$href}/{$uri}/\">{$nam}</a>";
}
$n = array_chunk($n, $numRows);
foreach ($n as $rows) {
$list .= "\n<td>\n\t<ul>\n\t\t<li>" .
implode("</li>\n\t\t<li>", $rows) .
"</li>\n\t</ul>\n</td>\n"
;
}
}