greens85 Posted April 20, 2009 Share Posted April 20, 2009 Hi all, I currently have a situation where I have a main site (advertsing jobs) and a few partner sites which also carry these job ads. What i want is to have a 'Apply Now' link on the partner site that then takes the user to my main site and drops them at the relevant job ad! I'm not quite sure how to make this work, can anyone offer me any advice? This is the code that drags the ads out of my database. I have also commented the line where i am trying to link it to the mainsite. <? $sql = "SELECT * FROM jobs WHERE CS = 'Yes' ORDER BY jobid"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_array ($result)) { echo '<font color="#246494"><strong>Job Title:</strong></font> '; echo $row['position']; echo '<br/>'; echo '<font color="#246494"><strong>Description:</strong></font> '; echo $row['description']; echo '<br/>'; echo '<br/>'; echo '<font color="#246494"><strong>Job Reference:</strong></font> '; echo $row['jobref']; echo '<br/>'; echo '<font color="#246494"><strong>Hours:</strong></font> '; echo $row['hour']; echo '<br/>'; echo '<font color="#246494"><strong>Location:</strong></font> '; echo $row['subcounty']; echo '<br/>'; echo '<font color="#246494"><strong>Working Term:</strong></font> '; echo $row['contract']; echo '<br/>'; echo '<font color="#246494"><strong>Salary:</strong></font> '; echo $row['salary']; echo '<br/>'; echo '<font color="#246494"><strong>Application Deadline:</strong></font> '; echo $row['deadline']; echo '<br />'; <!-- this is what i have tried to make it work echo '<a href="http://www.mainsite.com/jobseekers/info.php?jobid=<?=$row[jobid]?>">Apply Now</font></a>'; end of attempted link --> echo '<br/>'; echo '<hr style="background-color: rgb(204, 204, 204);" width="100%" size="1" noshade="noshade" color="#246494">'; } } } ?> Link to comment https://forums.phpfreaks.com/topic/154853-solved-php-url/ Share on other sites More sharing options...
trq Posted April 20, 2009 Share Posted April 20, 2009 Your already within php so theres no need for more php tags. eg; echo '<a href="http://www.mainsite.com/jobseekers/info.php?jobid=<?=$row[jobid]?>">Apply Now</font></a>'; should be.... echo '<a href="http://www.mainsite.com/jobseekers/info.php?jobid=' . $row['jobid'] . '>Apply Now</font></a>'; Link to comment https://forums.phpfreaks.com/topic/154853-solved-php-url/#findComment-814427 Share on other sites More sharing options...
jackpf Posted April 20, 2009 Share Posted April 20, 2009 You could use javascript. $jobid = $_GET['jobid'] + 1; //in theory this only works if your id starts from 1 echo '<script> function blah() { document.forms[0].selectname.'.$jobid.'.selected; } </script>'; Link to comment https://forums.phpfreaks.com/topic/154853-solved-php-url/#findComment-814429 Share on other sites More sharing options...
greens85 Posted April 20, 2009 Author Share Posted April 20, 2009 Hi Thorpe, I tried that code but it makes all the lines e.g. job title, salary etc a link and removes the apply now link. Have i misunderstood what you have tried to show me? Thanks Link to comment https://forums.phpfreaks.com/topic/154853-solved-php-url/#findComment-814433 Share on other sites More sharing options...
greens85 Posted April 20, 2009 Author Share Posted April 20, 2009 If i have the following line: echo '<a href="http://www.mysite.com/jobseekers/info.php?jobid=8?>">Apply Now</font></a>'; It drops me on the right page at the job ad, the problem is that i am dragging out multiple job ads in an array, therefore each one is going to have a different id. Is there anyway to call a certain id, depending on what job ad you want to view? Appologies for my lack of knowledge here, im relativley new to PHP! Link to comment https://forums.phpfreaks.com/topic/154853-solved-php-url/#findComment-814439 Share on other sites More sharing options...
trq Posted April 20, 2009 Share Posted April 20, 2009 A simple example. p1.php <a href="p2.php?id=1">1</a> <a href="p2.php?id=2">2</a> <a href="p2.php?id=3">3</a> p2.php <?php if (isset($_GET['id'])) { echo "This is article number {$_GET['id']}"; } ?> Does that help at all? Link to comment https://forums.phpfreaks.com/topic/154853-solved-php-url/#findComment-814443 Share on other sites More sharing options...
greens85 Posted April 20, 2009 Author Share Posted April 20, 2009 Could this apply to one link? As I only have the code written once and it is repeated using an array? Therefore I couldnt write a 'a href' for each job. I have seen something similar done like this: <a href=<?=$fullurl?>/jobseekers/info.php?jobid=<?=$as[jobid]?>>View Full Details</font></a> When u rollover the link, it gives you the relevant id, this is what i was trying to emulate but with little success! Hope this makes sense! Link to comment https://forums.phpfreaks.com/topic/154853-solved-php-url/#findComment-814453 Share on other sites More sharing options...
greens85 Posted April 20, 2009 Author Share Posted April 20, 2009 Hi all, I have now solved this problem. Incase anyone else needs this for reference in the future, this is the final code: <a href="http://www.mysite.com/jobseekers/info.php?jobid=<?=$row['jobid']?>">Apply Now</a> I basically close the php tags before i wrote the link, the added some php for the jobid. Not sure how u add solved to a thread, so if admin could do that for me it would be great. Thanks to all who replied Link to comment https://forums.phpfreaks.com/topic/154853-solved-php-url/#findComment-814466 Share on other sites More sharing options...
jackpf Posted April 20, 2009 Share Posted April 20, 2009 Down at the bottom. Link to comment https://forums.phpfreaks.com/topic/154853-solved-php-url/#findComment-814467 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.