SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2011
    Location
    Trinidad and Tobago
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to echo this statement to HTML

    Ok I have a statement I am trying to echo but it isn't working for some reason the statement is
    PHP Code:
     echo "<li><a href='#' onclick='History.pushState({state:null},'article,$id','article'); return false;'>".$row['title']."</a> </li>"
    everything after the } is being outputed but not in sequence so my statement doesn't work in HTML how can I solve this issue

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    PHP Code:
    // added a line end to make it easier to read on here

     
    echo "<li><a href='#' onclick=\"History.pushState({state:null},'article,$id','article'); 
                          return false;\">"
    .$row['title']."</a> </li>"
    Oh the joys of writing js inside php ... Try that instead, if it does not work try looking at the source code of the page.

    I'd test this out on a single new test page till the complexity is worked out.

    Then repeat using the heredoc syntax for strings - you might find that easier to work with when outputing js.

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2011
    Location
    Trinidad and Tobago
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Cups View Post
    PHP Code:
    // added a line end to make it easier to read on here

     
    echo "<li><a href='#' onclick=\"History.pushState({state:null},'article,$id','article'); 
                          return false;\">"
    .$row['title']."</a> </li>"
    Oh the joys of writing js inside php ... Try that instead, if it does not work try looking at the source code of the page.

    I'd test this out on a single new test page till the complexity is worked out.

    Then repeat using the heredoc syntax for strings - you might find that easier to work with when outputing js.
    Thanks will give it a shot.

  4. #4
    SitePoint Zealot
    Join Date
    Aug 2011
    Location
    Trinidad and Tobago
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This works tks alot


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
  •