Show Images With PHP


Hello, good afternoon .... You could help me, it's that I need to show some images, but I mean, in the bd, I have a lacual table that contains 1400 data, and I have a web page with which to select a only data, it brings all the characteristics of that selected data, but now I only need the image, and that is why I have to create another table, but I do not know if I want to save the image in the bd, or save only the name of the image, besides of that, in the first table mentioned above, there are five fields in which there are words like "attention", "corrosive", then I need that according to the selected field, if this has for example "attention" that brings me to screen only the image that represents "attention"

---------Archivo Conexion---------------

//Conexion A La Base De Datos

    $conexion = new mysqli($host, $usuario, $contraseña, $base);
    if ($conexion -> connect_errno){
        die ("Fallo La Conexion:(".$conexion -> mysqli_connect_errno().")".$conexion-> mysqli_connect_error());

---------Archivo Index---------------
    include ("control/conexion.php");
    //Consulta A La Base De Datos
    $resultado = $conexion->query("SELECT * FROM basede");
    $idproduc = '';
    $idproduc = $_POST['producto'];

        $where ="where id=".$idproduc;

<!DOCTYPE html>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <!--Carga De Archivos Css-->
        <link rel="stylesheet" type="text/css" href="css/estilos.css">
        <div class="container">
            <div class="Cuerpouno">
                <form action="#" method="post">
                <select name="producto" id="producto">
                    <option>Seleccione Una Opción</option>
                        while($row = $resultado->fetch_array()){
                            echo "<option value='".$row['id']."'>".$row['Nombre']."</option>";
                <input id="consultar" type="submit" value="Consultar">

            <table class="tabla">
                    <th class="uno"><b>CAS: </b></th>
                    <th class="dos"><b>Concentración: </b></th>
                    <th class="tres"><b>Formula: </b></th>
                    <th class="cuatro"><b>Densidad: </b></th>
                    <th class="cinco"></th>
                    <th class="once"></th>
                    <th class="doce"></th>
                    <th class="trece"><em>Advertencia De Peligros</em></th>
                    <th class="catorce"></th>
                    <th class="quince"><em>Consejos De Prudencia</em></th>
                    <th class="dieseis"></th>
                    <th class="diesiete"></th>
                    <th class="diesnueve"></th>
                    <th class="veintiuno"><b>M:</b></th>
                    <th class="veinticuatro"><img class="tres" src="img/Univ.png"></th>
                    <th class="veintisiete"></th>
                    <th class="veintiocho"><img class="cuatro" src="img/Univ.png"></th>
                    <th class="treinta"></th>
                    <th class="treintauno"></th>
                    <th class="treintacuatro"></th>
                    <th class="treintacinco"></th>
                    <th class="treintaseis"></th>
                    <th class="treintasiete"></th>
                    <th class="treintaocho"></th>
                    <th class="treintanueve"></th>
                    $sql = "SELECT 'id', 'CAS', 'Nombre', 'ColorDeEtiqueta', 'Etiqueta 1', 'Etiqueta 2', 'Etiqueta 3', 'Etiqueta 4', 'Etiqueta 5', 'Frase H1', 'Frase H2', 'Frase H3', 'Frase H4', 'Frase H5', 'Frase H6', 'Frase H7', 'Frase H8', 'Frase H9', 'Frase H10', 'Frase H11', 'Frase H12', 'Frase P1', 'Frase P2', 'Frase P3', 'Frase P4', 'Frase P5', 'Frase P6', 'Frase P7', 'Frase P8', 'Frase P9', 'Frase P10', 'Frase P11', 'Frase P12', 'Frase P13', 'Frase P14', 'Frase P15', 'Frase P16', 'Frase P17', 'Frase P18', 'Frase P19', 'Frase P20', 'Frase P21', 'Frase P22', 'Frase P23', 'Frase P24', 'Frase P25', 'Frase P26', 'Frase P27', 'Frase P28', 'Frase P29', 'Frase P30', 'UN', 'Almacenamiento', 'Palabra', 'Etiquetas 1', 'Etiquetas 2', 'Etiquetas 3', 'Sinonimos', 'Formula', 'PM', 'Densidad', 'Pureza', 'Concentracion' FROM 'basede' WHERE id='".$idproduc."'";
                    $sqlquery = $conexion->query($sql);
                    while ($Muestra = $sqlquery->fetch_array()){
                <tr><td class="diez"><b><?php echo $Muestra['Nombre']?></b></td></tr><tr><td class="seis"><?php echo $Muestra['CAS'];?></td><td class="siete"><?php echo $Muestra['Concentracion'];?></td><td class="ocho"><?php echo $Muestra['Formula'];?></td><td class="nueve"><?php echo $Muestra['Densidad'];?></td><td class="veinte"><?php echo $Muestra['PM']?></td><td class="veintitres"><b>Clase</b><br><?php echo $Muestra['Almacenamiento']?></td></tr>
                <tr><td class="diesocho"><b><?php echo $Muestra['Nombre']?></b></td><td class="veinticinco"><?php echo $Muestra['Formula']?></td><td class="veintiseis"><?php echo $Muestra['PM']?></td><td class="veintinueve"></td><td class="treintados"><b>Clase: <?php echo $Muestra['Almacenamiento']?></b></td><td class="treintatres"></td>
                <input type="submit" name="btncas" value="Buscar Por CAS" id="btncas">
                <input type="submit" name="menuP" value="Menú Principal" id="menuP">
                <input type="submit" name="buscarfds" value="Buscar FDS" id="buscarfds">
                <input type="submit" name="aggfds" value="Agregar FDS" id="aggfds">
asked by The Universe Android 04.12.2018 в 22:07

1 answer


In the database you save the path of the image, and then when extracting the data, with php you print something like this:

echo '<img src="'.$ruta.'">';
answered by 04.12.2018 в 22:34