i've the same search like mine alot here, but mine is a bit more complexe and didn't know how to make it work.
so i have this json content: (this is one of 84 objects inside a json table)
{
"number": "6",
"name": "Le Nickel : ses oxydes, ses sels et les opérations de grillage de mattes de nickel",
"cause":
{
"A":"<p><strong><u>Liste indicative des principaux travaux</u></strong></p><p>Nickelage électrolytique des métaux</p>",
"B": "<p><strong><u>Liste limitative des travaux</u></strong></p><p>Nickelage électrolytique des métaux</p><p>Opérations de soudage sur des métaux contenant du Nickel.</p>",
"C": "<p><strong><u>Liste limitative des travaux</u></strong></p><p>Opérations de grillage de mattes de nickel. Opérations de soudage sur des métaux contenant du nickel.</p>"
},
"content": {
"A": [
{
"des": "Dermites eczématiformes récidivantes en cas de nouvelles expositions ou confirmées par test épicutané.",
"period": "7 jours"
}
],
"B": [
{
"des": "Rhinite, asthme ou dyspnée asthmatiforme confirmés par test ou par épreuves fonctionnelles, récidivant après nouvelle exposition au risque.",
"period": "7 jours"
}
],
"C": [
{
"des": "Cancer primitif de l’ethmoïde et des sinus de la face.Cancer bronchique primitif.",
"period": "40 ans"
}
]
}
}
and i want to add them to this table based on search result
<tr>
<th>Tableau</th>
<th>Désignation des maladies</th>
<th>Délai de prise en charge</th>
<th>Liste indicative des principaux travaux susceptibles de provoquer ces maladies</th>
<th></th>
</tr>
when i search through the cause array everything works fine but when i loop through the content arrays thats when every thing just goes to hell.
this is my php code for the search:
$index = 0;
$output ="";
$first = "";
$last = "";
foreach($table["content"]["A"] as $content){
if(strpos($content["des"],$search)){
if($index == 0){
$first.= "<tr>";
$first.= "<td>".$table["number"]."</td>";
$first.= "<td>".$content["des"]."</td>";
$first.= "<td>".$content["period"]."</td>";
$$last.= '<td><a href="add.php"><button type="button">Ajoutez au suivi</button></a></td>';
$$last.= "</tr>";
}else{
$output.= "<tr>";
$output.= "<td>".$table["number"]."</td>";
$output.= "<td>".$content["des"]."</td>";
$output.= "<td>".$content["period"]."</td>";
$output.= '<td><a href="add.php"><button type="button">Ajoutez au suivi</button></a></td>';
$output.= "</tr>";
}
$index++;
}
}
echo $first;
echo "<td rowspan=\"".$index."\">".$table["cause"]["A"]."</td>";
echo $last;
echo $output;
$index =0;
and this is what happens when i run it :
i was hoping i find an answer here, thnks all for your time and for the help.
</div>