jaimec Posted January 27, 2007 Share Posted January 27, 2007 Hello, I'm new to PHP and would really appreciate some help with a simple banner scriptHere's the problem I'm stuck onOn 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)<?phpif (@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:$banneridthen 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, etcthen 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 etcI 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. Quote Link to comment Share on other sites More sharing options...
fert Posted January 27, 2007 Share Posted January 27, 2007 http://us2.php.net/manual/en/reserved.variables.phpRead about $_GET and $_POST Quote Link to comment Share on other sites More sharing options...
jaimec Posted January 27, 2007 Author Share Posted January 27, 2007 Thanks for the quick reply, and thanks for the link.Please forgive my ignorance but do I use the $_GET command on the results page to bring up the numerical value of jids - then create the new $bannerid variable accordingly? Quote Link to comment Share on other sites More sharing options...
fert Posted January 27, 2007 Share Posted January 27, 2007 It depends on the form's method Quote Link to comment Share on other sites More sharing options...
jaimec Posted January 27, 2007 Author Share Posted January 27, 2007 the method is POST Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 27, 2007 Share Posted January 27, 2007 So using some logic, let's think if $_POST or $_GET would be more appropriate ;) Quote Link to comment Share on other sites More sharing options...
jaimec Posted January 28, 2007 Author Share Posted January 28, 2007 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 workI'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=1so then the link to pull the banner from the server would have" zone:<?php echo $bannerlink ?> " rather than the original " zone:1 " Quote Link to comment Share on other sites More sharing options...
jaimec Posted January 28, 2007 Author Share Posted January 28, 2007 I've moved on a little$bannerlink = ($bannerid == 10) ? 1 : 0;gives an if/else valueI 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.