Autor Zpráva
Cup
Profil
ucebnicovy priklad ... a nekona jak by mel ... nevidite prosim chybu??? ... vubec nic to neudela ... je mrtvej jak kdyby s tim phpeckem nebyl vubec propojenej

<!DOCTYPE HTML PUBLIC 

"-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<title>Poznejte vína ve vybrane oblasti</title>
</head>
<body bgcolor="white">
<?php
include 'db.inc';
include 'error.inc';

function clean ($input, $maxlength)
{
$input = substr($input, 0, $maxlength);
$input = EscapeShellCmd($input);
return ($input);
}

function displayWinesList($connection, $query, $regionName)
{
if (!($result = @ mysql_query ($query, $connection)))
showerror();

$rowsFound = @ mysql_num_rows($result);

if ($rowsFound > 0)
{
echo "vína z oblasti $regionName <br>";

echo "
<table>
<tr>
" .
"
<th>ID vína</th>" .
"
<th>Název vína</th>" .
"
<th>Typ</th>" .
"
<th>Ročník</th>" .
"
<th>vinařství</th>" .
"
<th>Popis</th>" .
"
</tr>";

while ($row = @ mysql_fetch_array($result))
{
echo "
<tr>" .
"
<td>" . $row["wine_id"] . "</td>" .
"
<td>" . $row["wine_name"] . "</td>" .
"
<td>" . $row["type"] . "</td>" .
"
<td>" . $row["year"] . "</td>" .
"
<td>" . $row["winery_name"] . "</td>" .
"
<td>" . $row["description"] . "</td>" .
"
</tr>";
}

echo "
</table>";
}

echo "Zadaným kriteriím vyhovělo $fowsFound nalezených záznamů<br>";
}

$scriptName = "7-3_vypis_vin_z_databeze.php";

if (empty($regionName))
{

?>

<form action="<?=$scriptName;?>" method="GET">
<br>Zadejte požadovanou vinařskou oblast:
<input type="text" name="regionName" value="Všechny">
(zapisem všechny zobrazíte vsechny oblasti)
<br>
<input type="submit" value="Zobrazit vína">
</form><br>
<a href="index.php">Domů</a>


<?php
}

else
{

$regionName = clean($regionName, 30);

if (!($connection = @ mysql_connect($hostname, $username, $password)))
die ("nemohu se připojit");


if (!mysql_select_db($databasename, $connection))
showerror();

$query = "SELECT w.wine_id,
w.wine_name,
w.description,
w.type,
w.year,
wry.winery_name
FROM winery wry, region r, wine w
WHERE wry.region_id = r.region_id
AND w.winery_id = wry.winery_id";

if ($regionName != "Všechny" )
$query .= " AND r.region_name = "$regionName"";

$query .= " ORDER BY w.wine_name";

displayWinesList($connection, $query, $regionName);

mysql_close($connection);

}
?>


</body>
</html>
joejoe
Profil *
1) zalomitkovat uvozoky:
$query .= " AND r.region_name = "$regionName"";
2) zrejme problem register_globals ->
zkusit
$regionName = clean($regionName, 30);
zmenit na
$regionName = clean($_REQUEST['regionName'], 30);
Toto téma je uzamčeno. Odpověď nelze zaslat.

0