Jump to content
Larry Ullman's Book Forums

Shalmaneser

Members
  • Posts

    1
  • Joined

  • Last visited

Shalmaneser's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi. I have this up and running: http://prntscr.com/5parca The input field uses autocomplete to select a horse. I want to link the autoconnect field to the SQL select query as a filter. Ideally, the query will only run when the user has selected a horse from the list of horses. <?php require_once('../Connections/AlKh.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $maxRows_qHorses = 20; $pageNum_qHorses = 0; if (isset($_GET['pageNum_qHorses'])) { $pageNum_qHorses = $_GET['pageNum_qHorses']; } $startRow_qHorses = $pageNum_qHorses * $maxRows_qHorses; mysql_select_db($database_AlKhamsa, $AlKhamsa); $query_qHorses = "SELECT * FROM horses"; $query_limit_qHorses = sprintf("%s LIMIT %d, %d", $query_qHorses, $startRow_qHorses, $maxRows_qHorses); $qHorses = mysql_query($query_limit_qHorses, $AlKhamsa) or die(mysql_error()); $row_qHorses = mysql_fetch_assoc($qHorses); if (isset($_GET['totalRows_qHorses'])) { $totalRows_qHorses = $_GET['totalRows_qHorses']; } else { $all_qHorses = mysql_query($query_qHorses); $totalRows_qHorses = mysql_num_rows($all_qHorses); } $totalPages_qHorses = ceil($totalRows_qHorses/$maxRows_qHorses)-1; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>DEMO of "how to feed jQuery UI�s autocomplete with a database-generated dataset" | burnmind.com</title> <meta name="description" content="DEMO of 'how to feed jQuery UI�s autocomplete with a database-generated dataset' | burnmind.com" /> <meta name="keywords" content="demo, burnmind, how to, jquery, ui, autocomplete, database, dataset" /> <link type="text/css" href="css/jquery-ui-1.8.5.custom.css" rel="Stylesheet" /> <style type="text/css"> body { background-color: #000; color: #fff; }; </style> <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script> <script src="js/jquery-ui-1.8.5.custom.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $('#auto').autocomplete( { source: "search.php", minLength: 3 }); }); </script> </head> <body> <p>Type the name of a horse: <input type="text" id="auto" /></p> <p> </p> <table> <tr> <td>Horse</td> <td><p>Birth </p> <p>Year</p></td> <td>Color</td> <td>Gender</td> <td>Dam</td> <td>Sire</td> </tr> <?php do { ?> <tr> <td><?php echo $row_qHorses['HorseName']; ?></td> <td><?php echo $row_qHorses['YOB']; ?></td> <td><?php echo $row_qHorses['HorseColor']; ?></td> <td><?php echo $row_qHorses['HorseGender']; ?></td> <td><?php echo $row_qHorses['DamName']; ?></td> <td><?php echo $row_qHorses['SireName']; ?></td> </tr> <?php } while ($row_qHorses = mysql_fetch_assoc($qHorses)); ?> </table> </body> </html> <?php mysql_free_result($qHorses); ?>
×
×
  • Create New...