Problem in displaying data from DB

Please support our PHP advertiser: 50% off 6 Months Dedicated Server Hosting from 1&1!
Reply

Join Date: May 2008
Posts: 90
Reputation: Suhacini is an unknown quantity at this point 
Solved Threads: 0
Suhacini Suhacini is offline Offline
Junior Poster in Training

Problem in displaying data from DB

 
0
  #1
Jun 4th, 2008
Hi,
I wanted to display data which is in my db.The format of displaying must be in a div, in that div 3 columns & each column must have 10 rows.Am using this:
  1. while($data = mysql_fetch_array($result)) {
  2. echo $query;
  3. echo ' <tr> <td colspan="3" > <a href="'.$data['MedName'].'" >' . $data['dispname'].' </a> </td>';
  4. echo'</tr>';
  5. }
which is displaying it in a single line. I used even for loop which is displaying again in the single line.What way can be used to print in the above format?
Suhasini
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,237
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 171
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: Problem in displaying data from DB

 
0
  #2
Jun 4th, 2008
here is something i typed up a few weeks ago. it should work.

  1.  
  2. $table = '<table id="module" class="module" border="0" cellspacing="0" cellpadding="5">';
  3.  
  4. $cols = 3;
  5. $per_column = 10;
  6. $col = 1;
  7. $table .= '<tr>';
  8. $table .= '<td>';
  9. $table .= '<table id="module" class="module" border="0" cellspacing="0" cellpadding="5">';
  10. $i = 0;
  11. while ($row = $p->fetchAssoc($query)) {
  12. $table .= '<tr>';
  13. $table .= '<td><a href="' . $row['MedName'] . '">' . $row['dispname'] . '</a></td>';
  14. $table .= '</tr>';
  15. if ($i == ($per_column*$col)) {
  16. $table .= '</table>';
  17. $table .= '</td>';
  18. $table .= '<td>';
  19. $table .= '<table id="module" class="module" border="0" cellspacing="0" cellpadding="5">';
  20. $col++;
  21. }
  22. $i++;
  23. }
  24. $table .= '</table>';
  25. $table .= '</td>';
  26. $table .= '</tr>';
  27. $table .= '</table>';
  28.  
  29. echo $table;
Last edited by kkeith29; Jun 4th, 2008 at 3:30 am.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 90
Reputation: Suhacini is an unknown quantity at this point 
Solved Threads: 0
Suhacini Suhacini is offline Offline
Junior Poster in Training

Re: Problem in displaying data from DB

 
0
  #3
Jun 4th, 2008
what is $p here
  1. while ($row = $p->fetchAssoc($query))
Suhasini
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,237
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 171
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: Problem in displaying data from DB

 
0
  #4
Jun 4th, 2008
my bad, use to my class is use. change that to mysql_fetch_assoc($query)
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 90
Reputation: Suhacini is an unknown quantity at this point 
Solved Threads: 0
Suhacini Suhacini is offline Offline
Junior Poster in Training

Re: Problem in displaying data from DB

 
0
  #5
Jun 4th, 2008
Its Working.But have small problem, I have 4 buttons Home Categories Brand Store in a row.When I click each button the text display.Here if catogery is clicked that is in the same row but remaining 3 buttons are moving down.when it is clicked again..they are going back to normal position.Why is it like that?
Suhasini
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 517 | Replies: 4
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC