Can I Pass a URL variable to an IFrame using PHP?

后端 未结 3 1007
误落风尘
误落风尘 2021-01-18 20:17

I\'ve not used PHP much (or at all) before, and I have the following code:



        
相关标签:
3条回答
  • 2021-01-18 21:06

    iFrames just take a url - and parameters can be embedded in urls just fine.

    The problem, if I understand the question clearly, is that you're mixing up your quotes:

     echo "<iframe src='sitename.com.au/directory/app/pagename.cfm?memberid='$val'
            width='100%' scrolling='vertical'></iframe>";
    

    will be outputted as

     <iframe src='sitename.com.au/directory/app/pagename.cfm?memberid=' 21254545' 
      width='100%' scrolling='vertical'></iframe>
    

    where 21254545 is an attribute of the iframe instead of part of the url.

    Assuming that you don't actually need the quotes in the url, change the echo line to:

    echo "<iframe src='sitename.com.au/directory/app/pagename.cfm?memberid=$val' width='100%' scrolling='vertical'></iframe>";
    

    And it should work.

    0 讨论(0)
  • 2021-01-18 21:09

    Seems that the

    echo "<iframe src='sitename.com.au/directory/app/pagename.cfm?memberid=$val' width='100%' scrolling='vertical'></iframe>";
    

    doesn't work anymore. You have to add the variable like this

     echo "<iframe src='sitename.com.au/directory/app/pagename.cfm?memberid=".$val."' width='100%' scrolling='vertical'></iframe>";
    

    Since the anwser was from 2012... maybe PHP patched it to be used like that now.

    0 讨论(0)
  • 2021-01-18 21:11
    • Add http:// before sitename.com.au/
    • Change memberid='$val' to memberid=$val' [remove that single quote on left of $val]
    <?php
       $val = $_GET['ID'];
       echo "<iframe src='sitename.com.au/directory/app/pagename.cfm?memberid=$val' width='100%' scrolling='vertical'></iframe>";
    ?>
    
    0 讨论(0)
提交回复
热议问题