How to receive data from my database in a webpage format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • InksEtc
    New Member
    • Sep 2010
    • 4

    How to receive data from my database in a webpage format

    ...I don't know if this is the correct or more simplified style of being able to retrieve data from my database (phpmyadmin) and putting it on the browswer. I need assistance to do that.

    http://inks-etc.org/SearchEngine/thinker2010.html (or php) can tell you where things are going wrong. I have 9 plus reference books on PHP & MYSQL that are give me direction but I am placing my instruction in a "while loop" that are placing me in a viscous cycle. I need help...


    Code:
    <?php
    include ("thinker2010.html");
    
    
    //get data
    $button = $_GET['submit'];
    $search = $_GET['search_ink'];
    
    //if a customer places a keyword into the thinker then...go to the next phase
    if($search!="")
    {
         /* explode the keywords; the 1st term "" is the way to explode  
    and the 2nd term is what your exploding; the $search is the $GET*/
         $search_exploded = explode (" " , $search);
    
    
         // looping
         foreach ($search_exploded as $search_each);
         {
          $x++;
         // if ... this is the 1st time we are looping
          if ($x==1)
         /* the % are wildcards that stand in for any other char. before  
    	 or afterthe word --- construct query => x++ shows how many time the loop has been thru
         $construct .= is the same as $construct = $construct . "$xyz"*/
           $construct .= "keyword LIKE '%$search_each%'";
         /* else...allow more keywords that are looped by the con't phrase  
    OR keywords LIKE that cont over and over again ~ loop  */
          else
           $construct .=  "OR keyword LIKE '%$search_each%'";
         }
    
       /*echo out with the value construct - this is a $query --- FROM is the table WHERE is the column---"SELECT * FROM The_Thinker WHERE $construct";*/
       $construct =  "SELECT * FROM code WHERE MATCH(keyword, url) AGAINST ('$construct')";
       //this is a $result
       $run = mysqli_query(" ", $construct);
       $foundnum = mysqli_num_rows($run);
        if ($foundnum==0)
         echo "Jason No results found.";
        else
        {
         echo "$foundnum results found!";
    
         while ($runrows = mysqli_fetch_assoc($run));
    
          {
           //get data
           $keyword = $runrows ['keyword'];
           $desc = $runrows ['Description'];
           $url = $runrows ['url'];
           echo "<b>$keyword</b><br>
            $desc<br><a href='$url'>$url</a><p>";
          }
    
        }
     
      echo $construct;
      die ();
    }
    	else
            {
               echo "Kraft No result found.";
            }
    ?>
    Last edited by Niheel; Sep 25 '10, 06:36 AM. Reason: added code tags
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    You need to connect to MySQL before trying to send it queries. See the examples in the manual entry for mysqli_query.

    Comment

    Working...