4 Replies - 183 Views - Last Post: 29 January 2014 - 09:57 AM Rate Topic: -----

#1 Hrbook  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 25-October 12

do a search option on the website for businesses

Posted 27 January 2014 - 02:55 PM

here and now I am working on making a search option on the website for businesses.

It is such that there will not be some errors on the page.

The problem is that there will be no forward by some companies on the side.

Want to have done such firms pages appears.

if(isset($_POST["sognu"]))
    {
        if($stmt = $this->mysqli->prepare('SELECT navn, link, img, omrade FROM ordblindtest WHERE omrade = ?  OR sogord = ?'))
        {
            $stmt->bind_param('ss', $omrade, $sogord);
            $omrade = $_POST["sogord"];
            $sogord = $_POST["sogord"];
            $stmt->execute();
            $stmt->bind_result($navn, $link, $img, $omrade);
            $count = $stmt->num_rows;
            while($stmt->fetch())
            {
                if($count > 0)
                {
                    echo "<div id=\"error\">Error on: " . $_POST["sogord"] . "..</div>";    
                }
                else
                {
                    echo "klik";
                }
            }
            $stmt->close();
        }
        else
        {
            echo 'Der opstod en fejl i erklæringen: ' . $this->mysqli->error;
        }
    }



<form action="#" method="POST">
    <input type="text" name="sogord" maxlength="590" id="sogbartekst" placeholder="Søg efter: Sjælland eller Jylland eller samt Fyn.. eller VUC Hillerød">
    <input type="submit" name="sognu" value="Søg nu" id="sogbarklik">
    </form>



My question is this, how can it be that there does not appear right away

Is This A Good Question/Topic? 0
  • +

Replies To: do a search option on the website for businesses

#2 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 369
  • View blog
  • Posts: 1,323
  • Joined: 15-January 14

Re: do a search option on the website for businesses

Posted 27 January 2014 - 03:01 PM

It's a little difficult to understand your English, but one problem I see is that you're trying to bind a variable before you've set it:

            $stmt->bind_param('ss', $omrade, $sogord);
            $omrade = $_POST["sogord"];
            $sogord = $_POST["sogord"];

Was This Post Helpful? 1
  • +
  • -

#3 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3371
  • View blog
  • Posts: 11,420
  • Joined: 12-December 12

Re: do a search option on the website for businesses

Posted 27 January 2014 - 03:07 PM

Another issue is that you are not (or won't be) outputting anything from the database, simply echoing $_POST["sogord"] repeatedly.

Also you don't need to check $count each time in the loop, you should check it once, before entering the loop.
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3530
  • View blog
  • Posts: 10,174
  • Joined: 08-June 10

Re: do a search option on the website for businesses

Posted 29 January 2014 - 01:02 AM

View PostArtificialSoldier, on 27 January 2014 - 11:01 PM, said:

one problem I see is that you're trying to bind a variable before you've set it

that’s not a problem. whether the variable contains something useful at binding time doesn’t matter because the variable’s value is requested by MySQLi (resp.PDO) when the statement is executed.

that would be a different matter when using PDO’s bindValue() method.
Was This Post Helpful? 0
  • +
  • -

#5 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 369
  • View blog
  • Posts: 1,323
  • Joined: 15-January 14

Re: do a search option on the website for businesses

Posted 29 January 2014 - 09:57 AM

Ah right, it looks like those are passed by reference.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1