search for a smilie

Started on the old forum in April 2010 · view the original in the archive · old links redirect here

3 replies · 448 views · started 16 years ago · 2 min read

2 participants
nclemale36 Lead · 537 posts #1

ok guys .i have used search nickname code here and eddited a few table names etc .to be able to search for a smilie. at the moment its displaying the first 5 in the database . dont matter wot i tyoe in search box.

i know its very rough and prob half the stuff in there dont need to be.

but wot i want is to be able to enter say a word in the search box and it brings up a list of smile images and the code to use them on site that relates to the word that was entered.

i had it working the search part of it but the next page prev page was giving me errors and i kinda messed it all up tryin to fix lol .

///////////////////////////////////////search for smilies
else if($action=="searchsm")

{

    addonline(getuid_sid($sid),"smilies search","");

    echo "<head>";

    echo "<title>Search</title>";

    echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";

    echo "</head>";

    echo "<body>";

    echo "<p>";

    echo "<form action=\"smiliesearch.php?action=find&sid=$sid\" method=\"post\">";

    echo "Nickname: <input name=\"stext\" maxlength=\"15\"/><br/>";

    echo "Order: <select name=\"cat\">";

    echo "<option value=\"1\">Member Name</option>";

    echo "<option value=\"2\">Last Active</option>";

    echo "<option value=\"3\">Join Date</option>";

    echo "</select><br/>";

    echo "<input type=\"Submit\" name=\"send\" value=\"Find It\"></form>";

    echo "</p>";

  echo "<p align=\"center\">";

  echo "<b>9 </b><a accesskey=\"9\" href=\"index.php?action=search&sid=$sid\"><img src=\"../phpThumb/phpThumb.php?src=../images/search.gif\" alt=\"\"/>Search Menu</a><br/>";

  echo "<b>0 </b><a accesskey=\"0\" href=\"index.php?action=main&sid=$sid\"><img src=\"../phpThumb/phpThumb.php?src=../images/home.gif\" alt=\"\"/>Home</a>";  echo "</p></body>";

  echo "</p></body>";

}//////////////////////////////////////////

else if($action=="find")

