0

Could u help me with code ? I want to add t that script an option like : when I type ex. data/pag , then script replaces data with key from mysql db and echo it like: replaced/pag . I mean it only replaces text before first and single "/".

Code :

 $wyszukaj=$_GET['wyszukaj'];

 $min_wartosc = 1;

 if(strlen($wyszukaj)>=$min_wartosc)
 {
     $wyszukaj =htmlspecialchars($wyszukaj);

     $zapytanie=$baza->prepare("SELECT * FROM wyszukiwarka WHERE nazwa LIKE :wyszukaj");

     $zapytanie->bindValue('wyszukaj', $_GET['wyszukaj'],PDO::PARAM_STR);
     $zapytanie->execute(array($wyszukaj));

     if($zapytanie->rowCount()>0)
     {
          while($wynik=$zapytanie->fetch())
         {
             echo $wynik['nazwa'] . "<br>";
              header('location:http://'.$wynik['login']);
         }
      }
           else
         {
              echo "brak <b> " . $wyszukaj . " </b> w bazie danych ...";
          }
     }
     else
     {
          echo "";
     }
5
  • 2
    your question is about a replacement of text in a string of text (containing a /). Then there is a lot of code, but where is the part the question is about? Commented Jul 16, 2017 at 20:57
  • I mean , I can't do this . Asking for help. I know that I have to add elseif but I don't know in which part and how to construct it. Commented Jul 16, 2017 at 21:17
  • Do you mean you will send wyszukaj=data/page to your php? You want data to be 'replaced' with something from the database? Commented Jul 16, 2017 at 21:41
  • 1
    Possible duplicate of Replace any string before "/", PHP Commented Jul 16, 2017 at 21:43
  • Yep , I mean when I type to input text : "sometext/second" then script checks if there is sometext in db , and then replace id so prints : replaced/second as echo , when not id db then just other echo*. It must check text only for first "/" , It other echo* when it has sometext/sometext/second. Commented Jul 17, 2017 at 9:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.