Menu
Is free
check in
home  /  Tips / Birth to man Search Item PHP I. Multi-level menu on PHP and MYSQL

Birth of a man Search Item PHP I. Multi-level menu on PHP and MYSQL

By Ibrahim Diallo.

Published Jul 2 2014 ~ 16 Minutes Read

Search IS An Important Feature On a Website. WHEN MY FEW READERS WANT TO LOOK FOR A PARTICULAR PASSAGE ON MY BLOG, THE SEARCH BOX. IT Used to Be Powered by Google Search, But I Have Since Then Changed It To My Own Home-Brewed Version Not Because I Can Do Better But Because It Was An Interesting Challenge.

If You are in a Hurry and Just Want Your Site to Be SearchBle, Well Do What I Did Before, USE Google.

// in search.php file $ term \u003d isset ($ _ get ["Query"])? $ _ Get ["Query"]: ""; $ TERM \u003d URLENCODE ($ Term); $ WebSite \u003d Urlencode ("www.yourwebsite.com"); $ redirect \u003d "https://www.google.com/search?q\u003dsite%3A($website )+($term)"; Header ("Location: $ Redirect"); exit;

What It Does Is Pretty Simple. Get The Term Passed by The User, and Forward It To Google Search Page. Limit The Search Result to Our Current Domain Using The Site: Keyword in The Search Query. All You Pages That Are Indexed by Google Will Be Available Through Search Now. If you do Want to handle Your Search in House However, Then Keep Reading.

HomeMade Search Solution

Before We Go Any Further, Try Using The Search Box On This Blog. IT Use The Same Process That I Will Describe Below. IF You Feel That This Is What You Want Then Please Continue Reading.

This Solution Is Catered to Small Websites. I make Use of Like with Wild Cards on Both Ends, Meaning Your Search Cannot Be Indexed. This Means The Solution Will Work Fine for Your Blog Or Personal WebSite That DOESN "T Contain Tons of Data. Port It to a Bigger Website and It Might Become Very Slow. MySQL OFFERS FULL TEXT SEARCH IS NOT WHAT WE ARE DOING HERE.

Note: If You Have 5000 Blog Posts You are Still Fine. .

We Will Take The Structure of this Blog As a Reference. Each Blog Post Has:

  • A title p_title
  • A URL P_URL
  • A Summary P_summary.
  • A POST CONTENT P_CONTENTENT
  • And Catergories Category.tagname.

Forume Field That Matches with Our Search Term, We Will Give IT A SCORE. The Score Will Be Based On The Importance Of The Match:

// The EXACT TERM MATCHES IS FOUND IN THE TITLE $ SCOREFULLTITLE \u003d 6; // Match The Title in Part $ ScoreTitleKeyword \u003d 5; // The EXACT TERM MATCHES IS FOUND IN THE SUMMARY $ SCOREFULLSMARY \u003d 5; // Match The Summary in Part $ ScoresummaryKeyword \u003d 4; // The EXACT TERM MATCHES IS FOUND IN THE CONTENT $ SCOREFULLDOCUMENT \u003d 4; // Match The Document in Part $ ScoredocumentKeyword \u003d 3; // Matches a Category $ ScorecategoryKeyword \u003d 2; // Matches The URL $ ScoreURLKEYWORD \u003d 1;

Before Weit Started, There Are A Few Words That Don't Contribute Much To A Search That Should Be Removed. Example "IN", "IT", "A", "The", "of" .... We Will Filter Those Out and Feel Free to Add Any Word You Think Is Irrelevant. Another Thing Is, We Want to Limit The Length of Our Query. WE DON "T WANT A User to Write A Novel In The Search Field and Crash Our MySQL Server.

