1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Search trou a database and display on page

Discussion in 'PHP' started by Rizzler, Apr 1, 2007.

  1. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #21
    Try replacing this.
    
    else
    {
        while( $assoc = mysql_fetch_assoc( $result ) )
        {
             print_r( $assoc );
        }
    }
    
    PHP:
    With this. (Untested)
    
    else
    {
    	$int = 0;
    	
    	echo '<table border="1" cellpadding="2">' . "\n";
    	echo "<tr>\n";
    	
    	while( $assoc = mysql_fetch_assoc( $result ) )
    	{
    		echo '<td><img src="data/'. $assoc['id'] .'.jpeg" /></td>'. "\n";
    	}
    	
    	if (++$int % 6 == 0)
    	{
    		echo "</tr><tr>\n";
    	}
    	
    	echo "</tr>\n";
    	echo "</table>";
    }    
    
    
    PHP:

     
    nico_swd, Apr 1, 2007 IP
  2. Rizzler

    Rizzler Active Member

    Messages:
    14
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    88
    #22
    it did display all of them besides each other :) but not 6 per row. "all of them" :p
     
    Rizzler, Apr 1, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #23
    My bad, this:
    
     if (++$int % 6 == 0)
        {
            echo "</tr><tr>\n";
        }
    
    PHP:
    Should have gone in the loop. Try placing it under the echo in the while loop.
     
    nico_swd, Apr 1, 2007 IP
  4. Rizzler

    Rizzler Active Member

    Messages:
    14
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    88
    #24
    yey that worked! :D once again, thank you, thank you so very much for the help ^_^ i ove both you and joe! :)
     
    Rizzler, Apr 1, 2007 IP
  5. pj1s

    pj1s Active Member

    Messages:
    337
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    60
    #25
    Sure hope you are giving those guys thumbs up , pad on the backs and +rep for that work... ;)
     
    pj1s, Apr 1, 2007 IP
  6. Rizzler

    Rizzler Active Member

    Messages:
    14
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    88
    #26
    ye ofcourse i gave them +rep ;)

    they are both very nice guys! :D


    [​IMG]

    Picture say it all!! :)
     
    Rizzler, Apr 1, 2007 IP
    nico_swd likes this.
  7. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #27
    Hehe. :D You're welcome, mate. Glad you got it working.
     
    nico_swd, Apr 1, 2007 IP