PDA

View Full Version : <if condition=> help please


Joe Pimms
01-29-2005, 12:20 AM
hey i have a question for all you php coders

im working on a vbhack that improrting from another script my question is this
in the script im working on have all the templates in the .php scripts and in the scripts there are a few areas that have this in it

<table width="140" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#86A4C6">
<tr>
<td background="bgMenu.gif">
<div align="center"><strong>Stats</strong></div></td>
</tr>
<tr class="categoriesbox_transparentborder">
<td bgcolor="#f5f7fa" class="categoriesbox_text"><div align="center">Serials in DB: <?php getindb();?><br>
Total Serial Views: <?php gettotalviews();?></div></td>
</tr>
</table>

<?php gettotalviews();?>
its these thing im wondering when i make the template how i can keep this same function to work in the script as im going to remove all the other thing and leave the php code in the php tags

could i use the
<if condition=> or ?

please help me

Guy G
01-29-2005, 12:57 AM
you will need to put in the php script something like
gettotalviews() = $gettotalviews

Than on the template you put $gettotalviews where the gettotalviews() was..

a if is just a conditional.

Dean C
01-29-2005, 10:00 AM
in your php file put:


$gettotalviews = gettotalviews();


And put $gettotalviews in the template where you have your current phpcode :)

Joe Pimms
01-29-2005, 03:32 PM
so would the script look like this then ?
in the php script:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'serial');
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require"config_serial.php";
require"functions_serial.php";
// ################################################## ######################
?>

<script src="./sys.js"></script>
<?php
$getindb = getindb();
$gettotalviews = gettotalviews();
$advsbox = advsbox();
$gettitle = gettitle(40);
$getserials = getserials(40,40,40);
$pagelinks = pagelinks();

eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('serials') . '");');
?>


and here is the template:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>YourSiteTitle</title>
<script src="./sys.js"></script>
$headinclude
</head>
<body>
$header
$navbar
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="80%" align="center">
<thead>
<tr>
<td class="tcat" colspan="2">$vbphrase[serial_system]</td>
</tr>
</thead> <tr>
<td width="155" height="327" valign="top"> <div align="center"><br>
<br>
<table width="140" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td class="thead" width="175">$vbphrase[Navigation_serial]</td> </tr>
<tr class="categoriesbox_transparentborder">
<td class="categoriesbox_text"> <strong><a href="add_serial.php" target="_blank">Add Serial</a></strong></td>
</tr>
</table>
<br>
<br>
<table width="140" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td class="thead" width="175">$vbphrase[stats_serial]</td> </tr>
<tr class="categoriesbox_transparentborder">
<td class="categoriesbox_text"><div align="center">Serials in DB: $getindb<br>
Total Serial Views: $gettotalviews</div></td>
</tr>
</table>
<br>
</div></td>
<td width="624" valign="top"><div align="center"><br>
$advsbox
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td colspan="5" background="bgMenu.gif"><div align="center"><strong>$gettitle</strong></div></td>
</tr>
<td class="thead" width="175">$vbphrase[Software_Name]</td>
<td class="thead" width="175">$vbphrase[Date_serial]</td>
<td class="thead" width="175">$vbphrase[Views_serial]</td>
<td class="thead" width="175">$vbphrase[Working_in]</td>
</tr>
$getserials
$pagelinks
<tr class="categoriesbox_transparentborder">
<td colspan="5" class="categoriesbox_text"></td>
</tr>
</table>
</div></td>
</tr>
</table>
$footer
</body>
</html>

cause this is the real one im working on here below

