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
https://forums.phpfreaks.com/topic/26369-newbie-here-need-help-linking/
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'] . "'"
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>";
?>
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
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]
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

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.