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());


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


    <div id="rounded-corner">
            <p class="title">View Jobs</p>
                <table class="jobs">
<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>

                    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>

<? echo'<html>
    <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"  />


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



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());


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> ';

Edited by mike_2000_17: Fixed formatting

9 Years
Discussion Span
Last Post by BzzBee

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


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


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.