Jump to content

Trouble displaying results on same page as search box


Eiolon

Recommended Posts

All I want to do is have the results shown on the same page as the search box.  I don't want it to be directed to a second page that would have the results.

 

As it stands, if I run the query nothing is displayed.

 

I can get it to work if I leave out:

 

if (isset($_GET['submit'])) { }

 

but I need it to error out of a row is not returned and I don't want the error to always be shown until a correct query has been executed.

 


<?php

define ('DB_USER', 'root');			
define ('DB_PASS', '');	
define ('DB_HOST', 'localhost');	
define ('DB_NAME', 'trailers');		

$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASS) OR die ('Cannot connect to MySQL server.');
mysql_select_db (DB_NAME) OR die ('Cannot connect to database.');

$barcode = $_GET['barcode'];

if (isset($_GET['submit'])) {

$query_trailer = "SELECT * FROM trailers WHERE barcode = '$barcode'";
$trailer = mysql_query($query_trailer) OR die ('Cannot retrieve trailer information.');
$row_trailer = mysql_fetch_assoc($trailer);
$total = mysql_num_rows($trailer);

if ($total == 0) {
echo 'Nothing found';
}

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
<!--
function focus(){document.search.barcode.focus();}
// -->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="210;url=http://library/trailers" />
<title>Trailer</title>
</head>

<body onLoad=focus()>

<p><?php echo $row_trailer['title']; ?> (<?php echo $row_trailer['year']; ?>)</p>

<object width="<?php echo $row_trailer['width']; ?>" height="<?php echo $row_trailer['height']; ?>"
classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
codebase="http://www.apple.com/qtactivex/qtplugin.cab">
<param name="src" value="http://library/trailers/<?php echo $row_trailer['filename']; ?>.mov">
<param name="autoplay" value="true">
<param name="controller" value="false">

<embed src="<?php echo $row_trailer['filename']; ?>.mov" width="<?php echo $row_trailer['width']; ?>" height="<?php echo $row_trailer['height']; ?>"
autoplay="true" controller="false"
pluginspage="http://www.apple.com/quicktime/download/">
</embed>

</object>

<form id="search" name="search" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">

<p style="font-size: 30px; font-family: arial; font-weight: bold;">SCAN DVD BARCODE</p>

<input name="barcode" type="text" id="barcode" style="font-size: 30px; height:30px; width: 400px;"/>
<input type="submit" name="submit" id="submit" value="Search" />

</form>

</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.