SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2000
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello, another stupid question...I am having trouble outputting more than one colum from mysql using the following structure...any pointers? I don't have any problems if I only include one column, but I would think the following structure would work....

    Thanks

    <?php
    // Request the text of all the business listings
    $result = mysql_query("SELECT Business_Name, Business_Description, Address_1, Address_2 FROM Business");
    if (!$result) {
    echo("<P>Error performing query: " .
    mysql_error() . "</P>");
    exit();
    }

    // Display the text of each joke in a paragraph
    while ( $row = mysql_fetch_array($result) ) {
    echo("<P>" . $row["Business_Name"] . "</P>"
    "<P>" . $row["Business_Description"] .
    "</P>"
    "<P>" . $row["Address_1"] . "</P>"
    "<P>" . $row["Address_2"] . "</P>");
    }
    ?>

  2. #2
    SitePoint Zealot
    Join Date
    May 2000
    Location
    Eugene, OR
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote/font><HR>Originally posted by dylan:

    Thanks


    // Display the text of each joke in a paragraph
    while ( $row = mysql_fetch_array($result) ) {
    echo("&lt;P&gt;" . $row["Business_Name"] . "&lt;/P&gt;"
    "&lt;P&gt;" . $row["Business_Description"] .
    "&lt;/P&gt;"
    "&lt;P&gt;" . $row["Address_1"] . "&lt;/P&gt;"
    "&lt;P&gt;" . $row["Address_2"] . "&lt;/P&gt;");
    }
    ?&gt;
    <HR></BLOCKQUOTE>

    See if this works... If it does, you can thank Mr. Kevin Yank for helping me learn. If its not right, sorry.

    // Display the text of each joke in a paragraph
    while ( $row = mysql_fetch_array($result) ) {
    $busname = $row["Business_Name"];
    $busdesc = $row["Business_Description"];
    $add1 = $row["Address_1"];
    $add2 = $row["Address_2"];
    echo( &lt;p&gt; . $busname . "&lt;/p&gt;" .
    "&lt;p&gt;" . $busdesc . "&lt;/p&gt;" .
    "&lt;p&gt;" . $add1 . "&lt;/p&gt;" .
    "&lt;p&gt;" . $add2 . &lt;/p&gt; );
    }



  3. #3
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Actually, Dylan's original code was just fine, apart from a few missing dots (.) in his last echo statement.

    echo("&lt;P&gt;" . $row["Business_Name"] . "&lt;/P&gt;" . // added dot
    "&lt;P&gt;" . $row["Business_Description"] .
    "&lt;/P&gt;" . // added dot
    "&lt;P&gt;" . $row["Address_1"] . "&lt;/P&gt;" . // added dot
    "&lt;P&gt;" . $row["Address_2"] . "&lt;/P&gt;");


    ------------------
    -Kevin Yank.
    http://www.SitePoint.com/
    Helping Small Business Grow Online!


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
  •