JavaScript and client side scripting.
Moderator: General Moderators
blade_922
Forum Contributor
Posts: 132 Joined: Wed Jul 12, 2006 4:57 pm
Post
by blade_922 » Thu Jul 13, 2006 6:11 pm
My php code
Code: Select all
<?php
$self = 'http://www.mysite.com/';
$content=mysql_query("select * from mos_content ORDER BY `id` DESC LIMIT 5") or die(mysql_error());
while ($donnee = mysql_fetch_array($content))
{
$title = $donnee['title'];
echo "</table><tr><a href='$self/latestnews/$title'>$title</a></tr></br>";
}
?>
K i want to insert all that into a neat table so that i can customize table bg border width etc. i have no idea how to do it coz of the loop.
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Thu Jul 13, 2006 6:14 pm
Code: Select all
<?php
$self = 'http://www.mysite.com/';
$content=mysql_query("select * from mos_content ORDER BY `id` DESC LIMIT 5") or die(mysql_error());
while ($donnee = mysql_fetch_array($content))
{
$title = $donnee['title'];
echo '</table><tr><a href="' . $self . '/latestnews/' . $title . '">' . $title .'</a></tr></br>';
}
?>
blade_922
Forum Contributor
Posts: 132 Joined: Wed Jul 12, 2006 4:57 pm
Post
by blade_922 » Thu Jul 13, 2006 6:23 pm
so theres no <table> ? just </table> ?
How do i allow that for customization via css if its just </table>
blade_922
Forum Contributor
Posts: 132 Joined: Wed Jul 12, 2006 4:57 pm
Post
by blade_922 » Thu Jul 13, 2006 8:16 pm
and table doesnt appear...
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Thu Jul 13, 2006 8:58 pm
Untested..
Code: Select all
table.thisClass {
border-width: 0px 0px 1px 1px;
border-style: solid;
border-color: #000000;
}
td.thisClass {
border-width: 1px 1px 0px 0px;
border-style: solid;
border-color: #000000;
padding: 5px;
}
Code: Select all
<table cellpadding="0" cellspacing="0" border="0" class="thisClass">
<?php
$self = 'http://www.mysite.com/';
$content=mysql_query("select `title` from `mos_content` ORDER BY `id` DESC LIMIT 5") or die(mysql_error());
while ($donnee = mysql_fetch_array($content))
{
echo "<tr>\n";
echo ' <td class="thisClass"><a href="' . $self . '/latestnews/' . $donnee['title'] . '">' . $donnee['title'] .'</a></td>' . "\n";
echo "</tr>\n";
}
?>
</table>
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Thu Jul 13, 2006 10:27 pm
I think I should have read the original post better. Sorry for my crappy post earlier.
Astions has the ticket. Basically, open the table, then run the while loop adding in your rows and cells within the while loop. After you close the loop, close the table.