SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with images, please

    hello

    i have a problem with images

    i use the function mysql_num_rows for to obtein the images and, i want the show images in files of 5

    my code is :

    PHP Code:
    <?php
    extract
    ($HTTP_GET_VARS);
    require_once(
    'funciones.php');
    $lnk    Cnn();
    $sql    "select * from imagenes3 where img_of_id=$of_id";
    @
    $rs    mysql_query($sql,$lnk);
    $cant    mysql_num_rows($rs);
    if(
    $cant==0){echo "&nbsp;";
    }
    if(isset(
    $HTTP_GET_VARS['imagen_mostrar']))
    {
        
    $show $HTTP_GET_VARS['imagen_mostrar'];
    }
    else
    {
        
    $show mysql_result($rs,0,"img_id");
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Documento sin t&iacute;tulo</title>
    <style type="text/css">
    <!--
    body {
        background-color: #EAEAEA;
    }
    -->
    </style></head>

    <body>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td colspan="5"><div align="center"><?php echo "<img border='3' src='imagen.php?img_id=$show&tamanio=600'>"?></div></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      
    <?php
    $filas 
    $cant/5;
    if(
    $filas<1){$filas=1;}
        for(
    $i=1;$i<=$filas;$i++)
        {
            echo 
    "  <tr>\n";
            for(
    $i=1;$i<=$cant;$i++)
            {        
                
    $x+=1;

                if(
    $x<=$cant)
                {
                    
    $img_id mysql_result($rs,$i-1,"img_id");
                    echo 
    "    <td width='20%'><div align='center'><a href='?of_id=$of_id&imagen_mostrar=$img_id' title='Click para ver...'><img border='3' src='imagen.php?img_id=$img_id&tamanio=100'></a></div></td>\n";
                }
                else
                {
                    echo 
    "    <td width='20%'><div align='center'>&nbsp;</div></td>\n";
                }
            }
            echo 
    "  </tr>\n";
        }
    ?>
      
    </table>
    </body>
    </html>
    <?php
    mysql_free_result
    ($rs);
    mysql_close($lnk);
    ?>
    help me, please!!!!!
    i dont know where is my fault!!!!

    cheers

    pd: sorry for my english, is very bad

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Really i could not get what you want to do. If you mean that you want to get 5 images from the database, why don't you use while and you need to use mysql_fetch_array() function to loop. But i saw there in your code that you are probably wanting to get only one image from the database with one id.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i want show the images in rows of 5
    in this code, show the images in one row of n images

    i dont know where is my fault in this code, if you show me, please

  4. #4
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh that means you want to show 5 images in a row and others in next row if there are more than 5, right? How many images are being retrieved with that query for the time being?
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  5. #5
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep!!!!!!!!!!!!!!

    show 5 images in a row and
    other 5 images in other row, and next next next

    in this code, show the n images in 1 only row

    30 images for the time being!!!!

    cheers

  6. #6
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok do like this then. I changed your whole code like this:
    Code php:
    <?php
    extract($HTTP_GET_VARS);
    require_once('funciones.php');
    $lnk	= Cnn();
    $sql	= "SELECT * FROM imagenes3 WHERE img_of_id=" . $of_id;
    $rs		= mysql_query($sql) or die(mysql_error());
    $cant	= mysql_num_rows($rs);
     
    if($cant >= 1){
    	if(isset($HTTP_GET_VARS['imagen_mostrar']))
    		$show = $HTTP_GET_VARS['imagen_mostrar'];
    	else
    		$show = mysql_result($rs, 0, "img_id");
    }
    else{
    	echo "No images found.";
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Documento sin t&iacute;tulo</title>
    <style type="text/css">
    body {background-color: #EAEAEA;}
    </style>
    </head>
    <body>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td colspan="5"><div align="center"><?php echo "<img border='3' src='imagen.php?img_id=$show&tamanio=600'>"; ?></div></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    <?php
    $perrow 	= 5;
    $cnter 		= 1;
    if($cant >= 1){
    	echo '<tr>\n';
    	while($rows = mysql_fetch_array($rs)){
    		$img_id = $rows['img_id'];
    		echo '<td width="20%"><div align="center"><a href="?of_id=' . $of_id . '&imagen_mostrar=' . $img_id . '" title="Click para ver...">';
    		echo '<img border="3" src="imagen.php?img_id=' . $img_id . '&tamanio=100"></a></div></td>\n';
    		if(($cnter % $perrow) == 0){
    			echo '</tr><tr>';
    		}
    		$cnter++;
    	}
    	echo '</tr>\n';
    }
    ?>
    </table>
    </body>
    </html>
    <?php
    mysql_free_result($rs);
    mysql_close($lnk);
    ?>
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  7. #7
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you so much!!!!!!!!!!!!!!

    i have a little problem with this code

    in one part, show

    \n
    \n
    \n
    \n
    \n
    \n

    but, the problem is solveddddddddddddddd!!!!!!!!!!!!! :P

    thank you again

    cheers!!!

  8. #8
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh yes if you use \n in single quote that won't work. So you can concatenate with double quote.
    PHP Code:
    echo 'content' "\n"
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  9. #9
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep, but the problem is solved

    thank you rajug for you time

    other question

    what do you advise me for to learn (better) php?

    thanks!!!!!

  10. #10
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are not the quite beginner for PHP at all, then the php manual is enough. Otherwise go for google and find some better site or buy some books from your local market.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  11. #11
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what books you advise me??????????

  12. #12
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  13. #13
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks rajug again for you help and time

    good night


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •