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 422,936 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,528 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: 169 | Replies: 4
Reply
Join Date: May 2008
Location: Hyderabad,India
Posts: 89
Reputation: Suhacini is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Suhacini Suhacini is offline Offline
Junior Poster in Training

Problem in displaying data from DB

  #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:
while($data = mysql_fetch_array($result)) { 
    echo $query;
    echo ' <tr> <td colspan="3" > <a href="'.$data['MedName'].'" >' . $data['dispname'].' </a> </td>'; 
    echo'</tr>'; 
}
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 554
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 57
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Posting Pro

Re: Problem in displaying data from DB

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

$table = '<table id="module" class="module" border="0" cellspacing="0" cellpadding="5">';

$cols = 3;
$per_column = 10;
$col = 1;
$table .= '<tr>';
$table .= '<td>';
$table .= '<table id="module" class="module" border="0" cellspacing="0" cellpadding="5">';
$i = 0;
while ($row = $p->fetchAssoc($query)) {
	$table .= '<tr>';
	$table .= '<td><a href="' . $row['MedName'] . '">' . $row['dispname'] . '</a></td>';
	$table .= '</tr>';
	if ($i == ($per_column*$col)) {
		$table .= '</table>';
		$table .= '</td>';
		$table .= '<td>';
		$table .= '<table id="module" class="module" border="0" cellspacing="0" cellpadding="5">';
	$col++;
	}
$i++;
}
$table .= '</table>';
$table .= '</td>';
$table .= '</tr>';
$table .= '</table>';

echo $table;
Last edited by kkeith29 : Jun 4th, 2008 at 3:30 am.
Reply With Quote  
Join Date: May 2008
Location: Hyderabad,India
Posts: 89
Reputation: Suhacini is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Suhacini Suhacini is offline Offline
Junior Poster in Training

Re: Problem in displaying data from DB

  #3  
Jun 4th, 2008
what is $p here
while ($row = $p->fetchAssoc($query)) 
Suhasini
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 554
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 57
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Posting Pro

Re: Problem in displaying data from DB

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

Re: Problem in displaying data from DB

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

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

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

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

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