mercredi 22 novembre 2017

If value "1" display picture

The result that I need to reach

If the value in the "price" column is "1" and in the "code" column is 5, then display the "images/imagex.png" image. If the value in the "price" column is "2" and in the "code" column is 5, then it will show the image "images/imagey.png".

Information: The table name in the database is "mag", it is updated every 5m, so every 5m the php page would have to be updated also with new information as well.


I've tried a lot of things and looked for several guides, so far I understand that I'll need to use a JSON, right? I do not know very well about it, but I understood that it updates without needing to refresh the page (f5).

The table looks like this:

  <div class="tg-wrap"><table class="tg">
  <tr>
  <th class="tg-031e" colspan="3"><img src="images/123_01.png" alt=""></th>
  </tr>

<tr>
    <td class="tg-031e"><img src="images/123_02.png" alt=""></td>
    <td class="tg-031e"><img src="images/123_03.png" alt=""></td>
    <td class="tg-031e"><img src="images/1234_04.png" alt="">
</td>
</tr>
</table>
</div>

With the code it would look like this:

<?php
$sql = "SELECT * FROM mag2";
$result = mysql_query($sql)or die(mysql_error());
while ($row = mysql_fetch_array($result)){

// Show images
 <div class="tg-wrap"><table class="tg">
      <tr>
   <th class="tg-031e" colspan="3">if($row['price, code']=='1, 5'){
 print "<img src='images/123_01.png'/>";
}
></th>
      </tr>

    <tr>
        <td class="tg-031e">if($row['price, code']=='3, 4'){
 print "<img src='images/123_02.png'/>";
}
</td>
        <td class="tg-031e">if($row['price, code']=='54, 12'){
 print "<img src='images/123_03.png'/>";
}
</td>
        <td class="tg-031e">if($row['price, code']=='11, 31'){
 print "<img src='images/123_04.png'/>";
}
</td>
    </tr>
    </table>
    </div>
} // End while loop
?>

I tried to explain everything I can, I apologize for being a bit confused, I'm starting and I really tried my best, but I do not find a solution. Thanks for your help!

Aucun commentaire:

Enregistrer un commentaire