Jump to content

[SOLVED] Urgently need help!! PHP Link


ow-design

Recommended Posts

  • Replies 69
  • Created
  • Last Reply

Try this but don't forget to edit the SELECT call for your table data!

<?php


include("db.php");

// Get a connection to the database
  $jobid=$_GET['id'];
  $cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);


<table width="600" border="0">;
<?php
  if (is_numeric($jobid)) {
    $sql="SELECT * FROM jobs WHERE `jobid`='$jobid'";
    $fetch=mysql_fetch_assoc(mysql_query($sql));
    echo '<tr><td><strong>Job title:</strong></td><td>'.$fetch['name'].'</td></tr>';
    echo '<tr><td><strong>Details:</strong></td><td>'.$fetch['description'].'</td></tr>';
  } else {
    echo '<tr><td>I am unable to locate that job - sorry!</td></tr>
  }
?>
  </table>
  </html>

Oops!

<?php


include("db.php");

// Get a connection to the database
  $jobid=$_GET['id'];
  $cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
?>

<table width="600" border="0">
<?php
  if (is_numeric($jobid)) {
    $sql="SELECT * FROM jobs WHERE `jobid`='$jobid'";
    $fetch=mysql_fetch_assoc(mysql_query($sql));
    echo '<tr><td><strong>Job title:</strong></td><td>'.$fetch['name'].'</td></tr>';
    echo '<tr><td><strong>Details:</strong></td><td>'.$fetch['description'].'</td></tr>';
  } else {
    echo '<tr><td>I am unable to locate that job - sorry!</td></tr>
  }
?>
  </table>
  </html>

In the code i gave you all you have to do is make a table to show the details on jobdetails.php and in the mysql_query() you have to put the name of the columns and the name of the table where the info on the jobs are. When i said my code wouldn't work i meant you have to put in the correct table names :)

Edit this line in the first script from this:

	<a href="jobdetails.php?<?php echo $fetch["id"]?>">More About Vacancy</a></font></td>

to this:

	<a href="jobdetails.php?id=<?php echo $fetch["id"]?>">More About Vacancy</a></font></td>

My mistake again!

ok, looking better but am geting following message:


Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/deswo/public_html/clients/martin_pooley/jobdetails.php on line 15
[b]Job title:  
Details: [/b] 

 

line 15 reads:


    $fetch=mysql_fetch_assoc(mysql_query($sql));

You'll often find that the error often lies in a previous line or two before the line you get told it's in.

 

As I said earlier, the error is actually in the line that assigns the variable $sql the SELECT call - change it to suit your database.

shouldn't it be this:

 

$fetch=mysql_fetch_assoc($sql);

Sort of but we need to go one line before that because the SELECT call itself is wrong. ow-design hasn't changed it to suit his database and has used the default one I posted as an example.

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.