Jump to content

New to PHP - Would appreciate some help with a simple banner script


jaimec

Recommended Posts

Hello, I'm new to PHP and would really appreciate some help with a simple banner script

Here's the problem I'm stuck on

On the home page of the site I'm working on there's a simple form where the user can select one option. The related section of code reads:

        <SELECT name="jids[]" multiple size="5">
        <OPTION selected value=00>All Categories</OPTION>
        <option value="10">Advertising/Marketing</option>
<option value="11">Creative/Graphic Design</option>
<option value="12">Games Industry</option>
<option value="13">IT & Telecoms</option>
</SELECT>


Once the form has been submitted, the user is then directed to a job results page - everything here is working without problems. The problem I now have the need to add a piece of code on the results page that calls up a banner advertisement from a seperate php script and database (code below)


<?php
if (@include(getenv('DOCUMENT_ROOT').'/ads/phpadsnew.inc.php')) {
        if (!isset($phpAds_context)) $phpAds_context = array();
        $phpAds_raw = view_raw ('zone:1', 0, '', '', '0', $phpAds_context);
        echo $phpAds_raw['html'];
    }
?>



What I'd like to write is a snippet of code that essentially creates a new variable:

$bannerid

then reads value of jids[] - and if the user has selected "Advertising/Marketing (10") then $bannerid = 1,
if the user has selected "Creative/Graphic Design (11)" then $bannerid = 2 etc, etc

then in the php script that calls up the banner I need to replace

'zone:1'

with 'zone: and the value of $bannerid' so specific ads can be called up relevant to the users selection - 1 for banners related to advertising/design jobs, 2 for Creative/Graphic Design jobs etc

I know it seems simple but as I'm new to php I just can't get the thing to work.

Any advice would be greatly appreciated.
Link to comment
Share on other sites

so the code

$bannerid=$_GET['jids'][0];

should give me $bannerid with the relevant value ??

just done a test with

$bannerid=$_GET['jids'][0];
print $bannerid;

and it seems to work


I'm taking this a step at a time here - (I mainly work with flash & photoshop but have had this dropped on me at the last minute)

now should I code an if $bannerid=10 then $bannerlink=1

so then the link to pull the banner from the server would have

"  zone:<?php echo $bannerlink ?>  " rather than the original "  zone:1  "
Link to comment
Share on other sites

I've moved on a little

$bannerlink = ($bannerid == 10) ? 1 : 0;

gives an if/else value

I just need to pass this to the banner code ensuring the relevant banner appears

"  zone:<?php echo $bannerlink ?>  " rather than the original "  zone:1  " doesn't seem to work.

Any advice greatly appreciated
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • 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.