Jump to content

Newbie Here - Need help linking..


virtuexru

Recommended Posts

OK. So I have a PHP/MySQL database setup.

The table in question is a table for job orders.. so basically it has ID# .. Job title, Description, etc..

Now my question is how do i make a link to a job based on the title and such,

so something like www.example.com/view.php?id=??

but so it does the linking automatically depending on what ID/Title for the job it gets because right now I'm just pulling up the information and linking the link manually..

[code]    

<?
include 'config.php';
include 'opendb.php';
?>
                                <?
$query  = "SELECT title, category, salary, location FROM joborder WHERE number='859'";
$result = mysql_query($query);
while(list($title,$category,$salary,$location)= mysql_fetch_row($result))
{
echo "<a href="example.com"><b>$title</b></a>" . " - $category" . " , $location" . ", $salary";
}
?>
[/code]
Link to comment
Share on other sites

$_GET['id'] .. this will pull the number after id= .. page.php?id=[b]1[/b]

so then its like this

$id = $_GET['id'];
$query = "SELECT title, category, salary, location FROM joborder WHERE id='" . $_GET['id'] . "'"; // Or number if thats the id

works like that with the title too $_GET['title'] would get the title= from the link then "WHERE title='" . $_GET['title'] . "'"
Link to comment
Share on other sites

Yea, i have something like that already..

I'm talking about a previous link without id?= in the address. I want to link the ID?= into the link bar from index.php.

This is the view.php?id= code

<?
$result = mysql_query("SELECT * FROM joborder WHERE number=$id");
$myrow = mysql_fetch_array($result);
echo "<h2>Job Title: ".$myrow["title"]; echo "</h2>";
echo "<br><b>Category:</b> ".$myrow["category"];
echo "<br><b>Description:</b> ".$myrow["description"];
echo "<br><b>Salary:</b> ".$myrow["salary"];
echo "<br><b>Position:</b> ".$myrow["position"];
echo "<br><b>Location:</b> ".$myrow["location"];
echo "<p><b>Details:</b><p> ".$myrow["details"]; echo "</p></p>";
?>
Link to comment
Share on other sites

Im not certain if i understand exactly what ur tryin to do but here goes

Basically u want the rows generated by the mysql result to be clickable by headers (title, id, description, salary, location, etc) and all these headers must point to the single id whatever that is

Am i on the right track
Link to comment
Share on other sites

if im right try this code

[code]
<?
include 'config.php';
include 'opendb.php';
?>
    <?

    $trackid= trim($_REQUEST(['id']);
      $trackid = mysql_real_escape_string($trackid);

$query  = "SELECT title, category, salary, location FROM joborder WHERE number='$trackid'";
$result = mysql_query($query);
while(list($id,$title,$category,$salary,$location)= mysql_fetch_row($result))
{
echo "<a href="example.com?id='$id'"><b>$title</b></a>" . " - $category" . " , $location" . ", $salary";
}
?>

[/code]
Link to comment
Share on other sites

This link [url=http://www.php.net/manual/en/reserved.variables.php]http://www.php.net/manual/en/reserved.variables.php[/url] can explain better i think. But basically it allows you to retrieve the variable $id whether using Post in the case of a form or Get in the case of a url like your doing
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.