Mi problema es que bueno no hace mucho salí de estudiar programción y tengo calro muchas falencias y en este caso PHP me da duro jajajja tengo un código de paginación para mostrar registros de la BD en un formulario cosa que hace casi perfectamente, el problema es que en campo imagen en vez de dejarme ver la IMG me muestra es la ruta se que es la línea donde muestro la img o la guardo en la BD pero no he podido jajaja les agradecería demasiado que me ayudaran :D
MUCHÍSIMAS GRACIAS.
Aquí el código que realiza el guardado en la BD
Código PHP:
<?php require_once('php/con_imag.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$tipo_prod = $_POST["lstTipo"];
//Guardar imagen
if(is_uploaded_file($_FILES['fleImagen']['tmp_name'])) { // verifica haya sido cargado el archivo
$ruta= "images/$tipo_prod/".$_FILES['fleImagen']['name'];
move_uploaded_file($_FILES['fleImagen']['tmp_name'], $ruta);
}
$insertSQL = sprintf("INSERT INTO contenido (referencia, imagen, nombre, descripcion) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['txtReferencia'], "int"),
GetSQLValueString($ruta, "text"),
GetSQLValueString($_POST['txtNombre'], "text"),
GetSQLValueString($_POST['txtDescripcion'], "text"));
mysql_select_db($database_con_imag, $con_imag);
$Result1 = mysql_query($insertSQL, $con_imag) or die(mysql_error());
$insertGoTo = "admin.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
Este es el codigo que me genera la paginación
Código PHP:
<?php
require('../php/conexion.php');
$RegistrosAMostrar=1;
//estos valores los recibo por GET
if(isset($_GET['pag'])){
$RegistrosAEmpezar=($_GET['pag']-1)*$RegistrosAMostrar;
$PagAct=$_GET['pag'];
//caso contrario los iniciamos
}else{
$RegistrosAEmpezar=0;
$PagAct=1;
}
$query = "SELECT referencia, imagen, nombre, descripcion FROM contenido LIMIT $RegistrosAEmpezar, $RegistrosAMostrar";
$Resultado=mysql_query($query, $con);
echo "<table border='1px'>";
while($MostrarFila=mysql_fetch_array($Resultado)){
echo "<tr>";
echo "<td>".$MostrarFila['referencia']."</td>";
/*if ($PagAct == 1)
echo "<td>".$MostrarFila['post_title']."</td>";
else*/
echo "<td>".utf8_encode($MostrarFila['nombre'])."</td>";
echo "<td>".$MostrarFila['imagen']."</td>";
echo "<td>".$MostrarFila['descripcion']."</td>";
echo "</tr>";
}
echo "</table>";
$NroRegistros=mysql_num_rows(mysql_query("SELECT * FROM contenido",$con));
$PagAnt=$PagAct-1;
$PagSig=$PagAct+1;
$PagUlt=$NroRegistros/$RegistrosAMostrar;
//verificamos residuo para ver si llevará decimales
$Res=$NroRegistros%$RegistrosAMostrar;
// si hay residuo usamos funcion floor para que me
// devuelva la parte entera, SIN REDONDEAR, y le sumamos
// una unidad para obtener la ultima pagina
if($Res>0) $PagUlt=floor($PagUlt)+1;
//desplazamiento
echo "<a onclick=\"Pagina('1')\">Primero</a> ";
if($PagAct>1) echo "<a onclick=\"Pagina('$PagAnt')\">Anterior</a> ";
echo "<strong>Pagina ".$PagAct."/".$PagUlt."</strong>";
if($PagAct<$PagUlt) echo " <a onclick=\"Pagina('$PagSig')\">Siguiente</a> ";
echo "<a onclick=\"Pagina('$PagUlt')\">Ultimo</a>";
?>
Y este es el que muestra los datos de la BD en el formulario
Código HTML:
<table align="center" border="1px"> <tr> <td>referencia</td> <td>imagen</td> <td>nombre</td> <td>descripcion</td> </tr> </table> <div id="contenido"> <?php include('paginador.php')?> </div> </div>