// Remove Unnecessary Words from The Search Term and Return Them As An Array Function FiltersearchKeys ($ Query) ($ Query \u003d Trim (Preg_replace ("/ (\\ s +) + /", "", $ Query)); $ WORDS \u003d Array (); // Expand This List With Your Words. $ List \u003d Array ("In", "IT", "A", "The", "of", "or", "i", "you", "HE", "ME", "US", "THEY", "SHE", "TO", "BUT", "THAT", "THIS", "THOSE", "THEN"); $ c \u003d 0; Foreach (Explode (", $ Query) AS $ Key) (if (in_array ($ Key, $ List)) (Continue;) $ Words \u003d $ Key; if ($ C\u003e \u003d 15) (Break;) $ C ++ ;) Return $ Words;) // Limit Words Number of Characters Function Limitchars ($ Query, $ Limit \u003d 200) (RETURN Substr ($ Query, 0, $ Limit);)

Our Helper Functions Can Now Limit Character Count and Filter Useless Words. The Way Will Implement Our Algorithm IS by Giving a Score Every Time We Find A Match. We Will Match Words Using The If Statement and Accumulate Points AS We Match More Words. AT The End We Can Use That Score to Sort Our Results

Note: I Will Not Be Showing How to Connect to MySQL Database. If You are Having Problems to Efficiently Connect to the Database I Recommend Reading This.

Let "S Give Our Function A Structure First. Note I Left Placeholders SO WE CAN IMPLEMENT SECTIONS SEPARETELY.

