Ich vermute mal von dem Script hast du nichts selber geschrieben, oder? Andernfalls sollte es doch eine Leichtigkeit sein. Das was nach dem Submit aufgerufen werden soll muss halt in die Abfrage rein.
Hallo an alle,
ich habe mir vor einigen tagen eine kleine suchabfrage in einer datenbank zusammengebastelt. Das ergebnis erscheint automatisch mit dem Laden der PHP Seite. Ich möchte aber gerne das Suchergebnis nur bei Klick auf einen Submit Button abfragen. Ich habe das mit if (isset( $_POST['eintragen'] ))
{ probiert aber ich weiss nicht wo ich das in den Code einfügen soll.
Wenn ich es einfüge funktioniert die Suche nicht mehr oder es kommen Fehlermeldungen.
Sagt mir jemand wo ich das einbinden müsste ?
PHP-Code:<?php require_once('../Connections/Test.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Recordset1 = 3;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_Test, $Test);
$query_Recordset1 = "SELECT * FROM mytable WHERE mytable.vorname LIKE '%$airbag%' ORDER BY mytable.id DESC";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $Test) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);
$TFM_LimitLinksEndCount = 2;
$TFM_temp = $pageNum_Recordset1 + 1;
$TFM_startLink = max(1,$TFM_temp - intval($TFM_LimitLinksEndCount/2));
$TFM_temp = $TFM_startLink + $TFM_LimitLinksEndCount - 1;
$TFM_endLink = min($TFM_temp, $totalPages_Recordset1 + 1);
if($TFM_endLink != $TFM_temp) $TFM_startLink = max(1,$TFM_endLink - $TFM_LimitLinksEndCount + 1);
?>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="formular" id="formular">
<p>
<input type="submit" name="eintragen" id="eintragen" value="Abschicken" />
<input type="text" name="airbag" id="airbag" value="<?php $_POST['airbag'];?>"/>
</p>
<?php do { ?>
<table width="181" height="88" border="0" cellpadding="0">
<tr>
<td width="155"><?php echo $row_Recordset1['vorname']; ?></td>
</tr>
<tr>
<td><?php echo $row_Recordset1['alter']; ?></td>
</tr>
</table>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?><p>
<?php
for ($i=$TFM_startLink; $i <= $TFM_endLink; $i++) {
$TFM_counter = ($i - 1) * $maxRows_Recordset1 + 1;
$TFM_endCounter = min($totalRows_Recordset1,$TFM_counter + $maxRows_Recordset1 - 1);
if($i-1 != $pageNum_Recordset1) {
printf('<a href="'."%s?pageNum_Recordset1=%d%s", $currentPage, $i-1, $queryString_Recordset1.'">');
echo "$TFM_counter-$TFM_endCounter</a>";
}else{
echo "<strong>$TFM_counter-$TFM_endCounter</strong>";
}
if($i != $TFM_endLink) echo "|";
}
?></p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
Ich vermute mal von dem Script hast du nichts selber geschrieben, oder? Andernfalls sollte es doch eine Leichtigkeit sein. Das was nach dem Submit aufgerufen werden soll muss halt in die Abfrage rein.
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)