Page 1 of 1

PHP code help

Posted: Tue Jul 22, 2008 1:21 pm
by strangenet
I am working with PHP nuke and I want to move the banner ads on a them up into a table, but I am a newb to PHP coding and could use a little help.

Code: Select all

echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"$thewidth\" border=\"0\" align=\"center\">\n"
        ."<tr>\n<td background=\"themes/$thename/images/logobg.gif\"><img src=\"themes/$thename/images/logo.gif\" alt=\""._WELCOMETO." $sitename\" border=\"0\" height=\"100\" width=\"350\"></td>\n</tr>\n"
        ."</table>\n";
}
 
    echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"$thewidth\" border=\"0\" align=\"center\" bgcolor=\"#fefefe\">\n"
        ."<tr>\n<td bgcolor=\"$textcolor1\" colspan=\"3\"><IMG src=\"themes/$thename/images/pixel.gif\" width=\"1\" height=\"1\" alt=\"\" border=\"0\" hspace=\"0\"></td>\n</tr>\n"
        ."<tr bgcolor=\"$bgcolor1\">\n<td align=\"left\" width=\"33%\"><font size=\"2\" color=\"#363636\">\n";
    if ($username == $anonymous) {
        echo "&nbsp;<a href=\"user.php?op=new_user\">"._NEWUSER."</a></b> / <b><a href=\"user.php\">"._USERLOGIN."</a>\n";
    } else {
        echo "&nbsp;"._TWELCOME." $username: <a href=\"user.php\">"._TACCOUNT."</a> | <a href=\"user.php?op=logout\">"._LOGOUT."</a>";
    }
    echo "</font></td>\n"
        ." <td align=\"center\" width=\"34%\"><font size=\"2\" color=\"#363636\">\n";
    $result = sql_query("select type, var, count from $prefix"._counter." order by type desc", $dbi);
    while(list($type, $var, $count) = sql_fetch_row($result, $dbi)) {
        if(($type == "total") && ($var == "hits")) {
            $total = $count;
            echo  ""._WERECEIVED." $total "._PAGESVIEWS." $startdate\n";
        }
    }
    echo "</font></td>\n"
        ."<td align=\"right\" width=\"33%\"><font size=\"2\">\n";
        $numrows = sql_num_rows(sql_query("select uid from $prefix"._users."", $dbi), $dbi);
    echo "&nbsp;</font>\n</td>\n</tr>\n"
        ."<tr>\n<td bgcolor=\"$textcolor1\" colspan=\"3\"><IMG src=\"themes/$thename/images/pixel.gif\" width=\"1\" height=\"1\" alt=\"\" border=\"0\" hspace=\"0\"></td>\n"
        ."</tr>\n</table>\n"
        ."<table width=\"$thewidth\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\"><tr valign=\"top\">\n"
        ."<td><img src=\"themes/$thename/images/pixel.gif\" width=\"1\" height=\"5\" border=\"0\" alt=\"\"></td></tr></table>\n"
        ."<table width=\"$thewidth\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\"><tr valign=\"top\">\n"
        ."<td width=\"160\" valign=\"top\">\n";
    blocks(left);
    echo "</td><td><img src=\"themes/$thename/images/pixel.gif\" width=\"5\" height=\"1\" border=\"0\" alt=\"\"></td><td width=\"100%\" bgcolor=\"$bgcolor1\">\n";
    if ($banners) {
        OpenTable2();
        echo "<center>";
        echo ads(0);
        echo "</center>";
        CloseTable2();
        echo "<br>";
    }
}
I need to put the code:

Code: Select all

if (banners) { echo ads(0); }
up into the table containing the logo.

Code: Select all

else {
    echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"$thewidth\" border=\"0\" align=\"center\">\n"
        ."<tr>\n<td background=\"themes/$thename/images/logobg.gif\"><img src=\"themes/$thename/images/logo.gif\" alt=\""._WELCOMETO." $sitename\" border=\"0\" height=\"100\" width=\"350\">[b][color=#BF0000]NEED BANNERS HERE[/color][/b]</td>\n</tr>\n"
        ."</table>\n";


Here is what I tried to do:

Code: Select all

else {
    echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"$thewidth\" border=\"0\" align=\"center\">\n"
        ."<tr>\n<td background=\"themes/$thename/images/logobg.gif\"><img src=\"themes/$thename/images/logo.gif\" alt=\""._WELCOMETO." $sitename\" border=\"0\" height=\"100\" width=\"350\"><php? if (banners) {echo ads(0); } ?></td>\n</tr>\n"
        ."</table>\n";
Didn't work. Any help would be greatly appreciated.

Re: PHP code help

Posted: Tue Jul 22, 2008 3:47 pm
by strangenet
I know someone knows how to do this...

Re: PHP code help

Posted: Tue Jul 22, 2008 4:12 pm
by omniuni

Code: Select all

else {
 echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"$thewidth\" border=\"0\" align=\"center\">\n"
 ."<tr>\n<td background=\"themes/$thename/images/logobg.gif\"><img src=\"themes/$thename/images/logo.gif\" alt=\""._WELCOMETO." $sitename\" border=\"0\" height=\"100\" width=\"350\">";
if (banners) {echo ads(0); }
echo "</td>\n</tr>\n</table>\n";
You are already in PHP, you don't need the tags. Try the above.

Also, are you quite sure if(banners) is right? It's not something like if($banners) ?

Re: PHP code help

Posted: Tue Jul 22, 2008 6:24 pm
by strangenet
I tried the above, but when loading the page it was blank. I tried a few variations of that but still can't get it to work.

Edit: it was $banners I messed up when posting, but I fixed it in the code

Re: PHP code help

Posted: Tue Jul 22, 2008 8:21 pm
by omniuni
I would carefully check the statement to make sure that everything is escaped correctly. If it's all semantically correct, I'm sorry, I'm out of suggestions at the moment.

Re: PHP code help

Posted: Tue Jul 22, 2008 9:23 pm
by strangenet
well I got it pretty close by changing some of the code. It seems the original coding was using \n" to escape??? I don't know, that must be some advanced style of coding that I don't understand.

I just went back and replaced the . " \n" with plain old echo " ";

I got it really close to where i want the ads, but the ads are below the logo.gif and I want it beside the logo.gif. The logo is only 350px wide and the ads are 468 so there should be plenty of space left for the ads to fit next to the logo on my monitor atleast, I might go back and resize the logo to make it fit into the 800px so it should work on nearly all screens.

Any suggestions?

here is the new code:

Code: Select all

else {
    echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"$thewidth\" border=\"0\" align=\"center\">";
    echo "<tr>\n<td background=\"themes/$thename/images/logobg.gif\"><img src=\"themes/$thename/images/logo.gif\" alt=\""._WELCOMETO." $sitename\" border=\"0\" height=\"100\" width=\"350\">";
         if ($banners) {echo ads(0);}
   echo "</td>\n</tr>";
   echo "</table>";
}

Re: PHP code help

Posted: Wed Jul 23, 2008 11:22 am
by strangenet
Anyone have anymore on this???

I need to get this done tonight

Re: PHP code help

Posted: Wed Jul 23, 2008 11:49 am
by mabwi
What's the HTML output look like? It seems the problem is the positioning of the elements, but everything is appearing correctly?

Re: PHP code help

Posted: Wed Jul 23, 2008 1:49 pm
by strangenet
I figured by changing the table's align "center" to "left" would fix it but it didn't
Here is what the HTML output looks like:

Code: Select all

 
<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td background="themes/theme2/images/logobg.gif"><img src="themes/theme2/images/logo.gif" alt="Welcome to Monticello Now" border="0" width="350" height="100">
 
 
<center><a href="index.php?op=ad_click&bid=1" target="_blank"><img src="/banners/hosting.gif" alt="Click Here" title="Click Here" border="0"></a></center></td></tr></tbody></table>

Re: PHP code help

Posted: Wed Jul 23, 2008 3:37 pm
by mabwi
Change your output to this:

Code: Select all

  <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">  <tbody>    <tr>      <td background="themes/theme2/images/logobg.gif">        <img src="themes/theme2/images/logo.gif" alt="Welcome to Monticello Now" border="0" width="350" height="100">      </td>      <td>        <center>        <a href="index.php?op=ad_click&bid=1" target="_blank">          <img src="/banners/hosting.gif" alt="Click Here" title="Click Here" border="0">        </a>        </center>      </td>    </tr>  </tbody></table>
Note that the logo & banner are in separate td's.

Re: PHP code help

Posted: Wed Jul 23, 2008 4:48 pm
by strangenet
mabwi wrote:Change your output to this:

Code: Select all

  <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">  <tbody>    <tr>      <td background="themes/theme2/images/logobg.gif">        <img src="themes/theme2/images/logo.gif" alt="Welcome to Monticello Now" border="0" width="350" height="100">      </td>      <td>        <center>        <a href="index.php?op=ad_click&bid=1" target="_blank">          <img src="/banners/hosting.gif" alt="Click Here" title="Click Here" border="0">        </a>        </center>      </td>    </tr>  </tbody></table>
Note that the logo & banner are in separate td's.
Thanks for the tip, I tried adding another TD before but I must have escaped it wrong or something. I just tried it again and it works fine now :D :drunk:

Thanks for the help guys.

Here is the final code:

Code: Select all

else {
    echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" border=\"0\">";
    echo "<tr><td width=\"350\"><img src=\"themes/$thename/images/logo.gif\" alt=\""._WELCOMETO." $sitename\" border=\"0\" height=\"100\" width=\"350\"></td>";
    echo "<td background=\"themes/$thename/images/logobg.gif\">";
    if ($banners) {echo ads(0);}
   echo "</td></tr></table>";
}