Function Search ($ Query) ($ Query \u003d Trim ($ Query); if (MB_STRLEN ($ Query) \u003d\u003d\u003d 0) (// No Need for Empty Search Right? Return False;) $ Query \u003d Limitchars ($ Query) ; // Weighing scores $ scoreFullTitle \u003d 6; $ scoreTitleKeyword \u003d 5; $ scoreFullSummary \u003d 5; $ scoreSummaryKeyword \u003d 4; $ scoreFullDocument \u003d 4; $ scoreDocumentKeyword \u003d 3; $ scoreCategoryKeyword \u003d 2; $ scoreUrlKeyword \u003d 1; $ keywords \u003d filterSearchKeys ( $ Query); $ escquery \u003d db :: escape ($ Query); // See Note Above to Get DB Object $ TitleSQL \u003d Array (); $ sumsql \u003d array (); $ docsql \u003d array (); $ CategorySQL \u003d Array (); $ URLSQL \u003d Array (); / ** Matching Full Occurrences Place Holder ** / ** Matching Keywords Place Holder ** / $ SQL \u003d "Select P.P_ID, P.P_TITLE, P.P_DATE_PUBLISHED, P. P_URL, P.P_SUMMARY, P.P_CONTENT, P.Thumbnail, (- Title Score .implode ("+", $ TitleSQL). ") + (- Summary .implode (" + ", $ SUMSQL) . ") + (- Document" .implode ("+", $ docsql). ") + (- Tag / Category" .implode ("+", $ CategorySQL). ") + (- URL". implode (" + ", $ URLSQL).")) AS RELEVANCE FROM POST P WHERE P.Status \u003d "Published" Having Relevance\u003e

In The Query, All Scores Will Be Summed Up As The Relevance Variable and We Can Use IT to Sort The Results.

Matching Full Occurrences.

We make sure we have some keywords first then Add Our Query.

If (Count ($ Keywords)\u003e 1) ($ TitleSQL \u003d "If (P_title Like"%. $ Escquery. "%", ($ ScoreFullTle), 0) "; $ sumsql \u003d" If (p_summary like "%" . $ escquery. "%", ($ scorefullsummary), 0) "; $ docsql \u003d" if (P_CONTENT LIKE "%." $ escquery. "%", ($ scorefulldocument), 0) ";)

Those Are The Matches with Higher Score. If The Search Term Matches An Article That Contains These, They Will Have Higher Chancese of Appearing On Top.

Matching Keywords Occurrences.

WE LOOP THROUGH ALL KEYWORDS AND CHECK IF THEY MATCH ANY OF THE FIELDS. For Category Match, Ised a sub-Query Since a Post Can Have Multiple Categories.

Foreach ($ keywords as $ Key) ($ titlesql \u003d "if (p_title like"% ". DB :: Escape ($ Key)."% ", ($ Scoretlekeyword), 0)"; $ sumsql \u003d "if (p_summary Like "%." DB :: Escape ($ Key). "%", ($ Scoresummarykeyword), 0) "; $ docsql \u003d" if (P_CONTENT LIKE "%." DB :: Escape ($ KEY). "% ", ($ ScoredocumentKeyword), 0)"; $ urlsql \u003d "if (P_URL LIKE"%. "DB :: Escape ($ Key)."% ", ($ scoreurlKeyword), 0)" $ CategorySQL \u003d "IF ((Select Count (Category.tag_id) from Category Join Post_category on post_category.tag_id \u003d Category.tag_id WHERE POST_CATEGORY.POST_ID \u003d p.post_id and category.name \u003d "" .db :: escape ($ Key). "" ")\u003e 0, ($ ScorecategoryKeyword), 0) ";)

Also As Pointed by A Commenter Below, We Have to Make Sure That These Variables Are Not Empty Arrays Or The Query Will Fail.

// Just Incase IT "S Empty, Add 0 if (empty ($ titlesQL)) ($ titlesql \u003d 0;) if (empty ($ sumsql)) ($ sumsql \u003d 0;) if (empty ($ docsql)) (EMPTY $ docsql \u003d 0;) if (empty ($ URLSQL)) ($ urlsql \u003d 0;) if (Empty ($ tagsql)) ($ tagsql \u003d 0;)

AT The End The Quers Are All Concatenated and Added Together to Determine The Relevance of the Post to the Search Term.

// Remove Unnecessary Words from The Search Term and Return Them As An Array Function FiltersearchKeys ($ Query) ($ Query \u003d Trim (Preg_replace ("/ (\\ s +) + /", "", $ Query)); $ WORDS \u003d Array (); // Expand This List With Your Words. $ List \u003d Array ("In", "IT", "A", "The", "of", "or", "i", "you", "HE", "ME", "US", "THEY", "SHE", "TO", "BUT", "THAT", "THIS", "THOSE", "THEN"); $ c \u003d 0; Foreach (Explode (", $ Query) AS $ Key) (if (in_array ($ Key, $ List)) (Continue;) $ Words \u003d $ Key; if ($ C\u003e \u003d 15) (Break;) $ C ++ ;) Return $ Words;) // Limit Words Number of Characters Function Limitchars ($ Query, $ Limit \u003d 200) (Return Substr ($ Query, 0, $ Limit);) Function Search ($ Query) ($ Query \u003d Trim ($ Query); if (MB_Strlen ($ Query) \u003d\u003d\u003d 0) (// No Need for Empty Search Right? Return False;) $ Query \u003d Limitchars ($ Query); // Weighting Scores $ ScoreFullTle \u003d 6; $ ScoreTitleKeyword \u003d 5; $ scorefullsummary \u003d 5; $ scoresummarykeyword \u003d 4; $ scorefulldocument \u003d 4; $ scoredocumentkeyword \u003d 3; $ scorecategorykeyword \u003d 2; $ scoreurlke yword \u003d 1; $ Keywords \u003d FiltersearchKeys ($ Query); $ escquery \u003d db :: escape ($ Query); // See Note Above to Get DB Object $ TitleSQL \u003d Array (); $ sumsql \u003d array (); $ docsql \u003d array (); $ CATEGORYSQL \u003d Array (); $ urlsql \u003d array (); / ** Matching Full Occurences ** / If (Count ($ Keywords)\u003e 1) ($ TitleSQL \u003d "If (P_title Like"%. "$ Escquery."% ", ($ Scorefulltle), 0)"; $ SUMSQL \u003d "If (p_summary like"%. "$ Escquery."% ", ($ scorefullsummary), 0)"; $ docsql \u003d "if (P_CONTENT LIKE"%. $ Escquery. "%", ($ scorefulldocument), 0) ";) / ** Matching keywords ** / foreach ($ keywords as $ key) ($ TitleSQL \u003d" if (p_title like "%". DB :: Escape ($ Key). "%", ($ ScoreTitleKeyword ), 0) "; $ sumsql \u003d" if (p_summary like "%". DB :: Escape ($ Key). "%", ($ ScoresumMaryKeyword), 0) "; $ docsql \u003d" if (p_content like "% ".Db :: escape ($ Key)."% ", ($ ScoredocumentKeyword), 0)"; $ URLSQL \u003d "if (P_URL LIKE"%. "DB :: Escape ($ Key)."% ", ( $ ScoreURLKEYWord), 0) "$ CategorySQL \u003d" if ((Select Count (Category.tag_id) from Category Join Post_category on post_category.tag_id \u003d Category.tag_id WHERE POST_CATEGORY.POST_ID \u003d p.post_id and category.name \u003d "". DB :: Escape ($ Key). "" ")\u003e 0, ($ scorecategorykeyword), 0)";) // Just Incase IT "S Empty, Add 0 if (Empty ($ TitleSQL)) ($ TitLesQL \u003d 0; ) if (Empty ($ Sumsql)) ($ sumsql \u003d 0; ) if (empty ($ docsql)) ($ docsql \u003d 0;) if (Empty ($ URLSQL)) ($ URLSQL \u003d 0;) if (empty ($ tagsql)) ($ tagsql \u003d 0;) $ sql \u003d " Select P.P_ID, P.P_TITLE, P.P_DATE_PUBLISHED, P.P_URL, P.P_SUMMARY, P.P_CONTENT, P.Thumbnail, ((- Title Score .implode ("+", $ TitleSQL). ") + (- Summary" .implode ("+", $ SUMSQL). ") + (- Document" .implode ("+", $ docsql). ") + (- Tag / Category" .implode ("+", $ categorySQL). ") + (- URL. RELEVANCE DESC, P.PAGE_VIEWS DESC LIMIT 25 "; $ Results \u003d DB :: Query ($ SQL); if (! $ Results) (Return False;) Return $ Results; )

NOW Your Search.php File Can Look Like This:

$ Term \u003d Isset ($ _ Get ["Query"])? $ _ get ["Query"]: ""; $ search_results \u003d search ($ Term); If (! $ search_results) (Echo "No Results"; exit;) // Print Page with Results Here.

We Created a Simple Search Algorithm That Can Handle a Fair Amount of Content. I Arbitrarily Chose The Score for Each Match, Feel Free to Tweak IT to Something That Works Best for You. AND THERE IS ALWAYS ROOM FOR IMPROVEMENT.

IT IS A Good Idea To Track The Search Term Coming from Your Users, This Way You Can See If Most Users Search for the Same Thing. IF There Is A Pattern, Then You Can Save Them a Trip and Just Cache The Results Using Memcached.

If you Want To See This Search Algorithm in Action, Go Ahead and Try Looking for an Article On The Search Box On Top of the Page. I Have Added Extra Features Like Returning The Part Where The Match Was Found in the Text. Feel Free To Add Features To Yours.

Did You Like this article? You can Subscribe to Read more Awesome Ones. .

On a Related Note, Here Are Some Interesting Articles.

If there is One Thing a Web Server Does Everyday IT ISS Connecting to the Database. I Have Been using PHP for Many Years Now, But If You Ask ME to Write A Script to Fetch Data from the Database i Couldn "T Do it Without Going Back to the Ultimate PHP Manual to Find a Few Examples First.

A FEW MONTHS AGO I UPDATED MY PHP VERSION. PHP 5.4 to 5.5. I NEVER HAD ANY PROBLEMS UPDATING PHP BEFORE. I Follow Its Development Closely and Try to Remove My Deprecated Functions Long Before They Are Officially Removed. But This Time I Was Caught Off Guard. IT SILENTLY BROKE PART OF MY WebSite for the Silliest Reason.

Comments (45)

Zarayel. Aug 12 2015:

Ian Mustafa. SEP 26 2015:

Rob SEP 29 2015:

adeem. Feb 11 2016:

Ivan Venediktov. Apr 9 2016.

Updated on April 30, 2016

I "M GOING TO SHOW YOU HOW TO CREATE SIMPLE SEARCH USING PHP AND MYSQL. YOU" LL LEARN:

  • How to Use Get and POST METHOD.s.
  • Connect to Database.
  • Communicate with Database.
  • Find Matching Database Entries Wort Given Word Or Phrase
  • Display Results.

Preparation

You Shald Have Apache, MySQL and PHP Installed and Running Of Course (You Can Use for Different Platforms or Wamp for windows, Mamp for Mac) Or a Web Server / Hosting That Supports PHP and MySQL Databases.

Let "S CREATE DATABASE, Table and Fill It With Some Entries We Can Use for Search:

  • Go to PHPMYAdmin, if you have server on your computer you can access it at http: // localhost / phpmyadmin /
  • CREATE DATABASE, I CALLED MINE TUTORIAL_SEARCH
  • CREATE TABLE I Used 3 Fields, I Called Mine Articles.
  • Configuration for 1st field. Name: ID, Type: Int, Check AUTO_INCREMENT, INDEX: Primary

Int Means IT "S Integer
Auto_Increment Means That New Entries Will Have Other (Higher) Number Than Previous
Index: Primary Means That It "S Unique Key Used to Identify Row

  • 2nd Field: Name: Title, Type: Varchar, Length: 225

Varchar Means It String Of Text, Maximum 225 Characters (IT IS Required to Specify Maximum Length), Use It for Titles, Names, Addresses
length Means It Can "T BE LONGER THAN 225 CHARACTSERS (YOU CAN SET IT TO LOWER NUMBER IF YOU WANT)

  • 3rd Field: Name: Text, Type: text

Text Means It "S Long String, IT" S Not Necessary to Specify Length, USE it for Long Text.

  • Fill The Table with some Random Articles WebSites, For Example: CNN, BBC, etc.). Click Insert On The Top Menu and Copy Text to a Specific Fields. LEAVE "ID" Field Empty. INSERT AT Least Three.

