User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Apr 2008
Posts: 31
Reputation: shadiadiph is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
shadiadiph shadiadiph is offline Offline
Light Poster

how to explode records?

  #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 4:40 am. Reason: Keep It Organized - please use [code] tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2008
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training

Re: how to explode records?

  #2  
May 17th, 2008
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>
Reply With Quote  
Join Date: Apr 2008
Posts: 31
Reputation: shadiadiph is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
shadiadiph shadiadiph is offline Offline
Light Poster

Re: how to explode records?

  #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 8:44 pm.
Reply With Quote  
Join Date: Apr 2008
Posts: 31
Reputation: shadiadiph is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
shadiadiph shadiadiph is offline Offline
Light Poster

Re: how to explode records?

  #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 8:59 pm.
Reply With Quote  
Join Date: Jan 2008
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training

Re: how to explode records?

  #5  
May 17th, 2008
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>
Reply With Quote  
Join Date: Apr 2008
Posts: 31
Reputation: shadiadiph is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
shadiadiph shadiadiph is offline Offline
Light Poster

Re: how to explode records?

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

Re: how to explode records?

  #7  
May 17th, 2008
add limit 9
Reply With Quote  
Join Date: Apr 2008
Posts: 31
Reputation: shadiadiph is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
shadiadiph shadiadiph is offline Offline
Light Poster

Re: how to explode records?

  #8  
May 17th, 2008
cheers excellent
Reply With Quote  
Join Date: Apr 2008
Posts: 31
Reputation: shadiadiph is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
shadiadiph shadiadiph is offline Offline
Light Poster

Re: how to carry exploded record?

  #9  
May 17th, 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 4:42 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote  
Join Date: Apr 2008
Posts: 31
Reputation: shadiadiph is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
shadiadiph shadiadiph is offline Offline
Light Poster

Re: how to explode records?

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:00 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC