this has taken me hours and I am going nowhere slowly can anyone please help.

I am tryig to get my table to display more than 1 news record everythig i have tried doesn't work or has runtime errors. Here is the basic code that worls and displays the one row.
How would I get it to display the 9 most recet rows. Any help would be appreciated cheers.

<div  id="news">
<? 
$sql = "SELECT * FROM tblnewsdetails order by intnewsID desc limit 1";	
      $temps  = $DB_site->query($sql);
	if($row=$DB_site->fetch_array($temps))
	{
$tradeaid		= $row["intnewsID"];
$accountid		= $row["intAccountID"];
$stitle   		= $row["newsshTit"];
$updated                   = $row["dtAddedOn"];
}
?>

<div class="asnazzy">
<b class="atop"><b class="ab1"></b><b class="ab2 color_c"></b><b class="ab3 color_c"></b><b class="ab4 color_c"></b></b>
<div class="aboxcontent">
<h1 class="color_c">Market News</h1>
<p>

<table cellspacing="0" cellpadding="2" border="0">
<td width="90% align=left"><?=$stitle?></td>
</tr>
</table>

</p>
</div>

your output result has to be in side the query loop. if outside only one result is done.

<div id="news">

<div class="asnazzy">
<b class="atop"><b class="ab1"></b><b class="ab2 color_c"></b><b class="ab3 color_c"></b><b class="ab4 color_c"></b></b>
<div class="aboxcontent">
<h1 class="color_c">Market News</h1>
<p>

<table cellspacing="0" cellpadding="2" border="0">


<? 
$sql = "SELECT * FROM tblnewsdetails order by intnewsID desc limit 1"; 
$temps = $DB_site->query($sql);
if($row=$DB_site->fetch_array($temps))
{
$tradeaid = $row["intnewsID"];
$accountid = $row["intAccountID"];
$stitle = $row["newsshTit"];
$updated = $row["dtAddedOn"];

echo '<tr><td width="90% align=left">'. $stitle. '</td></tr>';

}
?>

</table>

</p>
</div>

seems ok thanks sorry i made a mistake how would i get it to only display 9 records.

sorry this isn't showing more than one record still only displays one record?

:D i just noticed the limit 1 in original code. remove this and test original code or try one below.

<div id="news">

<div class="asnazzy">
<b class="atop"><b class="ab1"></b><b class="ab2 color_c"></b><b class="ab3 color_c"></b><b class="ab4 color_c"></b></b>
<div class="aboxcontent">
<h1 class="color_c">Market News</h1>
<p>

<table cellspacing="0" cellpadding="2" border="0">


<? 
$sql = "SELECT * FROM tblnewsdetails order by intnewsID desc"; 
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
$tradeaid = $row["intnewsID"];
$accountid = $row["intAccountID"];
$stitle = $row["newsshTit"];
$updated = $row["dtAddedOn"];

echo '<tr><td width="90% align=left">'. $stitle. '</td></tr>';

}
?>

</table>

</p>
</div>

great thanks works now but is there anyway to limit it to showing 9 records?

great works ok now I am having this problem.

I am trying to get it so when I click on the news article it opens on another page called news.php
here is what I am trying but doesnt seem to work?

<div id="news">

<div class="asnazzy">
<b class="atop"><b class="ab1"></b><b class="ab2 color_c"></b><b class="ab3 color_c"></b><b class="ab4 color_c"></b></b>
<div class="aboxcontent">
<h1 class="color_c">Market News</h1>
<p>

<table cellspacing="0" cellpadding="2" border="0">


<? 
$sql = "SELECT * FROM tblnewsdetails order by intnewsID desc limit 9"; 
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
$tradeaid = $row["intnewsID"];
$accountid = $row["intAccountID"];
$stitle = $row["newsshTit"];
$updated = $row["dtAddedOn"];

echo '<tr><td width="90% align=left"><a href="news.php">'. $stitle. '</a></td></tr>';

}
?>
<input name="newst" type="hidden" id="newst" value="<?=$stitle?>">
</table>

</p>
</div><b class="abottom"><b class="ab4"></b><b class="ab3"></b><b class="ab2"></b><b class="ab1"></b></b>
</div>

I have tried 100 different ways using CODE tags doesn't work. Please give me an example, or if i could get the article just to open in a new window that would be great.

Edited 3 Years Ago by happygeek: fixed formatting

This question has already been answered. Start a new discussion instead.