0
When showing a query in a table I create these three fields for the user to update to the line showing the query data:
<?php
$tabela1 .= '<td> <input type="file" name= "Imagem['.$rows_cursos['Id'].']" value="'.$rows_cursos['Imagem'].'"></td>';
$tabela1 .= '<td> <input type="text" name= "Tratamento['.$rows_cursos['Id'].']" value="'.$rows_cursos['Tratamento'].'"></td>';
$tabela1 .= '<td> <input type="radio" name= "Id['.$rows_cursos['Id'].']" value="Pendente"> Pendente <input type="radio" name= "Id['.$rows_cursos['Id'].']" value="Concluido">Concluido</td>';
?>
In this next step I keep in this way the image path, but it does not guard the complete path, it only keeps the image name and the format "DSCF2712.JPG":
<?php
if(isset($_POST['registar']))
{
$servername = "xxx.xxx.x.xx";
$username = "xxxxx";
$password = "xxxxxxx";
$dbname = "xxxxxxxx";
$conn = new mysqli($servername, $username, $password, $dbname);
$conn->set_charset('utf8');
$registro = $_POST['Id'];
$imagem = $_POST['Imagem'];
$tratamento = $_POST['Tratamento'];
foreach($registro as $Id => $estado) {
$conn->query("UPDATE RegistoManutencao SET Estado='$registro[$Id]', Imagem = '$imagem[$Id]', Tratamento = '$tratamento[$Id]' WHERE Id='".$Id."'");
}
}
?>
I’ve been researching and what I realized is ideal is just to keep the name of the image and the extension, as I have, but now how do I show it? I’m doing it this way:
<?php
$result_cursos = "SELECT centrodb.RegistoManutencao.Imagem FROM centrodb.RegistoManutencao";
$resultado_cursos = mysqli_query($conn, $result_cursos);
$tabela1 .= '<div style="float: center" table align="center">';
$tabela1 .= '<table border="5">';
$tabela1 .= '<tr>';
$tabela1 .='<thead>';
$tabela1 .= '<tr>';
$tabela1 .= '<th>Imagem</th>';
$tabela1 .= '</tr>';
$tabela1 .='</thead>';
$tabela1 .='<tbody>';
while($rows_cursos = mysqli_fetch_array($resultado_cursos)) {
$tabela1 .= '<tr>';
$tabela1 .= '<td><img src="' .$rows_cursos['Imagem']. '" /></td>';
$tabela1 .= '</tr>';
}
$tabela1 .= '</tr>';
$tabela1 .='</tbody>';
$tabela1 .= '</table>';
$tabela1 .= '</div>';
echo $tabela1;
?>
And the result is this, does not show the image, but if you do inspect it shows the name and the extension that is in the database:
I think the problem is not finding the complete path of the image
inspect the element and see which URL is being generated
– WeezHard
I don’t get it, you can be more specific?
– user104114
Press the right mouse button on the image and go on to inspect. Are you sure that what is saving in the bank are the bases 64, JPEG?
– Woss
I know they are jpeg, but in my case it can also be png, I needed to show all the images inserted in the database in data type
LONGBLOB
on the chart, but I’m not getting– user104114
Tell me what kind of column you’re saving the image URL.
– user60252
currently varchar to save image name and extension.
– user104114
i besides saving the image name and the extension in the database table, should put a button to upload the images always to a specific folder of the server. I am using the Ubuntu server 16.04 and sharing folders with samba
– user104114
I understand, but how can you save a field URL
input type="file"
?– user60252
So instead of saving the url, just save the name and extension of the image in the database table and save it in a specific folder inside the server, where the correct one should put the image there with an upload and then show the image in a table
– user104114