IT SHOULD Look Something Like This:

  • Create A Folder In Your Server Directory and Two Files: index.php and search.php (Actually We Can Do All This Just With One File, But Let Let "S Use Two, It Will Be Easier)
  • Fill Them with Default Html Markup, DoCtype, Head, etc.

Search.

  • Create A Form With Search Field and Submit Button in Index.php, You Can Use Get Or Post Method, Set Action to search.php. I Use "Query" as name for text field

Get - Means Your Information Will Be Stored in URL (http: //localhost/tutorial_search/search.php? Query \u003d yourQuery.)
Post - Means Your Information Won "T Be Displayed IT IS Used for Passwords, Private Information, Much More Secure Than Get

OK, Let "S Get Started With PHP.

  • Open Search.php.
  • Start PHP ()
  • Connect to a Database (Read Comments in Following Code)

< to > $ Query \u003d mysql_real_escape_string ($ Query); // Makes Sure Nobody Use SQL Injection $ RAW_Results \u003d MySQL_Query ("Select * from Articles Where (` Title` Like "%." $ Query. "%") OR (`Text` Like"%. $ Query. "% ")") OR DIE (MYSQL_ERROR ()); // * Means That It Selects All Fields, You Can Also Write: `ID`,` title`, `text` // Articles Is The Name of Our Table //"% $ Query% "IS What We" Re Looking for ,% Means Anything, for example if $ Query Is Hello // IT Will Match "Hello", "Hello Man", "Gogohello", If You Want Exact Match USE `Title` \u003d" $ Query "// or if you want To Match Just Full Word So "Gogohello" is out Use "% $ Query%" ... Or ... "$ Query%" ... Or ... "% $ Query" if (mysql_num_rows ($ raw_results)\u003e

"$ results [" Title "]."

". $ results [" Text "]."

"// Posts Results Gotten from Database (Title and Text) You can also show ID ($ results [ID"])))) ELSE (// if there is no Matching Rows Do Following Echo "No Results";)) ELSE (// If Query Length Is Less Than Minimum Echo "Minimum Length Is". $ min_length;)?\u003e

Done!

Now it works. Try Different Words, Variations, Editing Code, Experiment. I "M adding Full Code of Both Files in Case You Think You" Ve Missed Something. Feel Free to Ask Questions or Ask for Tutorials.

index.php.

Search.

search.php.

Search Results. \u003d $ min_length) (// If Query Length Is More or Equal Minimum Length then $ Query \u003d HTMLSPECIALCHARS ($ Query); // Changes Characters Used in Html To Their Equivales, for example:< to > $ Query \u003d mysql_real_escape_string ($ Query); // Makes Sure Nobody Use SQL Injection $ RAW_Results \u003d MySQL_Query ("Select * from Articles Where (` Title` Like "%." $ Query. "%") OR (`Text` Like"%. $ Query. "% ")") OR DIE (MYSQL_ERROR ()); // * Means That It Selects All Fields, You Can Also Write: `ID`,` title`, `text` // Articles Is The Name of Our Table //"% $ Query% "IS What We" Re Looking for ,% Means Anything, for example if $ Query Is Hello // IT Will Match "Hello", "Hello Man", "Gogohello", If You Want Exact Match USE `Title` \u003d" $ Query "// or if you want To Match Just Full Word So "Gogohello" is out Use "% $ Query%" ... Or ... "$ Query%" ... Or ... "% $ Query" if (mysql_num_rows ($ raw_results)\u003e 0) (// If One Or more Rows Are Returned Do Following While ($ results \u003d mysql_fetch_array ($ raw_results)) (// $ Results \u003d MySQL_FETCH_ARRAY ($ RAW_Results) Puts Data from Database Into Array, While IT "S Valid It Does The Loop Echo "

"$ results [" Title "]."

". $ results [" Text "]."

"// Posts Results Gotten from Database (Title and Text) You can also show ID ($ results [ID"])))) ELSE (// if there is no Matching Rows Do Following Echo "No Results";)) ELSE (// If Query Length Is Less Than Minimum Echo "Minimum Length Is". $ min_length;)?\u003e

In this article, I will show how to create multi-level menu on PHP and MYSQL. Of course, the options for its creation can be invented a lot, but judging by the number of your questions on this topic, you need an example. And I will give it in this article. I immediately note that this article makes sense only for those who know Php. and knows how to work with Mysql. All the rest first need to go through this one, or read some books on Php and mysql.

To begin with, create a table in the database with the following fields:

  • id - unique identificator.
  • title - Anchor links in the menu.
  • lINK. - The address to which the menu item will be.
  • parent_id - Parental ID. If there is no parent item, then NULL will be here (or you can put 0 more).

The table was sorted out, now it's time Php-code. Full PHP code Located below:

$ mysqli \u003d new mysqli ("Localhost", "root", "", "db"); // Connect to the database
$ result_set \u003d $ Mysqli-\u003e Query ("Select * from` Menu` "); // We make a sample of all entries from the table with the menu
$ items \u003d array (); // array for menu items
while (($ row \u003d $ result_set-\u003e fetch_assoc ())! \u003d false) $ items [$ row [«ID]] \u003d $ ROW; // Fill the array of the sample from the database
$ Childrens \u003d Array (); // Array for conformity to their parental elements
Foreach ($ Items As $ Item) (
if ($ item ["parent_id"]) $ childrens [$ item [id "]] \u003d $ item [" parent_id "]; // Fill an array
}
Function PrintItem ($ Item, $ Items, $ Childrens) (
/ * Display the menu item * /
Echo "

  • ";
    Echo ". $ item [" Title "]." ";
    $ ul \u003d false; // Did the child elements been displayed?
    While (True) (
    / * Infinite loop in which we are looking for all child elements * /
    $ Key \u003d Array_Search ($ item [ID "], $ Childrens); // We are looking for a child element
    if (! $ Key) (
    / * Daughter items not found * /
    if ($ ul) echo ""; // If child elements are output, then close the list
    Break; // come out of the cycle
    }
    Unset ($ Childrens [$ Key]); // Delete the found element (so that it does not appear again)
    if (! $ ul) (
    Echo "
      "; // We begin the internal list if the child elements have not yet been
      $ Ul \u003d True; // Set the flag
      }
      Echo Printitem ($ items [$ Key], $ items, $ childrens); // Recursively display all the child elements
      }
      Echo "";
      }
      ?>

      This code is fully worker, however, you must understand that no one writes (in particular, the conclusion through echo. HTML tagov). And your task is to take the algorithm from this code, but not the code itself. And then this algorithm is connected to your engine. I tried to carefully comment on the output code multi-level menu on PHP and MYSQLBut, of course, it is not the most transparent and requires good initial knowledge. If you still know Php and mysqlthen at first I strongly recommend going through this

      Men's birthday script requires special attention. After all, the strong floor is usually rigoring assesses the format of the holiday. Our vast experience of holidays allows you to find the perfect scenario for the birthday depending on the age, the character warehouse and the interests of the birthday officer. We offer for example the scenario of the birthday men who are most popular with our customers:

      Leading pronunciation toast for the birthday room And finishes him with the words:

      Champagne in glasses pour
      And they drink everything together to the bottom!
      For youth your toast we raise,
      And youth is not alone!

      The first circle is finished, a new one began,
      You joined the second youth.
      Male prominent, strong and healthy,
      You are full of fresh ideas and strength.

      Also stay energetic
      After all, you didn't work in vain so many years!
      So be funny, pretty,
      And let the fate keep you from the troubles!

      Guests are performed for the perpetrator of the celebration ancient Gypsy Romance
      (Two can maintain, and all the others pick up chorus):

      Glasses are poured
      In them gleam amber,
      And faces light up
      How comical dawn!

      With wine, longing worn,
      Becomes light
      And the toast on the heart is asking:
      We drink for the anniversary!

      Chorus:

      Our choir sings antique ancient,
      Pours champagne river!
      For you, our friend is beloved,
      Our birthday book (maybe name) dear!

      What could be wonderful
      When, love Taya,
      You are met with a song
      Native and friends!

      Let the evening begins,
      How Life is a new circle,
      And all dreams come true,
      And everything blooms around!

      Chorus:
      Bottoms Up! Bottoms Up! Bottoms Up!

      Musical pause.

      Then Call toast for parents.

      Leading:

      Well, now, friends, the moment has come
      Fill a glass for parents!
      For those who gave the joy of life
      And in the world, the wonderful doors challenged,

      For those who teach him
      And the battery relay was handed over.
      For those thanks to who, now
      Our birthday is sitting among us!

      So drink for parents ... (calls them by name-patronymic)

      Musical pause.

      The presenter briefly talks about the life path of the jubilee.

      Host: And now we are singing "Old songs about the main hero of our holiday".

      (Guests sing on the motive of the songs about the pilots)


      Without a jubilee, let's say straight, there is nothing to do.
      We will gather at the table,
      Full glasses Nalmes
      And for his health Songs we sing:

      It's time for us to note
      And this day to meet

      Let you not twenty and not thirty, let!
      You do not lower your barrier!
      Watch we will be strictly
      You do not hurt us, you also know!

      We see brave, brave, brave
      Men slender, beautiful, curly!
      Let the series go for years
      But we wish you always
      Your soul remained young!

      It's time for us to note
      It's time to celebrate, celebrate the glorious anniversary!
      And this day to meet
      In the big company of relatives, friends!

      Let the fate sometimes be cruel to us, let!
      In response, you let go of your jokes!
      Follow the same strictly
      Do not admit a despondency around!

      Tonight, in the evening, in the evening
      Without an expensive jubilee, there is nothing to do!
      We will drink once, we will drink two
      For the anniversary and for affairs,
      But that tomorrow I did not hurt my head!

      We are a jubilee love, respect
      And our congratulations continue!

      (Guests sing on a ringtone "I can't me on your birthday ..." :)

      We can not you on your birthday
      Dear Mercedes give,
      But a gift handed, no doubt
      And ready to repeat a hundred times:

      That you are kind, cheerful, attentive
      And in matters generally accepted specials,
      What are you wonderful
      And comrade, and husband, and father!

      Leading:

      We want to congratulate you from the soul
      As well as the age of the passport,
      After all, it says your kind, your smile,
      What about ten years in the passport error!

      (Guests sing on the motive of the soldier's song "The path is far from us with you ...")

      Birthday man - brave guy
      Looking at Sokol in the ranks!
      Respect everyone he rightfully
      And in the service, as in battle!

      Chorus:

      ________ (Birthday name) on the road! Let's hit the road! Let's hit the road!
      To one hundred years reach
      And strong remain
      Fate calls you!
      ________ (Birthday name) forward!

      Dear Jubilee
      Congratulations from the soul!
      And the medal hand, and a gift
      In the means of merit of his big!

      Chorus.

      The anniversarier is awarded a gift and memorable medal with inscription: "For great merits in work, friendship and love." (Medal can be filled out of the tree and hang it on the neck of the birthday party on the ribbon

      Competition on the topic "Who knows the birthday better"!

      The judge will be the birthday itself.
      The leading asks questions and presents the chips for the right answers. The one who at the end of the game became the owner of the greatest number of chips, receives a prize with the attorney of the birthday man.

      Musical pause.

      Quiz on birthdays

      Dear friends! Let's try to determine the very erudite guest! The topic, of course, is still the same - birthday. Only not in life, but on the screen!

      For each correct or witty response, a chip is given. Following the quiz for the largest number of chips a prize is awarded. For example, chocolate. If the guests can not guess, the leading must give a prompt, a little remind of this film.

      Comic Questions and Answers

      You make two couch with questions and answers. At first, a person announces to whom he will ask the question, pulls the question and reads. Shears the cocks with the answers to whom he called. Then the one who called, pulls the answer and reads. Then he also announces to whom he will ask a question, pulls the question and reads. Etc.

      Dance by team lead

      Greeting telegrams-riddles (including guests)

      Leading announces: for Tanya congratulatory telegrams came, but they all without signature. You need to guess the sender. These are well-known people, as well as guests. And even fabulous heroes!

      Let them whisper about love to you on the ear!
      Tsarevna for Nickname ... Frog

      I wish to drink only vintage wines!
      Happy holiday to you! ... Malvina

      I wish to sing more often under the guitar!
      Good company to you! ... Rotaru

      I wish not to meet the love of unscheduled!
      Hello you musical from ... Bulanova

      Live, Seryozha, fun and cool!
      Do not forget about childhood! ... Queen

      I wish you a lot of music and laughter,
      love and eternal youth! ... Pieha

      Let the money always go to the fig!
      And chicken legs! ... Baba Yaga

      Because more often in the field and in the forest!
      Health to you strong! ... Alsu

      saddy never allow!
      Big hello from mom! ... Orloe.

      Do not get into PE and shootout!
      I wish you a long life! Group… Arrows

      The one who first gave the correct answer is given chips. For the greatest number of chips a prize is awarded.

      Lottery mystery

      The prize receives one who guessed that for the subject of the lead in the bag. You can ask leading questions. He answers "yes" or "no".

      Lottery - forecast

      Everyone pulls tickets or get them for a joke, anecdote. During the presenter drawing says:
      - Now we will experience fate and find out what she cooked.
      Giving gifts, starting from the first room and reads the forecast for the coming year.

      Test "Draw a non-existent animal"

      You ask for guests to draw a non-existent animal and write its name.

      Test "Draw a little man"

      It is necessary to draw a person from 12 figures: you need to use all the shapes - a circle and triangles, squares. (In the amount of them 12)

      At the conclusion of the evening, you can offer guests to open an account for the birthday phone. After that, to endure the 3rd - a liter jar where all guests can throw in the top ten.