I have an iframe in my page in which i wud like to load weblinks from a database which contains a name and the corresponding link, the name is selected through a dropdown. I know we can do that by giving "src" attribute to the option of the name in the dropdown option tag but i want to get it from the database. I'm using Ajax.
<?php
$q = var_dump($_GET['q']);
$Marketplace = $_POST['txtHint'];
$con = mysqli_connect('localhost','Chuk','pass','Login');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
if(isset($_GET["q"]))
{
mysqli_select_db($con,"ajax_demo");
$sql="SELECT Website FROM Details WHERE ID = '.$q.' AND Marketplace = '.$Marketplace.'";
$result = mysqli_query($con,$sql);
echo "<iframe src=$url'" . $act['Website'] . "'></iframe>";
$url= $row['Website'];
}
mysqli_close($con);
?>
First of all, try to use PDO instead of mysqli (see the documentation here).
Secondly, to concatenate string and variable must be like that:
$sql="SELECT Website FROM Details WHERE ID = '".$q."' AND Marketplace = '".$Marketplace."'";
Thirdly, where does $act
come from ? What about $row
? I think you forgot to do a loop in order to get data from $result
.