{

  $stext = $_POST["stext"];
  $scode = $_POST["scode"];
  $sin = $_POST["sin"];

  $cat = $_POST["cat"];

    addonline(getuid_sid($sid),"smilie search","");

    echo "<head>";

    echo "<title>Search</title>";

    echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";

    echo "</head>";

    echo "<body>";

    echo "<p>";

    

        if(trim($stext)=="")

        {

            echo "<br/>Failed to search for club";

        }else{

          //begin search

          if($page=="" || $page<1)$page=1;

          

            $where_table = "dave_smilies";

            $cond = "scode";

            $select_fields = "id, scode, cat";

            if($cat=="1")

            {

              $ord_fields = "name";

            }else if($cat=="2"){

                $ord_fields = "lastact DESC";

            }else if($cat=="3"){

                $ord_fields = "regdate";

            }

          

          $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ".$where_table." WHERE ".$cond." LIKE '%".$stext."%'"));

          $num_items = $noi[0];

          $items_per_page = 10;

          $num_pages = ceil($num_items/$items_per_page);

    if(($page>$num_pages)&&$page!=1)$page= $num_pages;

    $limit_start = ($page-1)*$items_per_page;

    $sql = "SELECT ".$select_fields." FROM ".$where_table." WHERE ".$cond." LIKE '%".$stext."%' ORDER BY scode LIMIT $limit_start, $items_per_page";

          $items = mysql_query($sql);

          while($item=mysql_fetch_array($items))

          {

              //$tlink = "<a href=\"index.php?action=viewuser&sid=$sid&who=$item[0]\">".htmlspecialchars($item[1])."</a><br/>";
              // echo  $tlink;
               echo parsepm ($item[1], $sid);
               echo "$item[1]<br/>";

          }

          echo "<p align=\"center\">";

          if($page>1)

    {

      $ppage = $page-1;

        $rets = "<form action=\"search.php?action=$action&sid=$sid&page=$ppage\" method=\"post\">";

      $rets .= "<input type=\"hidden\" name=\"stext\" value=\"$stext\"/>";

      $rets .= "<input type=\"hidden\" name=\"sin\" value=\"$sin\"/>";

      $rets .= "<input type=\"hidden\" name=\"sor\" value=\"$sor\"/>";

        $rets .= "<input type=\"Submit\" name=\"Prev\" value=\"Prev\"></form>";

        echo $rets;

    }

    if($page<$num_pages)

    {

      $npage = $page+1;

        $rets = "<form action=\"smiliesearch.php?action=find&sid=$sid&page=$npage\" method=\"post\">";

      $rets .= "<input type=\"hidden\" name=\"stext\" value=\"$stext\"/>";

      $rets .= "<input type=\"hidden\" name=\"sin\" value=\"$sin\"/>";

      $rets .= "<input type=\"hidden\" name=\"sor\" value=\"$sor\"/>";

        $rets .= "<input type=\"Submit\" name=\"Next\" value=\"Next\"></form>";

        echo $rets;

    }

    echo "<br/>$page/$num_pages<br/>";

    if($num_pages>2)

    {

        $rets = "<form action=\"smiliesearch.php?action=find&sid=$sid&page=$(pg)\" method=\"post\">";

        $rets .= "<input name=\"pg\" style=\"-wap-input-format: '*N'\" size=\"3\"/>";

      $rets .= "<input type=\"hidden\" name=\"stext\" value=\"$stext\"/>";

      $rets .= "<input type=\"hidden\" name=\"sin\" value=\"$sin\"/>";

      $rets .= "<input type=\"hidden\" name=\"sor\" value=\"$sor\"/>";

        $rets .= "<input type=\"Submit\" name=\"Send\" value=\"Go To Page\"></form>";

        echo $rets;

    }

    echo "</p>";

        }

    

echo "</p>";

  echo "<p align=\"center\">";

  echo "<b>9 </b><a accesskey=\"9\" href=\"index.php?action=search&sid=$sid\"><img src=\"../phpThumb/phpThumb.php?src=../images/search.gif\" alt=\"\"/>Search Menu</a><br/>";

  echo "<b>0 </b><a accesskey=\"0\" href=\"index.php?action=main&sid=$sid\"><img src=\"../phpThumb/phpThumb.php?src=../images/home.gif\" alt=\"\"/>Home</a>";

  echo "</p></body>";

}

cracked it lol . .just needed some food for my brain. just need to sort the catorgories out .

Themaster Junior · 14 posts #2
 boxstart("search");
  $thmname=$theme["theme"];
  $them=explode("_",$thmname);
  $them2=$them[0];
  if($them2=="Custom")
  	{
	include("custom_theme.inc.php");
	}else{
  echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
	} 
    echo "</head>";
    echo "<body>";
    echo "<p>";
    echo "<form action=\"smilsearch.php?action=smbr&sid=$sid\" method=\"post\">";
    echo "Smilie: <input name=\"stext\" maxlength=\"15\"/><br/>";
    
    echo "<input type=\"Submit\" name=\"send\" value=\"Find It\"></form>";
    echo "</p>";
  echo "<p align=\"center\">";
 // echo "<b>9 </b><a accesskey=\"9\" href=\"index.php?action=search&sid=$sid\"><img src=\"../images/search.gif\" alt=\"\"/>Search Menu</a><br/>";
 // echo "<b>0 </b><a accesskey=\"0\" href=\"index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";  echo "</p></body>";
  echo "</p></body>";

	$stext = $_POST["stext"];
  $sin = $_POST["sin"];
  //$sor = $_POST["sor"];
