| | |
how to explode records?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 78
Reputation:
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 5: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.
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 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. 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"; $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: 78
Reputation:
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 5:42 am. Reason: Keep It Organized - please use [code] tags
![]() |
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
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube





