•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,708 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,379 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 434 | Replies: 10 | Solved
![]() |
•
•
Join Date: Apr 2008
Posts: 31
Reputation:
Rep Power: 1
Solved Threads: 0
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.
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.
php Syntax (Toggle Plain Text)
<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>
Last edited by peter_budo : May 18th, 2008 at 4:40 am. Reason: Keep It Organized - please use [code] tags
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>
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>•
•
Join Date: Apr 2008
Posts: 31
Reputation:
Rep Power: 1
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?
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?
php Syntax (Toggle Plain Text)
<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>
Last edited by peter_budo : May 18th, 2008 at 4:42 am. Reason: Keep It Organized - please use [code] tags
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- code to import excel data into mysql using php (PHP)
- PHP codes to search MySQL (PHP)
- Getting sum of array (PHP)
- mssql_fetch_array or mssql_query is stripping out a space in PHP (PHP)
Other Threads in the PHP Forum
- Previous Thread: PHP and Oracle connection
- Next Thread: Relocation Error


Linear Mode