How to get id from my table
Posted: Tue Mar 31, 2009 10:15 am
Hello all, i was wondering whether somebody could help me with a problem that i am having with my client contact web app. I am fairly new to php;
and what i am trying to do is when a user clicks on the row of the table that displays all the jobs from the job table it opens up the job-profile-page for the selected job with all its details showing.
I know i need to get the [id] from the table but i am unaware how to do this ...
I don't think its possible to use the GET method as i am loading the job-profile-page into a div using Js please correct me if i am wrong.
Any help would be greatly appreciated
C¬Rose
and what i am trying to do is when a user clicks on the row of the table that displays all the jobs from the job table it opens up the job-profile-page for the selected job with all its details showing.
I know i need to get the [id] from the table but i am unaware how to do this ...
I don't think its possible to use the GET method as i am loading the job-profile-page into a div using Js please correct me if i am wrong.
Any help would be greatly appreciated
C¬Rose
Code: Select all
<?
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['company_name'] . '</td>
<td class="table_results">' . $row['company_id'] . '</td>
<td class="table_results">' . $row['job_status'] . '</td>
<td class="table_results">' . $row['pcnt_complete'] . '</td>
<td class="table_results">' . $row['contractor'] . '</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>';
?>