<?php
require"config.php";
require"functions.php";
?>
<html>
<head>
<title>YourSiteTitle</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="serials.css" rel="stylesheet" type="text/css">
<script src="./sys.js"></script>
</head>
<style>
a:link {color: #0F51C6; text-decoration: none}
a:active {color: #0F51C6; text-decoration: none}
a:visited {color: #0F51C6; text-decoration: none}
a:hover {color: #000000; text-decoration: none}
.box {color: #193A4D; border: 1px solid #D0D5D9; background-color: #F3F4F5; font-family:Verdana; font-size:8pt}
td {font-family: Tahoma; font-size: 8pt}
body {font-family: Tahoma; font-size: 8pt; scrollbar-face-color: #F3F4F5;scrollbar-shadow-color: #ADB6BC; scrollbar-highlight-color: #ADB6BC; scrollbar-3dlight-color: #F3F4F5; scrollbar-darkshadow-color: #F3F4F5; scrollbar-track-color: #FFFFFF; scrollbar-arrow-color: #ADB6BC}
.carea { font-size: 11px; line-height: 24px; color: #878787; letter-spacing: -1; }
.smallblack { font-size: 10px; color: #000000; letter-spacing: -1; }
.sidelink { font-size: 10px; color: #686868; letter-spacing: -1; }
</style>
<body>
<div align="center">
<table width="650" height="349" border="0" cellpadding="0" cellspacing="1" bgcolor="#86A4C6">
<tr>
<td height="19" colspan="2" valign="top" bgcolor="#f5f7fa">
<div align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="65" background="rightoflogo.jpg"> <div align="center">
<table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="210" height="20"><div align="center"></div></td>
<td width="359" rowspan="3"> <div align="center"></div></td>
<td width="211" height="20"><div align="center"></div></td>
</tr>
<tr>
<td width="210" height="11"><img src="blank.gif" width="1" height="11"></td>
<td width="211" height="11"><img src="blank.gif" width="1" height="13"></td>
</tr>
<tr>
<td width="210" height="32"> <div align="center"><font size="1"><img src="arrow.gif" width="9" height="8">
<strong><a href="javascript:window.external.AddFavorite('http://www.url.com/','YOURSITETITLE')">Bookmark
Us</a><img src="blank.gif" width="8" height="1"> </strong><img src="arrow.gif" width="9" height="8">
<strong><a href="javascript:setHomepage()" onClick="this.style.behavior='url(#default#homepage)'; this.setHomePage ('http://www.url.com/');"><span class="maintext">Make
HomePage</span></a></strong></font></div></td>
<td width="211" height="32"> <div align="center"><font size="1"><strong>Todays
Date:</strong>
<script language="JavaScript">
<!--

var font="verdana";
var fsize="2";
var now=new Date();
var month="";
var year="";
var date=now.getDate();

if(now.getMonth()==0)month="January"
if(now.getMonth()==1)month="February"
if(now.getMonth()==2)month="March"
if(now.getMonth()==3)month="April"
if(now.getMonth()==4)month="May"
if(now.getMonth()==5)month="June"
if(now.getMonth()==6)month="July"
if(now.getMonth()==7)month="August"
if(now.getMonth()==8)month="September"
if(now.getMonth()==9)month="October"
if(now.getMonth()==10)month="November"
if(now.getMonth()==11)month="December"
if(now.getYear()<100)year="19"+now.getYear()
if(now.getYear()>=100)var year="2003"

document.write('<font size="1" face="verdana" " color="#000000">'+month+" "+date+", "+year)

//-->
</script>
</font></div></td>
</tr>
</table>
</div></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td width="155" height="327" valign="top" bgcolor="#f5f7fa"> <div align="center"><br>
<table width="140" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#86A4C6">
<tr>
<td background="bgMenu.gif">
<div align="center"><strong>Search Serials </strong></div></td>
</tr>
<tr class="categoriesbox_transparentborder">
<form action="?" method="post"><td bgcolor="#f5f7fa" class="categoriesbox_text">
<input name="q" type="text" class="box" size="15">
<input type="submit" class="box" value="Go"></td></form>
</tr>
</table>
<br>
<table width="140" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#86A4C6">
<tr>
<td background="bgMenu.gif"> <div align="center"><strong>Navigation
</strong></div></td>
</tr>
<tr class="categoriesbox_transparentborder">
<td bgcolor="#f5f7fa" class="categoriesbox_text"><a href="./">Home / Top 20</a><br>
<a href="?do=advs">Advanced Search</a><br>
<a href="?do=browse">Browse By Added</a><br>
<strong><a href="add.php" target="_blank">Add Serial</a></strong></td>
</tr>
</table>
<br>
<table width="140" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#86A4C6">
<tr>
<td background="bgMenu.gif">
<div align="center"><strong>List By </strong></div></td>
</tr>
<tr class="categoriesbox_transparentborder">
<td bgcolor="#f5f7fa" class="categoriesbox_text"><div align="center"><a href="?list=1">#</a> <a href="?list=a">A</a> <a href="?list=b">B</a> <a href="?list=c">C</a> <a href="?list=d">D</a> <a href="?list=e">E</a> <a href="?list=f">F</a> <a href="?list=g">G</a> <a href="?list=h">H</a> <a href="?list=i">I</a> <a href="?list=j">J</a> <a href="?list=k">K</a> <a href="?list=l">L</a> <a href="?list=m">M</a> <br>
<a href="?list=n">N</a> <a href="?list=o">O</a> <a href="p">P</a> <a href="?list=q">Q</a> <a href="?list=r">R</a> <a href="?list=s">S</a> <a href="?list=t">T</a> <a href="?list=u">U</a> <a href="?list=v">V</a> <a href="?list=w">W</a> <a href="?list=x">X</a> <a href="?list=y">Y</a> <a href="?list=z">Z</a></div></td>
</tr>
</table>
<br>
<table width="140" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#86A4C6">
<tr>
<td background="bgMenu.gif">
<div align="center"><strong>Stats</strong></div></td>
</tr>
<tr class="categoriesbox_transparentborder">
<td bgcolor="#f5f7fa" class="categoriesbox_text"><div align="center">Serials in DB: <?php getindb();?><br>
Total Serial Views: <?php gettotalviews();?></div></td>
</tr>
</table>
<br>
<table width="140" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#86A4C6">
<tr>
<td background="bgMenu.gif"> <div align="center"><strong>Partners
/ Affiliates</strong></div></td>
</tr>
<tr class="categoriesbox_transparentborder">
<td bgcolor="#f5f7fa" class="categoriesbox_text"> <div align="center"><br>
</div></td>
</tr>
</table>
</div></td>
<td width="624" valign="top" bgcolor="#f5f7fa"><div align="center"><br>
<?php advsbox();?>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#86A4C6">
<tr>
<td colspan="5" background="bgMenu.gif"><div align="center"><strong><?php gettitle(40);/*First = Top...Serials on main page*/?></strong></div></td>
</tr>
<tr bgcolor="#f5f7fa">
<td bgcolor="#f5f7fa">Software Name </td>
<td bgcolor="#f5f7fa">Date</td>
<td bgcolor="#f5f7fa">Views</td>
<td bgcolor="#f5f7fa">Working in %</td>
</tr>
<?php getserials(40,40,40);/*First=Frontpage(top..),Second=#-Z(list..)+Browse,Third=SearchResults*/?>
<?php pagelinks();?>
<tr class="categoriesbox_transparentborder">
<td colspan="5" bgcolor="#f5f7fa" class="categoriesbox_text"></td>
</tr>
</table>
</div></td>
</tr>
</table>
</body>
</html>


please help

miz
01-29-2005, 11:44 PM
well
if i got you right then its dosent show vb header and footer or things like that
right ?

so in the function gettotalviews();

add


global $header,$footer,$headinclude;



should work if this is your problem
i had this problem in my one of my hacks

btw this will work only if the function call to template.

Joe Pimms
01-30-2005, 12:39 AM
where in my script do i put this can you give me a example please ?

well
if i got you right then its dosent show vb header and footer or things like that
right ?

so in the function gettotalviews();

add


global $header,$footer,$headinclude;



should work if this is your problem
i had this problem in my one of my hacks

btw this will work only if the function call to template.

miz
01-30-2005, 12:42 AM
where you have
function gettotalviews

but i think i just got you worng
so if you can explain your problem again
i might be able to help you more

TECK
01-30-2005, 03:07 AM
You can also embed PHP in HTML language, with a simpe tag like:
<script type="php"></script>