$sor = 1;
    addonline(getuid_sid($sid),"Smilie search","");

  $thmname=$theme["theme"];
  $them=explode("_",$thmname);
  $them2=$them[0];
  if($them2=="Custom")
  	{
	include("custom_theme.inc.php");
	}else{
  echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
	} 
    echo "</head>";
    echo "<body>";
    echo "<p>";

    
        if(trim($stext)=="")
        {
            echo "<br/>Please enter search term";
        }else{
          //begin search
          if($page=="" || $page<1)$page=1;
          
            $where_table = "ibwf_smilies";
            $cond = "scode";
            $select_fields = "id, scode, imgsrc";
            if($sor=="1")
            {
              $ord_fields = "scode";
            }else if($sor=="2"){
                $ord_fields = "lastact DESC";
            }else if($sor=="3"){
                $ord_fields = "regdate";
            }
          
          $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ".$where_table." WHERE ".$cond." LIKE '%".$stext."%'"));
          $num_items = $noi[0];
          $items_per_page = 10;
          $num_pages = ceil($num_items/$items_per_page);
    if(($page>$num_pages)&&$page!=1)$page= $num_pages;
    $limit_start = ($page-1)*$items_per_page;

    $sql = "SELECT ".$select_fields." FROM ".$where_table." WHERE ".$cond." LIKE '%".$stext."%' ORDER BY ".$ord_fields." LIMIT $limit_start, $items_per_page";
          $items = mysql_query($sql);
          while($item=mysql_fetch_array($items))
          {
  echo "<img src=\"$item[2]\" alt=\"$item[1]\"/>$item[1]<br/>";            
 //$tlink = "<a href=\"index.php?action=viewuser&sid=$sid&who=$item[0]\">".htmlspecialchars($item[1])."</a><br/>";

               // echo  $item[1];

          }
          echo "<p align=\"center\">";
		  if($page>1)
    {
      $ppage = $page-1;
        $rets = "<form action=\"smilsearch.php?action=$action&sid=$sid&page=$ppage\" method=\"post\">";
	  $rets .= "<input type=\"hidden\" name=\"stext\" value=\"$stext\"/>";
	  $rets .= "<input type=\"hidden\" name=\"sin\" value=\"$sin\"/>";
	  $rets .= "<input type=\"hidden\" name=\"sor\" value=\"$sor\"/>";
        $rets .= "<input type=\"Submit\" name=\"Prev\" value=\"Prev\"></form>";

        echo $rets;
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
        $rets = "<form action=\"smilsearch.php?action=$action&sid=$sid&page=$npage\" method=\"post\">";
	  $rets .= "<input type=\"hidden\" name=\"stext\" value=\"$stext\"/>";
	  $rets .= "<input type=\"hidden\" name=\"sin\" value=\"$sin\"/>";
	  $rets .= "<input type=\"hidden\" name=\"sor\" value=\"$sor\"/>";
        $rets .= "<input type=\"Submit\" name=\"Next\" value=\"Next\"></form>";

        echo $rets;
    }
    echo "<br/>$page/$num_pages<br/>";
    if($num_pages>2)
    {
        $rets = "<form action=\"smilsearch.php?action=$action&sid=$sid&page=$(pg)\" method=\"post\">";
        $rets .= "<input name=\"pg\" style=\"-wap-input-format: '*N'\" size=\"3\"/>";
	  $rets .= "<input type=\"hidden\" name=\"stext\" value=\"$stext\"/>";
	  $rets .= "<input type=\"hidden\" name=\"sin\" value=\"$sin\"/>";
	  $rets .= "<input type=\"hidden\" name=\"sor\" value=\"$sor\"/>";
        $rets .= "<input type=\"Submit\" name=\"Send\" value=\"Go To Page\"></form>";

        echo $rets;
    }
    echo "</p>";
        }
    
echo "</p>";
  echo "<p align=\"center\">";
  //echo "<b>9 </b><a accesskey=\"9\" href=\"index.php?action=search&sid=$sid\"><img src=\"../images/search.gif\" alt=\"\"/>Search Menu</a><br/>";
//  echo "<b>0 </b><a accesskey=\"0\" href=\"index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
  echo "</p></body></html>";
boxend();
getfooter($sid);
exit();
  
?>

That's what i did for mobile zonez v2 hope it helps dave

Themaster Junior · 14 posts #4

lol no worries i dint read the post properly until after i posted it and cba to delete it...haha will do for anyone usin mob zonez though i guess so not a total waste of time 😛

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close