Hello all, i am having great difficulty in trying to get the job_id variable from the table that is displayed that will be passed into the next page and profile page information will be selected where he job_id (from previous page) is equal to the job_id of the profile.

In terms of my code below : you can see that the table is formed by selecting all the records in the "job" table from the database and for each row it finds, row of job data is added to the table.

What i am trying to do is when i click on a particular row it takes me to a page where the row that i clicked ons data is displayed on (in a sort of profile)

Can somebody help me in doing this?

I have tried various ways and cannot get it to work :shifty:
Any help would be greatly appreciated

Code: Job Table \/\/\/

<?

if ($log_in = true){
$db_name = "";
$table_name = "job";
$connection = @mysql_connect("localhost", "", "") or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
$sql = "SELECT * FROM $table_name";

$result = @mysql_query($sql) or die(mysql_error());


$numberofrows=mysql_num_rows($result);

$LOADcreateJOB1 = "$('#page_contents').load('profile_job.php');" ;


echo'

    <div id="rounded-corner">
            <p class="title">View Jobs</p>
                <table class="jobs">
                    <tr>
<th ><a class="table_header" >Job ID</a></th>
<th ><a class="table_header" >Job Name</a></th>
<th ><a class="table_header" >Company Name</a></th>
<th ><a class="table_header" >Comapny ID</a></th>
<th ><a class="table_header" >Job  Status</a></th>                      
<th ><a class="table_header" >% Complete</a></th>
<th ><a class="table_header" >Contractor</a></th>

</tr>';
                    while ($row = mysql_fetch_array($result)) 
            {       
                echo'   <tr>
<td class="table_results" id="' . $row['job_id'] . '" onclick=' . $LOADcreateJOB1 . '>' . $row['job_id'] . '</td>
<td class="table_results" href="index.php">' . $row['job_name'] . '</td>
<td class="table_results">' . $row['FK_company_id'] . '</td>
<td class="table_results">' . $row['FK_company_id'] . '</td>
<td class="table_results">' . $row['job_status'] . '</td>
<td class="table_results">' . $row['pcnt_complete'] . '</td>
<td class="table_results">' . $row['FK_contractor_id'] . '</td>
                            </tr>
        </div>';
}
            }
?>

<? echo'<html>
<head>
    <link href="forms_css.css" rel="stylesheet" type="text/css"  />
        <script type="text/javascript" src="jquery.js"></script>
    <link href="style.css" rel="stylesheet" type="text/css"  />

    </head>
<body>
</body>
</html>';
?>

Code: Job Profile \/\/\/ (Does not work!)

<?

echo'THIS IS THE JOB PROFILE PAGE';

if ($log_in = true){

$db_name = "";
$table_name = "job";
$connection = @mysql_connect("localhost", "", "") or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
$sql = "SELECT * FROM $table_name where job_id = [job_id]";

$result = @mysql_query($sql) or die(mysql_error());

echo'$GET_[job_id]';

while ($data=mysql_fetch_array($result)) {

echo'<P>JOB ID:' . $data['job_id'] . '</P>
<P> JOB NAME:' . $data['job_name'] . '</P>
<P>COMPANY NAME:' . $data['company_name'] . '</P>
<P> COMPANY ID:' . $data['company_id'] . '</P>
<P> CONTACT FORENAME:</P>' . $data['contact_fname'] . '</P>
<P> CONTACT SURNAME:</P>' . $data['contact_sname'] . '</P>
<P> JOB STATUS:</P>' . $data['job_status'] . '</P>
<P> COMPLETE PERCENTAGE:</P>' . $data['pcnt_complete'] . '</P>
<P> CONTRACTOR:</P>' . $data['contractor'] . '</P> ';
}
}
?>
    <html>
    <head>
    </head>
    <body>   
    P
    </body>
    </html>

Edited 3 Years Ago by mike_2000_17: Fixed formatting

add this line in first section in while loop

<td class="table_results"><a href="profile_job.php?jobid='.$row['job_id'].'">go to profile page</td>

and take this variable at second page

$job_id=$_POST;

and use this $job_id in second section(job profile page) query


second way

take an hidden field in your first form and put $row as a value in it and request it in other page

<input type="hidden" name="hd_val" value="<?=$row?>"?>


and use it in second page

$job_id=$_REQUST

This article has been dead for over six months. Start a new discussion instead.