SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Echo

  1. #1
    SitePoint Enthusiast Yonko's Avatar
    Join Date
    Jun 2001
    Location
    Panama
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Echo

    Can I include HTML tags inside an echo statement that shows a MySQL query result? If true please show me the syntax. Thanks.

  2. #2
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am assuming this is what you mean?


    <?//connection etc.......
    $result=mysql_query("FETCH * FROM table");?>

    <table>
    <tr><td>field 0</td><td>field 1</td></tr>
    <?
    while($row=mysql_fetch_row($result)){
    echo "<tr><td>$row[0]</td><td>$row[1]<td></tr>\n";
    }
    ?>
    </table>


    ED: - Should of course be SELECT * - where I got FETCH from I have not a clue !
    Last edited by firepages; Jul 4, 2001 at 18:10.

  3. #3
    SitePoint Enthusiast Yonko's Avatar
    Join Date
    Jun 2001
    Location
    Panama
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sort of. What I really need is formatting the font size and color of the output of my variable. I want to know if I can insert <a href> and <font> tags inside an ECHO statement. Thanks.

  4. #4
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, you can. You can insert any HTML, Javascript, CSS, or any other language that the browser can interpret in echo.

    PHP Code:
    <?//connection etc....... 
    $result=mysql_query("FETCH * FROM table");?> 

    <table> 
    <tr><td>field 0</td><td>field 1</td></tr> 
    <? 
    while($row=mysql_fetch_row($result)){ 
    echo 
    "<tr><td><a href="asdf"><font color="red">$row[0]</font></a></td><td>$row[1]<td></tr>\n"

    ?> 
    </table>

  5. #5
    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 qslack
    Yes, you can. You can insert any HTML, Javascript, CSS, or any other language that the browser can interpret in echo.

    PHP Code:
    <?//connection etc....... 
    $result=mysql_query("FETCH * FROM table");?> 

    <table> 
    <tr><td>field 0</td><td>field 1</td></tr> 
    <? 
    while($row=mysql_fetch_row($result)){ 
    echo 
    "<tr><td><a href="asdf"><font color="red">$row[0]</font></a></td><td>$row[1]<td></tr>\n"

    ?> 
    </table>


    good, but you forgot to excape your quotes


    PHP Code:
    <?//connection etc....... 
    $result=mysql_query("SELECT * FROM table");?> 

    <table> 
    <tr><td>field 0</td><td>field 1</td></tr> 
    <? 
    while($row=mysql_fetch_row($result)){ 
    echo 
    "<tr><td><a href=\"asdf\"><font color=\"red\">$row[0]</font></a></td><td>$row[1]<td></tr>\n"

    ?> 
    </table>

    very important.
    -Jeff Minard | jrm.cc - Battlefield 2 Stats


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
  •