ow-design Posted February 25, 2007 Share Posted February 25, 2007 Hi Everyone, hope you can help me! I am 16 yrs old and design websites for companies. I have a problem with a database i am doing for a recruitment company site. you can view the non-ready one here... www.ow-design.co.uk/clients/martin_pooley/jobs.php Basically i want all the jobs listed on the page listed above.. which is working fine... but i need a link after each job title with more info. This link will then go to a page where the job title will be displayed again but with a job description also. It all has to work automatically . i.e when the user of this website enters a new job via a html form the listings will update aswell as the more info links and the more info page. The links would probably have to work on id as this is unique to each job listing. Hope this makes sense Thanks.! Quote Link to comment Share on other sites More sharing options...
Archadian Posted February 25, 2007 Share Posted February 25, 2007 just pass the ID from the database into the URL and make the job title a link, make 1 script that uses the $_GET['id'] and displays the detailed info from the DB using SELECT job FROM jobs where id = "$id'") of course setting $id = $_GET['id']; I hope this makes sense. If this doesn't make sense i'll try to better explain it and maybe write some quick code as an example. Quote Link to comment Share on other sites More sharing options...
ow-design Posted February 25, 2007 Author Share Posted February 25, 2007 Thanks for your quick reply!! Please could you give me an example as it helps me to solve what i am doing quicker. Much appreciated! Thanks! Quote Link to comment Share on other sites More sharing options...
Archadian Posted February 25, 2007 Share Posted February 25, 2007 ok ur table: echo "<table align=\"center\" valign=\"top\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">"; echo "<tr>"; echo "<td align=\"center\" width=\"10%\" height=\"50\">Ref #</td>"; echo "<td align=\"center\" width=\"90%\" height=\"50\">Job Title</td>"; echo "</tr>"; $sql = mysql_query("SELECT id, job_title FROM jobs") or die("Couldn't connect to the Jobs table"); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job = $row['job_title']; $wbsite = "http://www.yoursite.com/"; echo "<tr>"; echo "<td align=\"center\" width=\"10%\" height=\"50\">" . $id . "</td>"; echo "<td align=\"left\" width=\"90%\" height=\"50\"><a href=\"" . $wbsite . "jobdetails.php?action=vd&id=" . $id . ">" . ucfirst($job) . "</a></td>"; echo "</tr>"; } echo "</table>"; ok that would make the job title a link as the name of the job title. this is your details.php: if ($_GET['action'] = "vd") { //Remember the jobdetails.php?action=vd in your URL on the above code? This checks to see if its valid. $id = $_GET['id'] // the &id=" . $id . " is set to $_GET['id'] ['id'] being the same id in the URL $sql = mysql_query("SELECT * FROM jobs WHERE id = '$id'"); // pulls the row with the same ID number as it is in the URL $row = mysql_fetch_array($sql); //your table here with your details with the $row[] array with the info from the database. I hope this helps. Quote Link to comment Share on other sites More sharing options...
ow-design Posted February 25, 2007 Author Share Posted February 25, 2007 Thanks, i am getting the following message of jobdetails.php Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/deswo/public_html/clients/martin_pooley/jobdetails.php on line 13 Line 13 is: while($row = mysql_fetch_array($result)) Quote Link to comment Share on other sites More sharing options...
Archadian Posted February 25, 2007 Share Posted February 25, 2007 are you using the code? I didn't check it for errors just put it down as a guide Quote Link to comment Share on other sites More sharing options...
ow-design Posted February 25, 2007 Author Share Posted February 25, 2007 I was taking a lot of info from the code and trying to adjust it, i am not great at php... yet Would you write me the code please for my jobs page & jobdetails page?? On jobs page i have fields [id] & [name] plus the more info link on jobdetails i would have [id] & [name] & [description] I know it's asking a lot but i am really dtuck and need this complete by tonight, i have tried everything and am getting nowhere := Thanks Ollie Quote Link to comment Share on other sites More sharing options...
superuser2 Posted February 25, 2007 Share Posted February 25, 2007 Can we see your whole jobdetails.php? Also, did you remember to connect to your database? That could be the problem, or it might not be the right table name. Let's check for mysql_error: <?php if(!$sql) { die("Mysql error: " . mysql_error()); } ?> Quote Link to comment Share on other sites More sharing options...
ow-design Posted February 25, 2007 Author Share Posted February 25, 2007 Nope definatly connected to database, this was not the problem Any other ideas? Quote Link to comment Share on other sites More sharing options...
superuser2 Posted February 25, 2007 Share Posted February 25, 2007 And adding the code I just gave you right after $sql = mysql_query("SELECT * FROM jobs WHERE id = '$id'")? Try it, I bet you have a mysql error. Quote Link to comment Share on other sites More sharing options...
ow-design Posted February 25, 2007 Author Share Posted February 25, 2007 I have deleted the php code on this jobdetails.php page. Is theiranyone that would be kind enough to give me the code to help me out with what i would like to do.?? Thanks Quote Link to comment Share on other sites More sharing options...
superuser2 Posted February 25, 2007 Share Posted February 25, 2007 OK what is the name of the jobs table? Quote Link to comment Share on other sites More sharing options...
ow-design Posted February 25, 2007 Author Share Posted February 25, 2007 What do you mean, what is the name? Sorry i am quite new to php Quote Link to comment Share on other sites More sharing options...
superuser2 Posted February 25, 2007 Share Posted February 25, 2007 Do you have a mysql table that holds jobs? Quote Link to comment Share on other sites More sharing options...
ow-design Posted February 25, 2007 Author Share Posted February 25, 2007 Yes it is called deswo_list does that help.? Quote Link to comment Share on other sites More sharing options...
dswain Posted February 25, 2007 Share Posted February 25, 2007 You have to make sure when you run the query you're checking this table. For example "Select * from deswo_list where id='$id'" needs to aim at that table in particular. Check that out firstly. The idea is basically you want that query to get all of the information from the table and pushed into an array. Once you do that, then you want to output this information (using a while loop and echo statements) so the users can see the current jobs in the database. Quote Link to comment Share on other sites More sharing options...
superuser2 Posted February 25, 2007 Share Posted February 25, 2007 Yes thank you. That's why Archadian's solution wasn't working. To list all your jobs: echo "<table align=\"center\" valign=\"top\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">"; echo "<tr>"; echo "<td align=\"center\" width=\"10%\" height=\"50\">Ref #</td>"; echo "<td align=\"center\" width=\"90%\" height=\"50\">Job Title</td>"; echo "</tr>"; $sql = mysql_query("SELECT id, job_title FROM deswo_list") or die("Couldn't connect to the Jobs table"); while ($row = mysql_fetch_array($sql)) { $id = $row['id']; $job = $row['job_title']; $wbsite = "http://www.yoursite.com/"; echo "<tr>"; echo "<td align=\"center\" width=\"10%\" height=\"50\">" . $id . "</td>"; echo "<td align=\"left\" width=\"90%\" height=\"50\"><a href=\"" . $wbsite . "jobdetails.php?action=vd&id=" . $id . ">" . ucfirst($job) . "</a></td>"; echo "</tr>"; } echo "</table>"; We changed 'jobs' to 'deswo_link'. Now let's try it again. Quote Link to comment Share on other sites More sharing options...
ow-design Posted February 25, 2007 Author Share Posted February 25, 2007 okay thanks. i have put that in, please look: http://www.ow-design.co.uk/clients/martin_pooley/jobs.php their are a few problems i would like to sort out, as you can see the jobs are all on one row, i would like them on individual rows with their links working. How can i make this happen? Really appreciate all your help! Ollie Quote Link to comment Share on other sites More sharing options...
superuser2 Posted February 25, 2007 Share Posted February 25, 2007 Wow that's messed up. Let me try to rewrite that: <table> <tr><td><b>Ref #</b></td><td><b>Job Title</b></td></tr> <?php //Put your db connection stuff here $sql = mysql_query("SELECT id, job_title FROM deswo_list") or die("Couldn't connect to the Jobs table"); while ($row = mysql_fetch_array($sql)) { echo "<tr><td>{$row['0']}</td><td>{$row['1']}</td></tr>"; } ?> </table> I didn't test that, but try it and let me know how it turns out. Quote Link to comment Share on other sites More sharing options...
ow-design Posted February 25, 2007 Author Share Posted February 25, 2007 Thanks thats a bit better: please look: http://www.ow-design.co.uk/clients/martin_pooley/jobs_old.php But the links are not working? I am really sorry to keep asking all these questions but i am brand new to php Quote Link to comment Share on other sites More sharing options...
magnetica Posted February 25, 2007 Share Posted February 25, 2007 What is the code you have for the line: <a href="http://www.ow-design.co.uk/clients/martin_pooley/jobdetails.php?action=vd&id=> It would seem that if you are echo'ing this out that there is one slight speech mark or single quote that you have left out Quote Link to comment Share on other sites More sharing options...
magnetica Posted February 25, 2007 Share Posted February 25, 2007 Sorry i mean this line: a href="http://www.ow-design.co.uk/clients/martin_pooley/jobdetails.php?action=vd&id= Quote Link to comment Share on other sites More sharing options...
ow-design Posted February 25, 2007 Author Share Posted February 25, 2007 line is: echo "<td align=\"left\" width=\"90%\" height=\"50\"><a href=\"" . $wbsite . "jobdetails.php?action=vd&id=" . $id . ">" . ucfirst($job) . "</a></td>"; Quote Link to comment Share on other sites More sharing options...
magnetica Posted February 25, 2007 Share Posted February 25, 2007 Is that [/url] actually in your code or have you tried to wrap it on here? Quote Link to comment Share on other sites More sharing options...
ow-design Posted February 25, 2007 Author Share Posted February 25, 2007 no thats not oin my code, this forum has automatically put that in. 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.