943,929 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1205
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
May 17th, 2008
0

how to explode records?

Expand Post »
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.

php Syntax (Toggle Plain Text)
  1. <div id="news">
  2. <?
  3. $sql = "SELECT * FROM tblnewsdetails order by intnewsID desc limit 1";
  4. $temps = $DB_site->query($sql);
  5. if($row=$DB_site->fetch_array($temps))
  6. {
  7. $tradeaid = $row["intnewsID"];
  8. $accountid = $row["intAccountID"];
  9. $stitle = $row["newsshTit"];
  10. $updated = $row["dtAddedOn"];
  11. }
  12. ?>
  13.  
  14. <div class="asnazzy">
  15. <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>
  16. <div class="aboxcontent">
  17. <h1 class="color_c">Market News</h1>
  18. <p>
  19.  
  20. <table cellspacing="0" cellpadding="2" border="0">
  21. <td width="90% align=left"><?=$stitle?></td>
  22. </tr>
  23. </table>
  24.  
  25. </p>
  26. </div>
Last edited by peter_budo; May 18th, 2008 at 5:40 am. Reason: Keep It Organized - please use [code] tags
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster
shadiadiph is offline Offline
117 posts
since Apr 2008
May 17th, 2008
0

Re: how to explode records?

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

PHP Syntax (Toggle Plain Text)
  1. <div id="news">
  2.  
  3. <div class="asnazzy">
  4. <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>
  5. <div class="aboxcontent">
  6. <h1 class="color_c">Market News</h1>
  7. <p>
  8.  
  9. <table cellspacing="0" cellpadding="2" border="0">
  10.  
  11.  
  12. <?
  13. $sql = "SELECT * FROM tblnewsdetails order by intnewsID desc limit 1";
  14. $temps = $DB_site->query($sql);
  15. if($row=$DB_site->fetch_array($temps))
  16. {
  17. $tradeaid = $row["intnewsID"];
  18. $accountid = $row["intAccountID"];
  19. $stitle = $row["newsshTit"];
  20. $updated = $row["dtAddedOn"];
  21.  
  22. echo '<tr><td width="90% align=left">'. $stitle. '</td></tr>';
  23.  
  24. }
  25. ?>
  26.  
  27. </table>
  28.  
  29. </p>
  30. </div>
Reputation Points: 11
Solved Threads: 7
Junior Poster in Training
amigura is offline Offline
71 posts
since Jan 2008
May 17th, 2008
0

Re: how to explode records?

seems ok thanks sorry i made a mistake how would i get it to only display 9 records.
Last edited by shadiadiph; May 17th, 2008 at 9:44 pm.
Reputation Points: 10
Solved Threads: 0
Junior Poster
shadiadiph is offline Offline
117 posts
since Apr 2008
May 17th, 2008
0

Re: how to explode records?

sorry this isn't showing more than one record still only displays one record?
Last edited by shadiadiph; May 17th, 2008 at 9:59 pm.
Reputation Points: 10
Solved Threads: 0
Junior Poster
shadiadiph is offline Offline
117 posts
since Apr 2008
May 17th, 2008
0

Re: how to explode records?

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


PHP Syntax (Toggle Plain Text)
  1. <div id="news">
  2.  
  3. <div class="asnazzy">
  4. <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>
  5. <div class="aboxcontent">
  6. <h1 class="color_c">Market News</h1>
  7. <p>
  8.  
  9. <table cellspacing="0" cellpadding="2" border="0">
  10.  
  11.  
  12. <?
  13. $sql = "SELECT * FROM tblnewsdetails order by intnewsID desc";
  14. $result = mysql_query($sql);
  15. while ($row = mysql_fetch_assoc($result)) {
  16. $tradeaid = $row["intnewsID"];
  17. $accountid = $row["intAccountID"];
  18. $stitle = $row["newsshTit"];
  19. $updated = $row["dtAddedOn"];
  20.  
  21. echo '<tr><td width="90% align=left">'. $stitle. '</td></tr>';
  22.  
  23. }
  24. ?>
  25.  
  26. </table>
  27.  
  28. </p>
  29. </div>
Reputation Points: 11
Solved Threads: 7
Junior Poster in Training
amigura is offline Offline
71 posts
since Jan 2008
May 17th, 2008
0

Re: how to explode records?

great thanks works now but is there anyway to limit it to showing 9 records?
Reputation Points: 10
Solved Threads: 0
Junior Poster
shadiadiph is offline Offline
117 posts
since Apr 2008
May 17th, 2008
0

Re: how to explode records?

add limit 9
Reputation Points: 11
Solved Threads: 7
Junior Poster in Training
amigura is offline Offline
71 posts
since Jan 2008
May 17th, 2008
0

Re: how to explode records?

cheers excellent
Reputation Points: 10
Solved Threads: 0
Junior Poster
shadiadiph is offline Offline
117 posts
since Apr 2008
May 18th, 2008
0

Re: how to carry exploded record?

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?


php Syntax (Toggle Plain Text)
  1. <div id="news">
  2.  
  3. <div class="asnazzy">
  4. <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>
  5. <div class="aboxcontent">
  6. <h1 class="color_c">Market News</h1>
  7. <p>
  8.  
  9. <table cellspacing="0" cellpadding="2" border="0">
  10.  
  11.  
  12. <?
  13. $sql = "SELECT * FROM tblnewsdetails order by intnewsID desc limit 9";
  14. $result = mysql_query($sql);
  15. while ($row = mysql_fetch_assoc($result)) {
  16. $tradeaid = $row["intnewsID"];
  17. $accountid = $row["intAccountID"];
  18. $stitle = $row["newsshTit"];
  19. $updated = $row["dtAddedOn"];
  20.  
  21. echo '<tr><td width="90% align=left"><a href="news.php">'. $stitle. '</a></td></tr>';
  22.  
  23. }
  24. ?>
  25. <input name="newst" type="hidden" id="newst" value="<?=$stitle?>">
  26. </table>
  27.  
  28. </p>
  29. </div><b class="abottom"><b class="ab4"></b><b class="ab3"></b><b class="ab2"></b><b class="ab1"></b></b>
  30. </div>
Last edited by peter_budo; May 18th, 2008 at 5:42 am. Reason: Keep It Organized - please use [code] tags
Reputation Points: 10
Solved Threads: 0
Junior Poster
shadiadiph is offline Offline
117 posts
since Apr 2008
May 18th, 2008
0

Re: how to explode records?

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.
Reputation Points: 10
Solved Threads: 0
Junior Poster
shadiadiph is offline Offline
117 posts
since Apr 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP and Oracle connection
Next Thread in PHP Forum Timeline: Relocation Error





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC