Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
| Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 22nd, 2006, 09:14 AM
Friend of Wrox
Points: 686, Level: 9
Points: 686, Level: 9 Points: 686, Level: 9 Points: 686, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Kolkata, West Bengal, India.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Search engine with hints

Hi,
I am working on a search engine which displays advertisers links when a keyword is searched. Some of the links have a game piece hidden in them and user can find the game pieces to play the game. Every time a search is made a hint word is displayed to find the game pieces.I am having a problem in displaying the hint words. The hint words are coming through query from 2 tables namely user game & the category where the cat_id of both the tables match. the first 2 hints are coming but thereafter the words are togggling between each other. In total there are 20-22 hint words which should randomly appear after every search.

I am putting the code below:
----------------------------------------------------------------

<?
    //Start the session!
    session_start();
    $hint = "";
    $ctr = "";
    //$hint1 = "";
?><head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body alink="#0066FF" vlink="#993399" link="#00CC33">
<table width="777" border="0" height ="18" cellpadding="0" cellspacing="0">

  <tr>
    <td width="577" height="18" align="left" valign="middle" class="tdOne">

Welcome
      <?
          //echo("THE value is: ".$_SESSION['USER_TYPE']);
        if(isset($_SESSION['USER_TYPE']))
        {
            //Advertiser/User loged in, show his name!
            echo($_SESSION['u_id']);
            echo("|");
            //surely theres a login, chk whose in!
            if($_SESSION['USER_TYPE'] == 1)
            {
                //Some Mr.Good Advertiser is IN...
                //Next goes the manage account Link!
                echo("<a href='adv_admin/adv_acc_mgr.php'>Account manager</a>");
            }
            else
            {
                //Some Mr.Freaking Guy user is in...
                //Next goes the manage account Link!
                echo("<a href='user_acc_mgr.php'>Your Account</a>");
                ////////////GET THE NEXT HINT IN CASE THERE IS A GAME CREATED FOR THIS USER
                //$sqlmissingcount = "SELECT srch_user_game.cat_id, srch_category.cat_name FROM srch_user_game, srch_category WHERE srch_user_game.user_id='".$_SESSION['u_id']."' and srch_user_game.cat_id=srch_category.cat_id";
                //echo($_SESSION['hint1']."<br>");

                if($_SESSION['hint1'] != "")
                {
                    $sqlmissingcount = "SELECT distinct srch_user_game.cat_id, srch_category.cat_name FROM srch_user_game, srch_category WHERE srch_user_game.user_id='".$_SESSION['u_id']."' and srch_user_game.cat_id=srch_category.cat_id and srch_user_game.cat_id != '".$_SESSION['hint1']."' AND kwd_found = '0'
AND game_active = '1' order by srch_user_game.cat_id";
                }
                else
                {
                    $sqlmissingcount = "SELECT distinct srch_user_game.cat_id, srch_category.cat_name FROM srch_user_game, srch_category WHERE srch_user_game.user_id='".$_SESSION['u_id']."' and srch_user_game.cat_id=srch_category.cat_id AND kwd_found = '0' AND game_active = '1' order by srch_user_game.cat_id";
                }
                //echo $sqlmissingcount."<br>";
                $resmissingcount = mysql_query($sqlmissingcount);
                //$rec = mysql_fetch_array($resmissingcount);
                $count = mysql_num_rows($resmissingcount);
                if($_SESSION['hint1'] == "")
                {
                    $ctr = 0;
                }
                else
                {
                    $ctr = $ctr+1;
                }

                for($i = $ctr;$i < $count; $i++)
                {
                    $rec = mysql_fetch_array($resmissingcount);
                    //echo ($rec['cat_id']."<br>");
                }
                $_SESSION['hint'] = $rec["cat_name"];
                $_SESSION['hint1']= $rec['cat_id'];
                if($rec)
                {
                    $hint = "&nbsp;|&nbsp;[Game Hint : ". $rec["cat_name"]."]";
                }
            }
            echo("&nbsp;&nbsp;&nbsp;<a href='forum/index.php'>Online Forum</a>");
            echo $hint;
            $ctr++;

            //echo $hint1;
        }
        else
        {
            //no one is logged in!
            echo("Guest");
        }


        /*if(isset($_SESSION['u_id']))
        {
            //user loged in, show his name!
            echo($_SESSION['u_id']);
        }
        else
        {
            //no one is logged in!
            echo("Guest");
        }
        ?>

        <?
        if(isset($_SESSION['u_id']))
        {
            echo("|");
            //Next goes the manage account Link!
            echo("<a href='adv_admin/adv_acc_mgr.php'>Account manager</a>");
        }*/
        ?>
    </td>
    <td width="200" align="right" valign="middle" class="tdOne">&nbsp;
    <?
        if(isset($_SESSION['u_id']))
        {
            echo("<a href='logout.php'>Logout</a>");
        }
    ?>
    </td>
  </tr>
</table>
</body>
----------------------------------------------------

Please help me as I have a deadline




Similar Threads
Thread Thread Starter Forum Replies Last Post
search engine rajuru PHP Databases 3 December 5th, 2004 01:22 AM
Search Engine for Full-text Search Kala ASP.NET 1.0 and 1.1 Professional 2 August 29th, 2004 02:16 AM
search engine alihussein3 Javascript How-To 3 October 21st, 2003 02:24 PM
Search engine that search through local drive! wenzation Classic ASP Basics 0 August 26th, 2003 09:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.