Click here to Skip to main content
15,881,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
PHP
   //GET FORM DETAIL
	$mySQL2 = 'SELECT A.* FROM assessment_performance A WHERE A.id = ' .$data['id'];	
	$result2 = mysql_query($mySQL2);
	
	if ($result2){
		if (mysql_num_rows($result2) > 0){
			$row2 = mysql_fetch_assoc($result2);
			
			$data['assessment_year_id'] = $row2['assessment_year_id'];
			$data['year_assessment'] = $row2['year_assessment'];

            $data['hr_scoring1'][$row2['id']] = $row2['hr_scoring1'];  

     }
}


What I have tried:

	<table class="table bg-grey-cararra m0 table-border-black">
		<div class="row">
			<div class="col-md-12">
				CRITERIA FOR SECTION C (FOR HR USE ONLY)
			</div>
		</div>
													
		<tr>
		<td class="bold text-center"></td>
		<td class="bold text-center">Description</td>
		<td class="bold text-center">Actual Score</td>
		</tr>
												
		<tr>
		<td class="text-center">a.</td>
		<td>Attendance (i.e Punctuality/Completion of Working hours/etc.)</td>	
		<td>
			<pre lang="PHP">
        <?php
															
		if ($_SESSION[AppName]['hr_function'] == 1) {
		echo '<select class="form-control select2" rows="2" id="hr_scoring1" name="hr_scoring1[1]">';
		foreach ($ListRate as $key => $value){
				$xSelect = '';
				if (array_key_exists(1, $data['hr_scoring1']) && $data['hr_scoring1'][1] == $key){
					$xSelect = ' selected="selected"';
				}
				echo '<option value="'.$key.'"'.$xSelect.'>'.$value.'</option>';
		}
			echo '</select>';
	}
else{
echo '<p class="text-center"> '.(array_key_exists (1, $data['hr_scoring1']) ? $data['hr_scoring1'][1] : '') .'</p>';
}
?>



Posted
Updated 30-May-22 22:54pm
v3

1 solution

Hello your query looks wrong.

when you call two table put a ',' to separate the 2 table :
select A.* FROM table1, A where A.id ='id' AND table1.foreign_key_a_id = A.id
| datas needed | all tables needed | criterias and linking between tables

when working on several tables ( instead of one only single table ), you have to link the id ( primary key ) and the foreign key in the second table to BUILD the junction between both.
 
Share this answer
 
Comments
CHill60 1-Jun-22 11:47am    
There is nothing wrong with the query
SELECT A.* FROM assessment_performance A WHERE A.id = someValue;
The A is an Alias for the table assessment_performance
Also, using a comma separated list of tables with a where clause to join them went out of date with ANSI-92 Syntax. You should use an ON clause instead e.g.
SELECT columnlist FROM TableA A JOIN TableB B ON A.ForeignKeyColumn = B.PrimaryKeyColumn;
Member 15627495 2-Jun-22 1:50am    
[ sorry I misread ]


It's not old, neither a syntax problem : it works.

When you use JOIN , the tables are melt, and the linked ( PK <=> FK ) rows are kept for instructions to come, and others statements.
JOIN is favorite with LEFT / INNER / RIGHT and pals.

but JOIN alone just go on linking table.

with the old linking "TABLE one, two WHERE one.fk = two.pk" , only columns in the "SELECT and WHERE" are up.
Instead of a big bunch of rows ( by JOIN ) and a filtering on them.

Where JOIN is trapy, it's a sided query ( 1! ), and with lot of tables involved ( try with 15 tables in a query ), it becomes a messy query ( 2! ).
CHill60 2-Jun-22 2:52am    
This comment does not make any sense at all. I have no idea what you are saying but I did get a couple of points. Yes that syntax does work but you are limited to inner joins only, the where clause is messy and difficult to separate the filtering from the join criteria. It IS old, old-fashioned and not best practice.
Any query with 15 tables becomes messy - especially using your style. And quite possibly not efficient.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900