alidad7878 alidad7878 - 16 days ago 4
MySQL Question

image in while loops

I'm trying to create echo image in while loops with table, but I'm getting the error . please see part of the code

$image = $rows['image'];
$sql = "SELECT * FROM boxes ";
$result = $db->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
if ($row['status'] == 1)
$visible = "visible";
else
$visible = "hidden";

if ($row['side'] == 1)
$side = "right";
else if ($row['side'] == 2)
$side = "left";
else $side = "not set yet";

echo "



<tr>
<td width=\"15%\" rowspan=\"3\"><img src="data:image' image \. ($row['image']).'" />';</td>
<td width=\"85%\" colspan=\"5\">".$row['title_boxe'] . "</td>
</tr>
<tr>
<td colspan=\"5\">desc</td>
</tr>
<tr>

<td>Visible</td>

<td>sss</td>
<td><form method='post'><input type='hidden' name='id' value='" . $row['id_boxe'] . "'/>
<input type='submit' name='update' value='Update' class=\"btn btn-primary\"/></form></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan=\"6\">hr</td>
</tr>
<tr>
<td colspan=\"6\">&nbsp;</td>
</tr>


";
}
}
?>
</tbody>
</table>


what wrong with this line of code inside of php that i can figure out how to solve this...

<td width=\"15%\" rowspan=\"3\"><img src="data:image' image \. ($row['image']).'" />';</td>


many thanks for your help.

Answer

Seems that you echo is wrong ( and to me is not clear what you are doing with <src='data:image image .. if you need a \ but this interfer with quote escape it using \

      echo "
    <tr>
      <td width='15%' rowspan='3'><img src='../image/box-manage/" . $row['image'] ."' />;</td>
      <td width='85%' colspan='5'>". $row['title_boxe'] . "</td>
    </tr>
    <tr>
      <td colspan='5'>desc</td>
    </tr>
    <tr>

      <td>Visible</td>

      <td>sss</td>
      <td><form method='post'><input type='hidden' name='id' value='" . $row['id_boxe'] . "'/>
          <input type='submit' name='update' value='Update' class='btn btn-primary'/></form></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan='6'>hr</td>
    </tr>
     <tr>
      <td colspan='6'>&nbsp;</td>
    </tr>";