DeanWhitehouse Posted June 1, 2008 Share Posted June 1, 2008 Ok, so basically what i want to is show an image on everypage depending on a variable if statment, but there are a few pages that use the same variable's and i cannot place the variable in the right_data.php (where the image is) becuase it will stop the pages with the variables working properly. Here is the code for one page where the variables are used, crime.php <?php session_start(); require_once('global.php'); $error= ""; $msg= ""; $success = 0; $isShowCode = false; $interval = 0; $exp = $db->getOne("select Experience from ".TBL_USER_DETAIL." where UserID = '".$_SESSION['userid']."'"); $cityID = $db->getOne("select CityID from ".TBL_USER." where Username = '".$_SESSION['username']."'"); $userRank = GetUserRank($exp); $sql = "select count(*) from ".TBL_USER_CRIME." where User = '".$_SESSION['username']."'"; $crimeCount = $db->getOne($sql); if ( $crimeCount > 0 && ( $crimeCount % VERIFY_TIMES ) == 0 ) { $isShowCode = true; } if ($_POST) { $crime = trim($_POST['crime']); $levelRequest = $db->getOne("select LevelNeed From ".TBL_CRIME." where ID = '".$crime."'"); $interval = $db->getOne("select count(*) from ".TBL_USER_CRIME." where User = '".$_SESSION['username']."' and DATE_SUB(NOW(), INTERVAL 2 MINUTE) < AddDate"); if ($interval > 0 ) { $error .= "You cannot do another crime yet.<br>"; } if ($userRank < $levelRequest) { $rankName = $db->getOne("select Title From ".TBL_RANK." where ID = '".$levelRequest."'"); $error .= "You must be at least a ".$rankName." to do this crime.<br>"; } elseif ($isShowCode) { $randomcode = safeStr($_POST['randomcode']); if ($randomcode != $_SESSION['key'] ) { $error = "Code is not verified."; } } if ($error == "") { $sql = "select Chance from ".TBL_CRIME_CHANCE." where User = '".$_SESSION['username']."' and CrimeType = '".$crime."'"; $chance = $db->getOne($sql); if ($chance == "" ) $chance = 0; if (mt_rand(1, 100) < $chance ) { $success = 1; //successful } else { $temp = mt_rand(1, 100); $success = (($temp < 90) ? 2 : 3); } $crimeTitle = $db->getOne("select Title from ".TBL_CRIME." where ID = '".$crime."'"); $sql = "insert into ".TBL_USER_CRIME." set User = '".$_SESSION['username']."', AddDate = NOW(), Crime = '".$crime."', Success = '".$success."'"; $db->query($sql); if ($success == 1) { $profitRow = $db->getRow("select MinProfit, MaxProfit from ".TBL_CRIME." where ID = '".$crime."'"); $profit = mt_rand($profitRow[0],$profitRow[1]); $userGetMoney = UptCrewMoney("Crime",$profit); $sql = "update ".TBL_USER_DETAIL." set Cash = (Cash + ".$userGetMoney.") where UserID = '".$_SESSION['userid']."'"; $db->query($sql); $addExp = mt_rand(3,; RankUpdate($addExp); $sql = "update ".TBL_USER_DETAIL." set Experience = (Experience + ".$addExp.") where UserID = '".$_SESSION['userid']."'"; $db->query($sql); } else { //unsuccessful or get caught $addExp = mt_rand(2,4); RankUpdate($addExp); $sql = "update ".TBL_USER_DETAIL." set Experience = (Experience + ".$addExp.") where UserID = '".$_SESSION['userid']."'"; $db->query($sql); } $MaxCrime = $db->getOne("select ID from ".TBL_CRIME." where LevelNeed <= '".$userRank."' order by LevelNeed Desc limit 0,1"); for ($i = 1;$i <= $MaxCrime;$i++) { $chance = $db->getOne("select Chance from ".TBL_CRIME_CHANCE." where User = '".$_SESSION['username']."' and CrimeType = '".$i."'"); $chance = (($chance == 100) ? (100 - mt_rand(5, 10)): ($chance + mt_rand(1, 2)) ); if ($chance > 100 ) $chance = 100; $sql = "update ".TBL_CRIME_CHANCE." set Chance = '".$chance."' where User = '".$_SESSION['username']."' and CrimeType = '".$i."'"; $db->query($sql); } $isShowCode = false; } } if ($success == 0 ) { $interval = $db->getOne("select count(*) from ".TBL_USER_CRIME." where User = '".$_SESSION['username']."' and DATE_SUB(NOW(), INTERVAL 2 MINUTE) < AddDate"); } $arrCrime = $db->getAll("select ID,Title,LevelNeed from ".TBL_CRIME." order by ID desc"); for ($i=0; $i < count($arrCrime);$i++ ) { $sql = "select Chance from ".TBL_CRIME_CHANCE." where User = '".$_SESSION['username']."' and CrimeType = '".$arrCrime[$i][0]."'"; $arrCrime[$i][3] = $db->getOne($sql); $arrCrime[$i][3] = ($arrCrime[$i][3]=="") ? 0 : $arrCrime[$i][3]; } $smarty = new MySmarty(); $smarty->assign('title', SITE_TITLE.' :: Crime'); $smarty->assign('base_url', BASE_URL); $smarty->assign('hiddenstr', $hiddenstr); //right side data require_once('right_data.php'); //right side data $smarty->assign('success', $success); $smarty->assign('error', $error); $smarty->assign('msg', $msg); $smarty->assign('interval', $interval); $smarty->assign('isShowCode', $isShowCode); $smarty->assign('userRank', $userRank); $smarty->assign('arrCrime', $arrCrime); $smarty->assign('arrCrimeCount', count($arrCrime)); if ($success == 1 ) { $smarty->assign('crime', $crime); $smarty->assign('profit', $profit); } if ($success == 2) { $smarty->assign('crimeTitle', $crimeTitle); } require_once('injail.php'); //when user is in jail require_once('inhospital.php'); //when user is in hospital require_once('inshooting.php'); //when user is in shooting range if ($success == 3) { // get caught $duration = mt_rand(40, 80); //$isBreakable = (mt_rand(1, 100) <= 70) ? 1 : 0; $isBreakable = 1; $sql = "insert into ".TBL_JAIL." set User = '".$_SESSION['username']."', City = '".$cityID."', AddDate = NOW(), Duration = '".$duration."', IsBreakable = '".$isBreakable."', IsBurst = 0"; $db->query($sql); } $smarty->display('crime.htm'); ?> this is right_data.php <?php $rowDetail = $db->getRow("select ShootSkill,ProtectionID,GunID,Experience,Cash, BoozeTimes from ".TBL_USER_DETAIL." where UserID = '".$_SESSION['userid']."'"); $rowDetail[1] = ($rowDetail[1] == "" ) ? 0 : $rowDetail[1]; $rowDetail[2] = ($rowDetail[2] == "" ) ? 0 : $rowDetail[2]; $userRank = GetUserRank($rowDetail[3]); if ($userRank < 12) { $nextRank = $db->getOne("select Title from ".TBL_RANK." where ID = '".($userRank+1)."'"); $nextRankRatio = intval( ($rowDetail[3]-GetRankValue($userRank)) / (GetRankValue($userRank+1)-GetRankValue($userRank)) * 100); } $smarty->assign('nextRankRatio', $nextRankRatio); $sql = " select C.Title, G.Title, D.Bullet, P.Title, D.Cash, D.Experience, D.Health, Cr.Title, (100-D.Health) as HealthLeft from ".TBL_USER_DETAIL." D INNER JOIN ".TBL_USER." U ON U.ID = D.UserID LEFT JOIN ".TBL_GUN." G ON G.ID =D.GunID "; $sql .= " INNER JOIN ".TBL_CITY." C ON C.ID =U.CityID LEFT JOIN ".TBL_PROTECTION." P ON P.ID =D.ProtectionID LEFT JOIN ".TBL_CREW." Cr ON Cr.ID =D.CrewID where U.UserName = '".$_SESSION['username']."'"; $row_userdetail = $db->getRow($sql); $row_userdetail[4] = number_format($row_userdetail[4]); $row_userdetail[5] = GetUserRankName($row_userdetail[5]); $row_userdetail[9] = $db->getOne("select count(*) from ".TBL_MESSAGE." where Recipient = '".$_SESSION['username']."' and IsViewed = 0 and IsSaved = 0"); //echo "select count(*) from ".TBL_MESSAGE." where Recipient = '".$_SESSION['username']."' and IsViewed = 0 and IsSaved = 0";exit(); $row_userdetail[10] = $db->getOne("select count(*) from ".TBL_JAIL." where DATE_SUB(NOW(), INTERVAL Duration SECOND) < AddDate and IsBurst = 0"); $smarty->assign('arrUserDetail', $row_userdetail); $smarty->assign('currTime', date("D h:i A", time())); ?> and this is right.htm <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link href="../../css/main.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="skinnytip.js"> <!-- SkinnyTip (c) Elliott Brueggeman --> </script> <style type="text/css"> <!-- {literal}.style1 {font-size: 10}{/literal} --> </style> </head> <body> <div id="tiplayer" style="position:absolute; visibility:hidden; z-index:10000;"></div> <table width="150" align="center" cellpadding="0" cellspacing="0" class="rightborder"> <tr> <td class="headertop"><div align="center">.:Stats:.</div></td> </tr> <tr> <td bgcolor="#666666" class="body"><table width="150" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="73" background="../../images/earth.jpg"><div align="center"><span class="biggrey">{$arrUserDetail[0]}</span></div></td> </tr> </table> <table width="150" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><div align="center"> <p align="center" class="biggrey"></font></p> <script src="http://www.clocklink.com/embed.js"></script><script type="text/javascript" language="JavaScript">obj=new Object;obj.clockfile="0002-black.swf";obj.TimeZone="JST";obj.width=150;obj.height=150;obj.Place="";obj.wmode="transparent";showClock(obj);</script> </div></td> </tr> </table> <table width="150" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="36" background="../../images/images/statsright_01.png"> </td> </tr> <tr> <td background="../../images/images/statsright_02.png" class="statsright"><table width="100%" border="0" cellpadding="0" cellspacing="5" class="statsright"> <tr> <td>- Crew: {if ($arrUserDetail[7]=="")}None{else}{$arrUserDetail[7]}{/if}</td> </tr> <tr> <td>- Rank: {$arrUserDetail[5]}</td> </tr> <tr> <td>- Money: ${$arrUserDetail[4]}</td> </tr> <tr> <td>- Armor: {if ($arrUserDetail[3]=="")}None{else}{$arrUserDetail[3]}{/if} </td> </tr> <tr> <td>- Bullets: {$arrUserDetail[2]}</td> </tr> <tr> <td>- Gun: {if ($arrUserDetail[1]=="")}None{else}{$arrUserDetail[1]}{/if}</td> </tr> </table> </td> </tr> <tr> <td height="22" background="../../images/images/statsright_03.png"> </td> </tr> </table> <p align="center"><a href="{$base_url}mailbox.php"><img src="{$base_url}images/{if ($arrUserDetail[9]== 0) }msg2{else}msgmail{/if}.gif" border="0" onMouseOver = "return tooltip('('{$arrUserDetail[9]} new messages!')', 'You have', 'width:75, titletextcolor:#222222, bordercolor:#999999, backcolor:#666666, fontsize:10');" onmouseout="return hideTip();" onClick=""></p> </tr> <tr> <td bgcolor="#666666" class="body"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="rightbars"> <tr> <td width="{$nextRankRatio}%" align="right" background="../../images/gunbar.gif"><div align="center">Rank:({$nextRankRatio}%)</div></td> <td width="{math equation=" align="left"x-y" x=100 y=$nextRankRatio}%"></td> </tr> </table> </tr> <tr> <td bgcolor="#666666" class="body"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="rightbars2"> <tr> <td width="{$arrUserDetail[6]}%" align="right" background="../../images/healthbar.gif"><div align="center">Health({$arrUserDetail[6]}%)</div></td> <td width="{$arrUserDetail[8]}%" align="left"></td> </tr> </table> </tr> <tr> <td height="100%" nowrap="nowrap" bgcolor="#999999"><table width="60%" border="0" align="center" cellpadding="5" cellspacing="0"> <tr> <td><div align="center"><a href="crime.php">{ if ($interval > 0 ) }<img src="../images/WigetCrime.jpg" border="0" onClick="" onMouseOver = "return tooltip('Crime', 'Timer', 'width:75, titletextcolor:#222222, bordercolor:#999999, backcolor:#666666, fontsize:10');" onmouseout="return hideTip();" onClick="">{else}<img src="../images/WigetCrimeGreen.jpg" border="0" onClick="" onMouseOver = "return tooltip('Crime', 'Timer', 'width:75, titletextcolor:#222222, bordercolor:#999999, backcolor:#666666, fontsize:10');" onmouseout="return hideTip();" onClick="">{/if} <td><div align="center"><a href="burglary.php"><img src="../images/WigetGTA.jpg" border="0" onClick="" onMouseOver = "return tooltip('GTA', 'Timer', 'width:75, titletextcolor:#222222, bordercolor:#999999, backcolor:#666666, fontsize:10');" onmouseout="return hideTip();" onClick=""> </tr> <tr> <td><div align="center"><a href="fight.php"> <img src="../images/WigetFight.jpg" border="0" onClick="" onMouseOver = "return tooltip('Work Out!', 'Timer', 'width:75, titletextcolor:#222222, bordercolor:#999999, backcolor:#666666, fontsize:10');" onmouseout="return hideTip();" onClick=""> <td><div align="center"><a href="airport.php"><img src="../images/WigetTravel.jpg" border="0" onClick="" onMouseOver = "return tooltip('Airport', 'Timer', 'width:75, titletextcolor:#222222, bordercolor:#999999, backcolor:#666666, fontsize:10');" onmouseout="return hideTip();" onClick=""> </tr> </table> <p> </p> <p> </p> <p> </p> </tr> </table> <script type="text/javascript" src="../../skinnytip.js"></script> </td> </tr> </table> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/108226-display-image-based-on-certain-factor-but-on-everypage-without-conflicting-vars/ Share on other sites More sharing options...
paulman888888 Posted June 1, 2008 Share Posted June 1, 2008 can you just change the name of your image variable to something verylong that will never be in any other page or am i missing the problem Quote Link to comment https://forums.phpfreaks.com/topic/108226-display-image-based-on-certain-factor-but-on-everypage-without-conflicting-vars/#findComment-554748 Share on other sites More sharing options...
DeanWhitehouse Posted June 1, 2008 Author Share Posted June 1, 2008 I could but it is based on a number of factors that are set right_data.php Quote Link to comment https://forums.phpfreaks.com/topic/108226-display-image-based-on-certain-factor-but-on-everypage-without-conflicting-vars/#findComment-554750 Share on other sites More sharing options...
DeanWhitehouse Posted June 1, 2008 Author Share Posted June 1, 2008 any other ideas. Quote Link to comment https://forums.phpfreaks.com/topic/108226-display-image-based-on-certain-factor-but-on-everypage-without-conflicting-vars/#findComment-554769 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.