how to explode records?

Thread Solved

Join Date: Apr 2008
Posts: 78
Reputation: shadiadiph is an unknown quantity at this point 
Solved Threads: 0
shadiadiph shadiadiph is offline Offline
Junior Poster in Training

how to explode records?

 
0
  #1
May 17th, 2008
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.

  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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training

Re: how to explode records?

 
0
  #2
May 17th, 2008
your output result has to be in side the query loop. if outside only one result is done.

  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>
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 78
Reputation: shadiadiph is an unknown quantity at this point 
Solved Threads: 0
shadiadiph shadiadiph is offline Offline
Junior Poster in Training

Re: how to explode records?

 
0
  #3
May 17th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 78
Reputation: shadiadiph is an unknown quantity at this point 
Solved Threads: 0
shadiadiph shadiadiph is offline Offline
Junior Poster in Training

Re: how to explode records?

 
0
  #4
May 17th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training

Re: how to explode records?

 
0
  #5
May 17th, 2008
i just noticed the limit 1 in original code. remove this and test original code or try one below.


  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>
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 78
Reputation: shadiadiph is an unknown quantity at this point 
Solved Threads: 0
shadiadiph shadiadiph is offline Offline
Junior Poster in Training

Re: how to explode records?

 
0
  #6
May 17th, 2008
great thanks works now but is there anyway to limit it to showing 9 records?
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training

Re: how to explode records?

 
0
  #7
May 17th, 2008
add limit 9
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 78
Reputation: shadiadiph is an unknown quantity at this point 
Solved Threads: 0
shadiadiph shadiadiph is offline Offline
Junior Poster in Training

Re: how to explode records?

 
0
  #8
May 17th, 2008
cheers excellent
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 78
Reputation: shadiadiph is an unknown quantity at this point 
Solved Threads: 0
shadiadiph shadiadiph is offline Offline
Junior Poster in Training

Re: how to carry exploded record?

 
0
  #9
May 18th, 2008
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?


  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
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 78
Reputation: shadiadiph is an unknown quantity at this point 
Solved Threads: 0
shadiadiph shadiadiph is offline Offline
Junior Poster in Training

Re: how to explode records?

 
0
  #10
May 18th, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC