SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2001
    Location
    home
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need Some PHP Coding Help

    I have a php file which querys my database for club or organization information and then orders the output alphabetically in small paragraphs. This is what the chunk of code looks like:

    PHP Code:
    $display_block "<h3><font color=\"000080\">You're search returned $num club(s).</font></h3>";

    while (
    $row mysql_fetch_array($result)) {
        
    $dealer_name $row['dealer_name'];
        
    $street_address $row['street_address'];
        
    $city $row['city'];
        
    $state $row['state'];
        
    $zip_code $row['zip_code'];
        
    $region $row['region'];
        
    $country $row['country'];
        
    $phone $row['phone'];
        
    $web_address $row['web_address'];
        
    $notes $row['notes'];    

        if (
    $web_address == "") {
                
    $web_address "Unknown";
        }
        
        
    $display_block .= "<p><b>$dealer_name</b><br />$street_address<br />$city&nbsp;$state&nbsp;  $zip_code<br />$country<br />Phone:&nbsp; $phone<br />Website: <a href=\"$web_address\" target=\"_blank\">$web_address</a><br />Notes:&nbsp; $notes<br /></p>";
        } 
    The problem is that one column of small paragraphs is created.....one paragraph after the other. If there is a large number of organizations returned, the user must do a lot of scrolling to reach the bottom. I'd like to organize the output so that two organizations are returned...in a row. I know I need to construct a table, but the problem I'm having is trying to get the organizations to populate consecutively one after the other. Can anyone help?

  2. #2
    :) delemtri's Avatar
    Join Date
    Jun 2001
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This
    PHP Code:
       $display_block .= "<p><b>$dealer_name</b><br />$street_address<br />$city&nbsp;$state&nbsp;  $zip_code<br />$country<br />Phone:&nbsp; $phone<br />Website: <a href=\"$web_address\" target=\"_blank\">$web_address</a><br />Notes:&nbsp; $notes<br /></p>"
    can be changed to this
    PHP Code:
    $display_block .= "<td><b>$dealer_name</b><br />$street_address<br />$city&nbsp;$state&nbsp;  $zip_code<br />$country<br />Phone:&nbsp; $phone<br />Website: <a href=\"$web_address\" target=\"_blank\">$web_address</a><br />Notes:&nbsp; $notes<br /></td>"
    and you can add
    PHP Code:
    $display_block "<table><tr>"// to the start and
    $display_block .= "</tr></table>"// to the end. 

  3. #3
    SitePoint Zealot
    Join Date
    Apr 2001
    Location
    home
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oliver,

    Not sure what you mean by:

    PHP Code:
    $display_block "<table><tr>"// to the start and
    $display_block .= "</tr></table>"// to the end. 
    To the start and end of what?

    -rob

  4. #4
    :) delemtri's Avatar
    Join Date
    Jun 2001
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your code. Although I messed up on the first one. It should be:


    $display_block .= "<table><tr>"; // to the start and

  5. #5
    SitePoint Zealot
    Join Date
    Apr 2001
    Location
    home
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This won't work either because what this does is generate only 1 row with multiple cells in it. I need to place 2 table cells in one row and then have the number of rows repeat according to however many organizations are pulled out of the database. So....if there were 18 organizations pulled out by the query, 9 rows listing 2 organizations would show.

  6. #6
    :) delemtri's Avatar
    Join Date
    Jun 2001
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In that case, this
    PHP Code:
       $display_block .= "<p><b>$dealer_name</b><br />$street_address<br />$city&nbsp;$state&nbsp;  $zip_code<br />$country<br />Phone:&nbsp; $phone<br />Website: <a href=\"$web_address\" target=\"_blank\">$web_address</a><br />Notes:&nbsp; $notes<br /></p>"
    can be changed to this
    PHP Code:
    if ($nr) { $display_block .= "</tr><tr>"$nr false; } else { $nr true; }
    $display_block .= "<td><b>$dealer_name</b><br />$street_address<br />$city&nbsp;$state&nbsp;  $zip_code<br />$country<br />Phone:&nbsp; $phone<br />Website: <a href=\"$web_address\" target=\"_blank\">$web_address</a><br />Notes:&nbsp; $notes<br /></td>"
    and you can add
    PHP Code:
    $display_block "<table><tr><td colspan=2></td>"$nr=true// to the start and
    $display_block .= "</tr></table>"// to the end. 

  7. #7
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Wolverhampton, UK
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    y <br />...?

    i kno it is used as short hand in xml to be as is <br></br> but <br> has no closin' tag #8{


    beachball

  8. #8
    You want what? By when?? Milamber's Avatar
    Join Date
    Jan 2001
    Location
    California
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by beachball
    y <br />...?

    i kno it is used as short hand in xml to be as is <br></br> but <br> has no closin' tag #8{


    beachball

    XML rules dictate that all tags must be closed.

    IE "<br />" and "<hr />"
    -Jeff Minard | jrm.cc - Battlefield 2 Stats

  9. #9
    SitePoint Zealot
    Join Date
    Apr 2001
    Location
    home
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oliver,

    That worked! I had to clean up the code a bit, but it worked! Thanks so much!!!

    -Rob


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •