Foros del Web » Programando para Internet » PHP »

problema con imagenes sacando path de bd

Estas en el tema de problema con imagenes sacando path de bd en el foro de PHP en Foros del Web. Buenas Estimados. Tengo un problema, acabo de conseguir una galeria de imagenes que estando colocado el archivo php en la carpate donde contiene las imagenes ...
  #1 (permalink)  
Antiguo 04/01/2012, 11:46
Avatar de mazaku  
Fecha de Ingreso: septiembre-2009
Ubicación: Veracruz
Mensajes: 104
Antigüedad: 14 años, 7 meses
Puntos: 0
Pregunta problema con imagenes sacando path de bd

Buenas Estimados.

Tengo un problema, acabo de conseguir una galeria de imagenes que estando colocado el archivo php en la carpate donde contiene las imagenes funciona muy bien pero cuando le pongo que lea imagenes de una carpeta del servidor pero pasandole la ruta desde una bd no me funciona. me aparece en blanco como si no hubiera imagenes cuando si las hay en la carpeta.

en la bd guardo el path de la carpeta donde se encuentran las imagenes
ejemplo
path: c/categoria/subcategoria/123/

galeria.php
Código PHP:
<?php
session_start
();
include (
'config.php');
$c_capitulo $_GET['capitulo']; // Esto recoje los datos de la variable id en la url.
$registros=mysql_query("SELECT * FROM capitulos WHERE c_capitulo='$c_capitulo'",  
           
$db_link) or
  die(
"Problemas en el select:".mysql_error());
while (
$reg=mysql_fetch_array($registros))
{
/* 
    PHPImageview 1.1
    written by Chris Heilmann 
    Homepage:http://www.onlinetools.org/tools/phpimageview.php
*/    
$bg="#cccccc";            // background of the for+next cells
$fornext=1;                // display for+next arrows 1=yes 0=no
$next="<b>&gt;&gt;</b>";// text displayed in the next field
$last="<b>&lt;&lt;</b>";// text displayed in the last field
$textlinks=1;            // display textlinks to the images 1=yes 0=no
$dropdown=1;            // display dropdown menu with names 1=yes 0=no
$dropdowntext="show";    // text display on the button next to the dropdown
$namedisp=1;            // display name of the pic (capitalized filename) 1=yes 0=no
$xofy=1;                // display pic x of y 1=yes 0=no


$SCRIPT_NAME=$SERVER_VARS['PHP_SELF'];
$pic=$HTTP_GET_VARS['pic'];

//    the directory name 
$handle=opendir("".$reg['c_path']."");
//    start HTML, you can tweak that!
echo "<div align=\"center\">\n\t<font face=\"verdana,arial,helvetica\" size=2>\n";

//    initialize variables
$pics=array();
$count=0;
//    read directory into pics array
while (($file readdir($handle))!==false) {
    
//    filter for jpg, gif or png files...     
    
if (substr($file,-4) == ".jpg" || substr($file,-4) == ".gif" || substr($file,-4) == ".png" || substr($file,-4) == ".JPG" || substr($file,-4) == ".GIF" || substr($file,-4) == ".PNG"){
    
//     you can apply other filters here...
        
$pics[$count] = $file;
        
$count++;
    
//    don't forget to close the filter conditions here!
    
}
}
closedir($handle); 

//    done reading, sort the filenames alphabetically, shade these lines if you want no sorting
sort ($pics);
reset($pics);

//    define the selected picture, to highlight textlink, preselect dropdown and define for+next links
for ($f=0;$f<=sizeof($pics)-1;$f++){if ($pic==$pics[$f]){$selected $f+1;}}

//    display dropdown if wanted...
if ($dropdown==1){
    echo 
"\t\t<!-- dropdown -->\n\t\t<form name=\"mainform\">\n\t\t\t<select name=\"pic\">\n";
    
//    loop over all pics
    
for ($f=0;$f<=sizeof($pics)-1;$f++){
        
//    Capitalize filename for display
        
$name=ucfirst(substr($pics[$f],0,-4));
        
// if the pic is the selected one set selected status
        
if ($pic==$pics[$f]){echo "\t\t\t\t<option value=\"".$pics[$f]."\" selected>".$name."</option>\n";}
        
//    or simply render another option
        
else{echo "\t\t\t\t<option value=\"".$pics[$f]."\">".$name."</option>\n";}
        }
    
// close select statement and display show button with predefined text.
    
echo "\t\t\t</select>\n\t\t\t&nbsp;<input type=\"submit\" value=\"".$dropdowntext."\">\n\t\t</form>\n\t\t<!-- end dropdown -->";
}

//    if there is already a pic selected...
if ($pic && !preg_match("/javascript/",$pic)){
    
//    if the text should be displayed
    
if ($namedisp==1){
        
// Capitalize filename for display andf print it
        
$name=ucfirst(substr($pic,0,-4));
        echo 
"\n\t\t<!-- imagename -->\n\t\t<b>".$name;
        }
    
//    if pic x of y is selected, display it    
    
if ($xofy==1){
        echo 
" ".$selected."/".sizeof($pics);
        }
    echo 
"</b>\n\t\t<!-- imagename end -->\n";
    
// Display table with for+next arrows, and a black line around the image
   
echo "\t\t<!-- table with image -->\n\t\t<table width=1 border=0 cellspacing=0 cellpadding=1 bgcolor=\"#000000\">\n\t\t\t<tr>\n\t\t\t\t<td bgcolor=\"".$bg."\">";
    
// if for+next arrows are selected and the picture is not the first one, display last arrow
    
if ($selected != && $fornext==1){
        echo 
"<a href=\"$SCRIPT_NAME?pic=".$pics[$selected-2]."\">$last</a>";
        }
    else { echo 
"<font color=\"".$bg."\">$last</font>";}
        echo
"</td>\n\t\t\t\t<td><image src=\"".$pic."\" alt=\"".$name."\" border=0></td>";
    
// if for+next arrows are selected and the picture is not the last one, display next arrow
    
if ($selected != (sizeof($pics)) && $fornext==1){
        echo
"\n\t\t\t\t<td bgcolor=\"".$bg."\"><a href=\"$SCRIPT_NAME?pic=".$pics[$selected]."\">$next</a>";
        }
    else { echo
"\n\t\t\t\t<td bgcolor=\"".$bg."\"><font color=\"".$bg."\">$next</font>";}
    echo
"</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t<!-- table with image end -->\n\t\t<!-- Textlinks--->\n\t\t";
}
//    if textlinks display is selected
    
if ($textlinks == 1){
        
// loop over images
        
for ($f=0;$f<=sizeof($pics)-1;$f++){
            
// add gaps between the links, unless it is the first one
            
if ($f 0) echo "&nbsp;&nbsp;";
            
// if the link to the pic is the selected one, display a bold number and no link
            
if ($pic==$pics[$f]){echo "<b>".($f+1)."</b>";}
            
// otherwise display the link
            
else{echo "<a href=\"$SCRIPT_NAME?pic=".$pics[$f]."\">".($f+1)."</a>";}
            
// make linebreaks every 15 times!
            
$isbr strpos((($f+1)/15),".");
                if (!
$isbr){echo "<br>";}
            }
    }
    }
