TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-12-2008, 04:24 PM   #1 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default man,aging the outputs , need urgent help

hey i have a problem with organizing the outputs from database

for exemple i want to be in a row 5 names then come to the other ligne and put other 5 rows

here is my code

PHP Code:
while($row mysql_fetch_array($reesul))
 {
    echo 
$row['name'];
    echo 
"<img src='$row[photo]'>";
 } 
thans in advance , i really need the answer thanks
__________________
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 03-12-2008, 05:19 PM   #2 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default

maybe this??

PHP Code:
while($row mysql_fetch_array($reesul))
 {
    for(
$i=0;$i<5;$i++)
    {
        
$row mysql_fetch_array($reesul);
        echo 
$row['name'];
        echo 
"<img src='$row[photo]'>";
    }
 } 
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Old 03-12-2008, 05:23 PM   #3 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

no , for exemple
the name of the singer then his photo under the name
5 photos and name on one ligne
then it come to the other ligne and post 5 other , .....
__________________
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 03-12-2008, 05:25 PM   #4 (permalink)
The Acquainted
 
freenity's Avatar
 
Join Date: Feb 2008
Posts: 119
Thanks: 17
freenity is on a distinguished road
Default

ah, then I think you have to while the whole results put names in one array, and photos in another.
After that just print 5 names from the first array, then 5 photos on the other lines from the second array, and so on...
__________________
http://feudal-times.net - My PBB Game
http://gwphp.feudal-times.net - My Blog "Gaming With PHP"
freenity is offline  
Reply With Quote
Old 03-12-2008, 06:46 PM   #5 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

Then I could suggest to make it a 3D array.

array contains an array for the first value of the first array, and then in that array the information from the value you're trying to access. I will 'map' it out later, got to go!
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 03-12-2008, 08:53 PM   #6 (permalink)
The Contributor
 
DeMo's Avatar
 
Join Date: Jan 2008
Location: Brazil
Posts: 77
Thanks: 14
DeMo is on a distinguished road
Default

From your first post it seems the photos also come from the database.
How is the data returned by your SQL query organized?

If it returns 5 rows for each artist (name repeats but the photo changes) you could do it like this:
PHP Code:
// Some helper variables
$counter 0;
$last_name '';

while (
$row mysql_fetch_array($reesul) {
  ++
$counter;

  
// Check if we have a new name
  
if ($row['name'] != $last_name) {
    
// Yes, we have a new name so we print it
    
echo $row['name'], '<br />';
    
// And we also update $last_name to the current name.
    
$last_name $row['name'];
  }
  
  
// Here we print the image tag
  
echo '<img src="'$row['photo'], '" />';

  
// If we looped through 5 records it's time to print a line break (<br />)
  
if ($counter == 0) {
    echo 
'<br />';
  }

Send a message via ICQ to DeMo Send a message via MSN to DeMo Send a message via Skype™ to DeMo
DeMo is offline  
Reply With Quote
Old 03-12-2008, 09:16 PM   #7 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

I'd go with CSS. Something like:

PHP Code:
echo '<ul id="listing">';
while( 
$row mysql_fetch_array($result) )
{
    
// this would be a loop through all the entries
    
echo '<li>
<div>'
.$row['title'].'</div>
<div><img src="'
.$row['photo'].'" /></div>
</li>'
;
}
echo 
'<li class="clear">&nbsp;</li></ul>'
And the CSS:

Code:
#listing { width:600px;}
#listing li { width:100px; float:left;}
#listing li.clear { float:none; clear:both; height:1px; overflow:hidden; line-height:1px;}
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 03-13-2008, 07:40 PM   #8 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

thanks but the name and photo changes
__________________
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Reply



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

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:29 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design