Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $yhteys = mysql_connect("localhost", "root", "")
- or die("Yhteys ei onnistunut. ".mysql_error());
- mysql_select_db("testikanta2",$yhteys)
- or die("Kantaa ei löytynyt. ".mysql_error());
- $tulos = mysql_query("SELECT * FROM firma", $yhteys);
- while($tulosrivi = mysql_fetch_array($tulos)){
- echo $tulosrivi['nimi']." ".$tulosrivi['osoite']."<br>";
- }
- echo "<br>-----------<br>";
- ?>
- <?php
- $firmahaku = $_POST["firma"];
- if (!isset($_POST['nappi'])) { // if page is not submitted to itself echo the form
- ?>
- <form method="post" action="<?php echo $PHP_SELF;?>">
- <p>
- <label for="nimi">Firma: </label>
- <input id="nimi" type="text" name="firma" size="50" />
- </p>
- <p>
- <input type="submit" name="nappi" value="Etsi" />
- </p>
- </form>
- <?php
- } else {
- $haku = mysql_query("SELECT * FROM firma WHERE nimi like '$firmahaku'", $yhteys);
- echo "Haettu firma<br>";
- while($tulosrivi = mysql_fetch_array($haku)){
- echo $tulosrivi['nimi']." ".$tulosrivi['osoite']."<br>";
- }
- echo "<br>-----------<br>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement