943,871 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 604
  • PHP RSS
Jun 4th, 2008
0

Problem in displaying data from DB

Expand Post »
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:
PHP Syntax (Toggle Plain Text)
  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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Suhacini is offline Offline
90 posts
since May 2008
Jun 4th, 2008
0

Re: Problem in displaying data from DB

here is something i typed up a few weeks ago. it should work.

PHP Syntax (Toggle Plain Text)
  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 4:30 am.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Jun 4th, 2008
0

Re: Problem in displaying data from DB

what is $p here
PHP Syntax (Toggle Plain Text)
  1. while ($row = $p->fetchAssoc($query))
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Suhacini is offline Offline
90 posts
since May 2008
Jun 4th, 2008
0

Re: Problem in displaying data from DB

my bad, use to my class is use. change that to mysql_fetch_assoc($query)
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Jun 4th, 2008
0

Re: Problem in displaying data from DB

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?
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Suhacini is offline Offline
90 posts
since May 2008

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: Sending data to a form using hyperlink
Next Thread in PHP Forum Timeline: Display forms results





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


Follow us on Twitter


© 2011 DaniWeb® LLC