Search:

Categories



a MySQL search function

if (!function_exists(‘mysql_search’)) {
 
   function mysql_search($table, $columns, $query = ”, $options = Array()) {
 
      if (empty($query)) { return Array(); }
 
      $sql_query = Array();
 
      $options[‘columns’] = isset($options[‘columns’])?$options[‘columns’]:’*’;
      $options[‘method’] = isset($options[‘method’])?$options[‘method’]:’OR’;
      $options[‘extra_sql’] = isset($options[‘extra_sql’])?$options[‘extra_sql’]:”;
 
      $query = ereg_replace(‘[[:<:]](and|or|the)[[:>:]]’, ”, $query);
      $query = ereg_replace(‘ +’, ‘ ‘, trim(stripslashes($query)));
 
      $pattern = ‘/([[:alpha:]:]+)([[:alpha:] ]+)[[:alpha:]]?+[ ]?/i’;
 
      $regs = Array();
 
      preg_match_all($pattern, $query, $regs);
 
      $query = $regs[0];
 
      while (list($key, $value) = @each($query)) {
 
         $column = $columns;
         $keywords = urldecode($value);
 
         if (strpos($value, ‘:’)) {
 
            $column = substr($value, 0, strpos($value, ‘:’));
            $keywords = trim(substr($keywords, strpos($keywords, ‘:’) + 1));
            $keywords = ereg_replace(”’, ”, $keywords);
 
         } else { $keywords = ereg_replace(‘ +’, ‘|’, $keywords); }
 
         $column_list = explode(‘ ‘, $column);
 
         $sql = Array();
 
         for ($i = 0; $i < count($column_list); $i++) { $sql[] = ” . $column_list[$i] . ‘ REGEXP "’ . $keywords . ‘"’; }
 
         $query[$key] = Array(‘orignal’=>$value, ‘sql’=>implode(‘ ‘ . $options[‘method’] . ‘ ‘, $sql));
 
         $sql_query = array_merge($sql_query, $sql);
         $sql_query = implode(‘ ‘ . $options[‘method’] . ‘ ‘, $sql_query);
 
      }
 
      $results = mysql_fetch_results(mysql_query(‘SELECT ‘ . $options[‘columns’] . ‘ FROM ‘ . $table . ‘ WHERE ‘ . $sql_query . ‘ ‘ . $options[‘extra_sql’]));
 
      return $results;
 
   }
 
}

Share

PHP and MySQL Everyday Applications for Dummies (Paperback)

PHP and MySQL Everyday Applications for Dummies

PHP and MySQL Everyday Apps For Dummies is a one–stop reference providing all you need to build dynamic, real–world, ready–to–use apps with the popular PHP (a scripting language) and MySQL (a database system) software. The book is a hands–on, go–to–guide that Walks you through installing the applications files from the CD–ROM and setting up your programming environment Contains all the code needed to create seven applications: User authentication with HTTP User login On–line catalog Shopping cart Content management system Web forum Building and managing a mailing list (on the CD–ROM) Automates the programming process and walks you through building the application from start to finish Explains how to write secure code Features complete code—not just snippets, but neatly assembled packages with “instant” real–world functionality Shows how to build the applications in two forms –– procedural and obje (more…)

Share

PHP and MySQL Web Development (Developer’s Library) (Paperback)

PHP and MySQL Web Development (Developer's Library)

Amazon.co.uk ReviewPHP and MySQL Web Development introduces readers (who are assumed to have little or no experience with the title subjects) to PHP and MySQL for the purpose of creating dynamic Internet sites. It teaches the same skills as introductory Active Server Pages (ASP) and ColdFusion books–technologies which address the same niche. Authors Luke Welling and Laura Thomson’s technique aims to get readers going on their own projects as soon as possible. They present easily digestible sections on specific technical processes–“Accessing Array Contents” and “Using Encryption with PHP” are two examples. Each section centres on a sample program that strips the task at hand down to its essentials, enabling the reader to fit the process into his or her own solutions as required. Tables that list options and other nuggets of reference material appear as well, but the many examples and the authors’ commentary on them take centre stage. For reference material on MySQL, have a (more…)

Share

PHP and MySQL for Dummies (Paperback)

PHP and MySQL for Dummies

Build an online catalog and a members–only site Everything you need to know to create a dynamic PHP and MySQL Web site! Been thinking of creating a high–quality interactive Web site? This book is just what you need to get started! Here′s the fun and easy way(r) to develop a Web application in PHP 4, 5, or 6 and MySQL 5, test your software, enable your Web pages to display, change, and move database information, and much more. Discover how to ∗ Plan and implement a Web database application ∗ Design and build a MySQL 5 database ∗ Build dynamic HTML forms ∗ Create scripts that store, retrieve, and update database information ∗ Display database information in a Web page

From the Back CoverBuild an online catalog and a members–only site Everything you need to know to create a dynamic PHP and MySQL Web site! Been thinking of creating a high–quality interactive Web site? This book is just what you need to get started! Here′s the fun and (more…)

Share

PHP and MySQL Web Development All-in-one Desk Reference for Dummies (Paperback)

PHP and MySQL Web Development All-in-one Desk Reference for Dummies

If you want to build dynamic Web sites that encourage users to interact with them, PHP and MySQL are among the best tools you’ll find. PHP is a scripting language designed specifically for use on the Web, while MySQL is a database management system that works with it perfectly. Best of all, they’re free. It’s hard to beat that combination! PHP & MySQL Web Development All–in–One Desk Reference For Dummies is kind of one–stop shopping for the information you need to get up and running with these tools and put them to good use. It’s divided into six handy minibooks that cover setting up your environment, PHP programming, using MySQL, security, PHP extensions, and PHP Web applications. They make it easy to create a Web site where visitors can sign on, use shopping carts, complete forms, and do business with your business. It’s easy to find what you need in this handy guide. You’ll discover how to: Find and acquire all the tools you need and set (more…)

Share

Build Your Own Database Driven Web Site Using PHP & MySQL (Paperback)

Build Your Own Database Driven Web Site Using PHP & MySQL

“Build Your own Database Driven Web Site Using PHP & MySQL” is a practical hands-on guide to learning all the tools, principles and techniques needed to build a fully functional database-driven web site using PHP & MySQL. This book covers everything from installing PHP & MySQL under Windows, Linux, and Mac through to building a live web-based content management system. While this is essentially a beginners book, it also covers more advanced topics such as the storage of binary data in MySQL, and cookies and sessions in PHP. It comes complete with a set of handy reference guides for PHP & MySQL that include: MySQL syntax MySQL functions MysQL column types PHP functions for working with MySQL

About the Author
Kevin Yank is a world-renowned leader in web development. When not writing best sellers, Kevin is the Technical Director of sitepoint.com and editor of the popular SitePoint Tech Times newsletter.

(more…)

Share