954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to explode records?

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>
shadiadiph
Junior Poster
119 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

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>
amigura
Junior Poster in Training
72 posts since Jan 2008
Reputation Points: 11
Solved Threads: 7
 

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

shadiadiph
Junior Poster
119 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

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

shadiadiph
Junior Poster
119 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

: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>
amigura
Junior Poster in Training
72 posts since Jan 2008
Reputation Points: 11
Solved Threads: 7
 

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

shadiadiph
Junior Poster
119 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

add limit 9

amigura
Junior Poster in Training
72 posts since Jan 2008
Reputation Points: 11
Solved Threads: 7
 

cheers excellent

shadiadiph
Junior Poster
119 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

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>
shadiadiph
Junior Poster
119 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

use code TAGS i have tried 100 different ways using [code] tags doesn't work.

Please give me an example.

Or if i couldl get the article just to open in a new window that would be great.

shadiadiph
Junior Poster
119 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

use code TAGS i have tried 100 different ways using [code] tags doesn't work.

Please give me an example.

Or if i couldl get the article just to open in a new window that would be great.


Click on linkHelp with Code Tags in any post with proper use of code tags to see tutorial or follow this link

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You