php - split a string whilst use left join -


i have 2 databases. first contains list of upload doucuments , when uploaded , expiry date. stored numbers representing each grade of person using implode. column name 'foagrade' has 10,11,12 in row one. second database list of grades , there id's eg 10 = manager, 11 = hr etc. using left join , basic html table display query.

$result = mysqli_query($con, "select upload.id, upload.title, upload.faograde,upload.faolocation, upload.date,   upload.expiry, grade.id, grade.grade gr, grade.id upload left join grade on upload.faograde=grade.id owner=$user"); echo "<table id='previous'> <tr> <th>title/document name:</th> <th>for attention of grade</th> <th>for location</th> <th>date</th> <th>date expires</th> <th>delete briefing</th> </tr>";  while($row = mysqli_fetch_array($result))   {   $id=$row['id'];   echo "<tr>";   echo "<td>" . $row['title'] . "</td>";   echo "<td>" . $row['gr'] . "</td>";   echo "<td>" . $row['foalocation']."</td>";   echo "<td>" . date("d, d m y ",($row['date']));   echo "<td>" . date("d, d m y ",($row['expiry']));   echo "<td><a href=pages/login/upload_delete.php?item=".$id.">delete</a></td> ";   echo "</tr>";   } echo "</table>"; 

the query shows details shows first grade stored in column faograde (manager) not 11 or 12. how explode or split this? each number in column grade name shown. have same column 'faolocation', working on 1 issue @ time.

these tables should normalized, have can this:

select upload.id uploadid, upload.title, upload.faolocation, upload.date, upload.expiry, grade.id gradeid1, grade.grade gr, grade.id gradeid2 upload, grade  find_in_set(gradeid2,upload.faograde) , upload.owner=$user; 

update here's sql fiddle.

it bit confusing there multiple columns called id & id. it's best give them intuitive names grade_id or user_id. normalization standpoint using relational table instead of comma separated column (depending on how data enters database). here's video normalization.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -