kytionut
28.01.2011, 08:03
Nu stiu daca am plasat bine subiectul dar:
Vreau sa fac un script de coduri postale dar nu reusesc
Nu stiu ce si unde gresesc deoarece nu functioneaza.Cine doreste baza de coduri postale sa zica in topic
<!-- CSS Stylesheet -->
<style type="text/css" id="dinBacau_css">
<!--
/* dinBacau CSS For Style 'Default' */
.text_normal
{
color: black;
font-family: arial;
font-size: 11px;
text-decoration: none;
}.titlu
{
color: #FFFFFF;
font-family: arial;
font-size: 12px;
text-decoration: none;
font-weight: bold;
}
table.blog {
border: 1px solid #999999;
width: 500;
color: #FFFFFF;
font-family: arial;
font-size: 12px;
text-decoration: none;
font-weight: bold;
} .blog2{
border: 1px solid #999999;
color: #000000;
text-align: center;
font-family: arial;
font-size: 12px;
text-decoration: none;
}
-->
</style>
<form name="search" method="post" action="<?$_SERVER['PHP_SELF']?>">
Cauta:
<input type="text" name="find" /> in
<Select NAME="field">
<Option VALUE="localitate">Localitatea</option>
<Option VALUE="strada">Strada</option>
<Option VALUE="numar">Numarul</option>
</Select>
<input type="hidden" name="searching" value="yes" />
<input type="submit" name="search" value="Cauta" />
</form>
<p>
<?
//This is only displayed if they have submitted the form
if ($_POST['searching'] =="yes")
{
echo "<h2>Rezultate Cautare</h2><p>";
//If they did not enter a search term we give them an error
if ($_POST['find'] == "")
{
echo "<p>You forgot to enter a search term";
exit;
}
// Otherwise we connect to our Database
mysql_connect("localhost", "298078_kyt", "prepelita") or die(mysql_error());
mysql_select_db("scurt_zxq_kyt") or die(mysql_error());
// We preform a bit of filtering
$_POST['find'] = strtoupper($find);
$_POST['find'] = strip_tags($find);
$_POST['find'] = trim ($find);
//Now we search for our search term, in the field the user specified
$data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'");
echo "<table class='blog' >";
echo "<tr><th align='center' valign='top' width='100' bgcolor='#999999'>Localitate</th><th align='center' valign='top' width='100' style='width=250;' bgcolor='#999999'>Numele Strazii</th> <th align='center' valign='top' bgcolor='#999999' >Judet</th><th align='center' valign='top' width='100' bgcolor='#999999'>Cod Postal</th></tr>";
//And we display the results
while($result = mysql_fetch_array( $data ))
{
echo "<tr ><td class='blog2'>";
echo $result['localitate'];
echo "</td><td class='blog2'>";
echo $result['strada'];
echo "</td><td class='blog2'>";
echo $result['judet'];
echo "<td class='blog2' >";
echo $result['cp'];
echo "</td></tr>";
}
echo "</table>";
//This counts the number or results - and if there wasn't any it gives them a little message explaining that
$anymatches=mysql_num_rows($data);
if ($_POST['anymatches'] == 0)
{
echo "Sorry, but we can not find an entry to match your query<br><br>";
}
//And we remind them what they searched for
echo "<b>Ai cautat Codul Postal pentru:</b> " .$_POST['find'];
}
?>
Vreau sa fac un script de coduri postale dar nu reusesc
Nu stiu ce si unde gresesc deoarece nu functioneaza.Cine doreste baza de coduri postale sa zica in topic
<!-- CSS Stylesheet -->
<style type="text/css" id="dinBacau_css">
<!--
/* dinBacau CSS For Style 'Default' */
.text_normal
{
color: black;
font-family: arial;
font-size: 11px;
text-decoration: none;
}.titlu
{
color: #FFFFFF;
font-family: arial;
font-size: 12px;
text-decoration: none;
font-weight: bold;
}
table.blog {
border: 1px solid #999999;
width: 500;
color: #FFFFFF;
font-family: arial;
font-size: 12px;
text-decoration: none;
font-weight: bold;
} .blog2{
border: 1px solid #999999;
color: #000000;
text-align: center;
font-family: arial;
font-size: 12px;
text-decoration: none;
}
-->
</style>
<form name="search" method="post" action="<?$_SERVER['PHP_SELF']?>">
Cauta:
<input type="text" name="find" /> in
<Select NAME="field">
<Option VALUE="localitate">Localitatea</option>
<Option VALUE="strada">Strada</option>
<Option VALUE="numar">Numarul</option>
</Select>
<input type="hidden" name="searching" value="yes" />
<input type="submit" name="search" value="Cauta" />
</form>
<p>
<?
//This is only displayed if they have submitted the form
if ($_POST['searching'] =="yes")
{
echo "<h2>Rezultate Cautare</h2><p>";
//If they did not enter a search term we give them an error
if ($_POST['find'] == "")
{
echo "<p>You forgot to enter a search term";
exit;
}
// Otherwise we connect to our Database
mysql_connect("localhost", "298078_kyt", "prepelita") or die(mysql_error());
mysql_select_db("scurt_zxq_kyt") or die(mysql_error());
// We preform a bit of filtering
$_POST['find'] = strtoupper($find);
$_POST['find'] = strip_tags($find);
$_POST['find'] = trim ($find);
//Now we search for our search term, in the field the user specified
$data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'");
echo "<table class='blog' >";
echo "<tr><th align='center' valign='top' width='100' bgcolor='#999999'>Localitate</th><th align='center' valign='top' width='100' style='width=250;' bgcolor='#999999'>Numele Strazii</th> <th align='center' valign='top' bgcolor='#999999' >Judet</th><th align='center' valign='top' width='100' bgcolor='#999999'>Cod Postal</th></tr>";
//And we display the results
while($result = mysql_fetch_array( $data ))
{
echo "<tr ><td class='blog2'>";
echo $result['localitate'];
echo "</td><td class='blog2'>";
echo $result['strada'];
echo "</td><td class='blog2'>";
echo $result['judet'];
echo "<td class='blog2' >";
echo $result['cp'];
echo "</td></tr>";
}
echo "</table>";
//This counts the number or results - and if there wasn't any it gives them a little message explaining that
$anymatches=mysql_num_rows($data);
if ($_POST['anymatches'] == 0)
{
echo "Sorry, but we can not find an entry to match your query<br><br>";
}
//And we remind them what they searched for
echo "<b>Ai cautat Codul Postal pentru:</b> " .$_POST['find'];
}
?>