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 = " | [Game Hint : ". $rec["cat_name"]."]";
}
}
echo(" <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">
<?
if(isset($_SESSION['u_id']))
{
echo("<a href='logout.php'>Logout</a>");
}
?>
</td>
</tr>
</table>
</body>
----------------------------------------------------
Please help me as I have a deadline
|