1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Rep Power

    Insert Variable into an iframe

    Hi all, I am trying to create a page that displays videos bu querying a database. I have it working properly except that i want it to be an IFRAME that we can control the height and width. Right now if you put the IFRAME into the SQL server, it displays the IFRAME. What I am trying to do is get a PHP variable to be parsed in the src part of the iframe. Is this at all possible?

    Here is my code

    $sqlget = "SELECT * FROM some_database";
    $sqldata = sqlsrv_query($link, $sqlget);
    if( $sqldata === false) 
    	echo("Critical Error!, Please contact your Administrator!");
    	// die(print_r (sqlsrv_errors(), true));
    Lots of HTML
    <form name="videos" method="post" action="somepage.php">
            <input type="submit" value="Post Your Video!" />
         	<table align="center" width="640px" cellpadding="2" cellspacing="2" border="0">
    		$counter =1;
    		while($row = sqlsrv_fetch_array($sqldata))
    			if ($counter == 1)
    			echo '<td colspan="2">';
    // This is current
    			echo $row['some_data'];
    /* This is what I would like it to look like */
    //echo '<iframe width="400px" height="300px" src="PHP Variable goes here" frameborder="0" allowfullscreen></iframe>';
    			echo "</td>";
    			if ($counter % 3 == 0)
    				echo "</tr><tr>";
    Is what I am trying to do at all possible? If not, what's a better way to go about it? I am fairly new when it comes to PHP / SQL
  2. #2
  3. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    A Land Down Under
    Rep Power
    You should be able to do it like this
    <iframe src="mypage.php?key=val">
    Then in your iframes page code you can reference this with
    PHP Code:
    $key $_GET ["key"]; 

    Comments on this post

    • sir_drinxalot agrees

IMN logo majestic logo threadwatch logo seochat tools logo