Help - Search - Members - Calendar
Full Version: Selecting data in a popup window via option form
HTMLHelp Forums > Web Authoring > General Web Design
geekgirl101
Hi, I've got a little problem that's been bugging me for a few days where I'm trying to write a select form where the submit button sends the selected option to a popup and the popup would then display the results where the selected option matches the data in a database. My only problem is that when clicking the submit button I get "Query was empty" which means that the selected option isn't being picked up by the popup on submission. I don't know how to fix this, can anyone help me?

My current code at the moment is a mess since I've been trying all kinds of examples and now I don't even know what it's doing hehe.

QUOTE(header.php)

<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript">
function doSubmit() {
window.open("","myWindow","width=640,height=480")
document.testForm.submit()
}
</script></head>
<body>


QUOTE(search.php)

<form name="testForm" action="skinsearch.php" method="post" target="myWindow">
<span class="head3">Skin Search</span><br />
<hr />
Family
<SELECT name="skinsearch">
<OPTION SELECTED value="<?php echo $skinsearch;?>"><?php echo $skinsearch;?></OPTION>
<OPTION value="Boar">Boar</OPTION>
<OPTION value="Cat">Cat</OPTION>
<OPTION value="Raptor">Raptor</OPTION>
<OPTION value="Wolf">Wolf</OPTION>
</SELECT>
<hr />
<input type="submit" value="Search" onclick="doSubmit()" />
</form>


QUOTE(skinsearch.php)

<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>

<?php
include 'config.php';
include 'opendb.php';

$query = "SELECT DISTINCT Family, Skin from petlist WHERE Family = '%" . $_POST['skinsearch'] . "%'";
$showgif = mysql_query($myquery) or die(mysql_error());

while($row = mysql_fetch_array($showgif, MYSQL_ASSOC))
{
echo "<img src='images/db/skinthumb/{$row['Skin']}'/>";
}
?>
</body>
</html>

geekgirl101
No worries, I worked out my mistake was to do with these lines in skinsearch.php:

$query = "SELECT DISTINCT Family, Skin from petlist WHERE Family = '%" . $_POST['skinsearch'] . "%'";
$showgif = mysql_query($myquery) or die(mysql_error());

I was calling for $myquery instead of $query. And to think I had been looking at this over and over for days I only just spotted it in here.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.