// close HTML :-)
echo"\n\t\t<!-- end textlinks -->\n\t</font></div>";
echo 
"\n\n<!-- Done with PHPImageview, get it at http://www.onlinetools.org/phpimageview -->";
?>

</body>
</html>
No se si tenga algun problema con que yo ponga el link hacia galeria.php de esta forma para pasar la variable
Código PHP:
galeria.php?capitulo=".$reg['c_capitulo']." 
y en la barra de direcciones me aparezca
Código PHP:
galeria.php?capitulo=69 
saludos y agradezco mucho su apoyo y ayuda.
  #2 (permalink)  
Antiguo 05/01/2012, 11:13
Avatar de mazaku  
Fecha de Ingreso: septiembre-2009
Ubicación: Veracruz
Mensajes: 104
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: problema con imagenes sacando path de bd

por favor alguien podria ayudarme con esto es que si quisiera usar este codigo para lo que necesito
  #3 (permalink)  
Antiguo 05/01/2012, 11:25
webankenovi
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: problema con imagenes sacando path de bd

/categoria/subcategoria/123/ o ../categoria/subcategoria/123/ prueba a guardarlo asi
  #4 (permalink)  
Antiguo 05/01/2012, 15:49
Avatar de mazaku  
Fecha de Ingreso: septiembre-2009
Ubicación: Veracruz
Mensajes: 104
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: problema con imagenes sacando path de bd

pues probe cambiando el path pero al parecer solo sirve si se encuentra en la carpeta de las fotos "." si le pongo otra ruta no me lee las imagenes, por que sera?
  #5 (permalink)  
Antiguo 05/01/2012, 16:06
Avatar de mazaku  
Fecha de Ingreso: septiembre-2009
Ubicación: Veracruz
Mensajes: 104
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: problema con imagenes sacando path de bd

o si alguien pudiera porfavor decirme de que forma muestro ordenadamente de 1 en 1, imagenes de una carpeta pasandole el path desde una bd y que me muestre links de siguiente y anterior y tambien un select con links a las imagenes.

algo como esto

http://submanga.com/c/142424
http://www.mangafox.com/manga/dragon_ball/v42/c008/1.html
http://www.mangareader.net/naruto/566

gracias por su apoyo y saludos de antemano

Etiquetas: bd, html, imagenes, path, registro, sql, variables
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:45.