+ Post New Thread
Results 1 to 2 of 2
Coding Thread, PHP - Quotes and $$$ in Coding and Web Development; Very simple php script: $result = mysql_query("SELECT id, fullname FROM mdl_course"); while($row = mysql_fetch_array($result)) { echo $row['id'] . " " ...
  1. #1

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    29

    PHP - Quotes and $$$

    Very simple php script:

    $result = mysql_query("SELECT id, fullname FROM mdl_course");
    while($row = mysql_fetch_array($result))
    {
    echo $row['id'] . " " . $row['fullname'];
    echo "<br />";
    }
    ?>

    But I want to change it so that I can write 'id' and 'fullname' into <a href=" ">

    Something like:

    <a href="www.link.com/$row['id']">$row['fullname']</a>

    Can anyone help?

  2. #2

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,406
    Thank Post
    639
    Thanked 961 Times in 661 Posts
    Blog Entries
    2
    Rep Power
    324
    Either use single quotes and drop out of the string to pull in the variables; or use double quotes, escape the ones you want echo'd out, and use curly braces to pull in the variables.

    Method 1

    PHP Code:
    echo '<a href="http://www.link.com/' $row['id'] . '">' $row['fullname'] . '</a>'
    Method 2

    PHP Code:
    echo "<a href=\"http://www.link.com/{$row['id']}\">{$row['fullname']}</a>"

  3. Thanks to webman from:

    danIT (8th February 2009)

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 5
    Last Post: 13th August 2009, 12:56 PM
  2. arrrrggghh! vbs and quotes
    By box_l in forum Scripts
    Replies: 23
    Last Post: 10th February 2009, 09:08 AM
  3. [Joke] Real-life Dilbert manager quotes
    By somabc in forum Jokes/Interweb Things
    Replies: 2
    Last Post: 18th December 2008, 03:56 PM
  4. Unsolicited quotes from Internet Business Index
    By sparkeh in forum General Chat
    Replies: 7
    Last Post: 1st November 2008, 06:50 PM
  5. WinOS upgrade - quotes required : recommendations?
    By contink in forum Educational Software
    Replies: 5
    Last Post: 6th May 2008, 10:58 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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