Jump to content

using Variable from db - Smarty template system


bulldog5046

Recommended Posts

hi guys,

i have a page with offers on, within one of the links for this i need to be able to pull the variable from the database and for it to me parsed which at present it isnt.

its inserting it perfectly fine i just can get my head around how to parse it as i have no examples else where on the site.

this is offers.php
[code]<?php

$PageTitle = 'Online offers';

include('inc/main.inc');

function insert_MAIN() {
    global $WAS_POST, $_VARS, $_ERRORS, $X_SESSION;

    if (!$X_SESSION['user_id']) {
        header('Location: index.php'); exit;
}
    if (!$_VARS['id'] || $X_SESSION['user_id'] != 1) {
        $_VARS['id'] = $X_SESSION['user_id'];
}


///check if account is on hold
$HELD=dbFastGet("SELECT held FROM users WHERE id=$_VARS[id]");

    if ($HELD == 1) {
        header('Location: suspended.php'); exit;
    }


    $smarty = new XSmarty;

    $offers = dbExec("SELECT * FROM offers ");
    $offer = dbFetchResult($offers);

    $smarty->assign('offers', $offer);

    $smarty->display('pages/offers.tpl', null, true);

}

?>[/code]

and this is offers.tpl
[code]<!--offers block -->
{assign var="n" value=1}

<br>
<table width="692" border="0" cellspacing="0" cellpadding="0">
  <tr>
{foreach from=$offers item=offer key=key}
    <td>
      <!--1 of 2 offers block -->
      <table width="341" cellspacing="0" cellpadding="0">
        <tr>
          <td><img src="pic/8.gif" width="11" height="11"></td>
          <td background="pic/9.gif"><img src="pic/spacer.gif" width="1" height="1"></td>
          <td><img src="pic/10.gif" width="11" height="11"></td>
        </tr>
        <tr>
          <td background="pic/15.gif">&nbsp;</td>
          <td valign="top" bgcolor="#FAFAFA">&nbsp;&nbsp;&nbsp;&nbsp;<strong>{$offer.1}<br>
            <br>
            </strong>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td valign="top" class="small">{$offer.3}<br>
                  <br>
  <br>
                  <a href="{$offer.4}" class="blueoff">{$offer.1}</a></td>
                <td width="180" valign="top"><a href="{$offer.4}"><img src="{$offer.2}" width="120" height="60" border="0"></a></td>
              </tr>
            </table>
            <strong> </strong></td>
          <td background="pic/12.gif"><img src="pic/spacer.gif" width="1" height="1"></td>
        </tr>
        <tr>
          <td width="11" valign="top"><img src="pic/14.gif" width="11" height="11"></td>
          <td background="pic/13.gif"><img src="pic/spacer.gif" width="1" height="1"></td>
          <td width="11"><img src="pic/11.gif" width="11" height="11"></td>
        </tr>
      </table>
      <!--/1 of 2 offers block  -->
    </td>
    <td><img src="pic/spacer.gif" width="20" height="1"></td>
{if $n == 0}
  </tr>
</table>
<br>
<table width="692" border="0" cellspacing="0" cellpadding="0">
  <tr align=center>
{assign var="n" value=1}
{else}
{assign var="n" value=0}
{/if}
{/foreach}
  </tr>
</table>
<br>
<!--/1 of 1 offers block  -->
<!--/offers block -->[/code]

and here is the URL in the database
[code]https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=admin%40freepsp%2eco%2euk&custom=$_VARS[id]&item_name=Donate%20%c2%a310%20to%20FreePSP&item_number=DON10&amount=10%2e00&no_shipping=2&no_note=1&tax=0&currency_code=GBP&lc=GB&bn=PP%2dDonati[/code]

as you can see i have used '$_VARS[id]' but though no experimenting can i get it to work. i have also tried using '$session.user_id' without success.

does anyone know why? or have any ideas atall  ???

Cheers,
Ryan Edge
  • 9 months later...

I have about the same script. The problem is in your php.ini sendmail. Also if you can't add offers, you will need to add points table to your offers in mysql database.

 

I never did get it working right. If your intrested, I made my own offers script That I'll let you have for 40.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.