Jump to content

Display Promotion Codes on the main page without editing the template


Recommended Posts

Hello,

 

I was working on a way to make so when I add a new Promotion Code in the WHMCS Admin panel it instantly updates on the main page with all the codes.

 

The Script is written in PHP by me I hope you like it

 

 

<?php

mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());

$result = mysql_query("SELECT * FROM tblpromotions") 
or die(mysql_error());  

echo "<table border='0' style='color: #FFF'>";
echo "<tr> <th>Promocode</th> <th>Discount</th> <th>Expiration</th> </tr>";

while($row = mysql_fetch_array( $result )) {


echo "<tr><td>"; 
echo $row['code'];
echo "</td><td>"; 
echo $row['value'];
echo $row['type'];
echo "</td><td>"; 
echo $row['expirationdate'];
echo "</td></tr>"; 
} 

echo "</table>";



?>

 

 

-John

Link to comment
Share on other sites

Why not make this a plugin for use the the templates, in the "homepage.tpl" file you could add a nicely styled section below the contents.

 

{php}

$result = mysql_query("SELECT * FROM tblpromotions")

or die(mysql_error());

 

echo "<table border='0' style='color: #FFF'>";

echo "<tr> <th>Promocode</th> <th>Discount</th> <th>Expiration</th> </tr>";

 

while($row = mysql_fetch_array( $result )) {

 

 

echo "<tr><td>";

echo $row['code'];

echo "</td><td>";

echo $row['value'];

echo $row['type'];

echo "</td><td>";

echo $row['expirationdate'];

echo "</td></tr>";

}

{/php}

 

It would make a nice plugin and would probably be used by many hosts!

Link to comment
Share on other sites

quick tweak to VE PORTAL, just cut and paste where you want this to go inside your homepage.tpl:

 

 

<P><h3 align="center">Promotion Codes</h3></P>

{php}

$result = mysql_query("SELECT * FROM tblpromotions")

or die(mysql_error());

echo "<table width='100%' bgcolor='#cccccc' cellspacing='1'>";

echo "<tr bgcolor='#efefef'> <th bgcolor='#efefef'>Promocode</th> <th bgcolor='#efefef'>Discount</th> <th bgcolor='#efefef'>Type</th> <th bgcolor='#efefef'>Expiration</th> </tr>";

while($row = mysql_fetch_array( $result )) {

echo "<tr bgcolor='#ffffff'><td>";

echo $row['code'];

echo "</td><td>";

echo $row['value'];

echo "</td><td>";

echo $row['type'];

echo "</td><td>";

echo $row['expirationdate'];

echo "</td></tr>";

}

{/php}

Edited by Cubeboy
Link to comment
Share on other sites

  • 11 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated