SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Printing an array value

    I have the following php code:

    PHP Code:
    <?php
        
    //slot 1
        
    $result1=safe_query("SELECT * from trailer where tid=1");
        if (
    mysql_num_rows($result1) == 0) {
    ?>
            <form method="post" action="<?php print "$PHP_SELF"?>">
            <input type="hidden" name="tid" value="1">
            <input type="submit" value="Sign-Up">
            </form>
    <?php
        
    } else {
        
    mysql_fetch_array($result1);
    ?>
            <a href="mailto:<?php print "".$result1["email"].""?>"><?php print "".$result1["name"].""?></a><br><font class="standard"><?php print "".$result1"["sail_num"]""; ?></font>
    <?php
        }
    ?>
    And I am getting a parse error, when I start to try and print out the values in the else statement. I don't know what syntax to use.

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes you must assign the result of the mysql_fetch_array to a var like:

    PHP Code:
    <?
    $row 
    mysql_fetch_array($result1);
    ?>
    <a href="mailto:<?php print $row["email"]; ?>"><?php print $row["name"]; ?></a><br><font class="standard"><?php print $row["sail_num"?></font>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks!

    Doh! I keep forgetting to capture the value, I don't know how many times I've done that, thanks!


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
  •