Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    Regular Coder
    Join Date
    Jul 2009
    Posts
    143
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Finding image path

    Good morning:

    I am trying to save and image path on a database and have it retrieved with a pagination script. My question is how do I find the image path once the image is on the server? I am able to find it locally but I need to send the image to my server and the script will not display image if it's hosted locally. Thanks

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,540
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    You also need to upload the image to your server, perhaps you'll put all of them
    in the same directory called "images"? You'll then know where they are stored.

    Typically, you use a PHP script to upload the image(s) and write the image filename,
    caption, description, etc. into the database.

  • #3
    New Coder
    Join Date
    Dec 2009
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Ml, I know how to do that on a local folder, my problem is I can't figure out how to find the link once is on the server. Let me get this straight:

    1. I set up a db on the server with the ability to include a) image b) text.
    2. I also set up a php script to send info into the db including the image and text fields.
    3. The pagination script will pull info from fields and display on any page.

    If i don't send and image path, obviously it would not display.

    My question is do I have to send images to the image folder, then, find the link and post on the db field along with the text in order for it to paginate?

    If so, how can I find the image path once is on the server?

    Thanks

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,540
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    You can do it one of two ways ...

    1) You can store the actual binary (BLOB) .jpg, .gif (whatever) image in your MySQL database.

    2) You can store the image filename in your MySQL database, but put the actual
    image itself into a directory you set-up to store images.

    I prefer option 2, only because it's easier to manage the images. In either case, you
    still need to upload the images and text from a form of some kind.

    I assume you're doing all this online, with a webhost?
    I'm not sure what the "local" stuff is that you're doing.

  • #5
    New Coder
    Join Date
    Dec 2009
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm doing it on a webhost server. "Local" means, I know how to send and find the image path on my local server.

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,540
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    You can't have an online script (located on a webhost), find a file on your PC (hard drive).
    Is that what you're trying to do?

  • #7
    New Coder
    Join Date
    Dec 2009
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No, I am trying to find the image path once is uploaded to a server, so that I can insert into a database field. Pretty simple. I think I got it. this is a hobby and unfortunately I don't have too much time to play with it. I am, however, able to figure that out and now I'm trying to figure out how to add CSS to it. I can't seem to get it right. I am trying to make the output look similar to www.digg.com but i can't seem to get it to align properly. I can send text into the db and have it paginate correctly but when I try it with an image, it does not. Here's the CSS code i'm using, can you tell me what I'm missing? Thanks
    Last edited by ilouie; 01-27-2010 at 10:22 PM. Reason: more info

  • #8
    New Coder
    Join Date
    Dec 2009
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    .testing{
    	height: 1500px;
    	width: 975px;
    	
    	
        font-family:Tahoma, Geneva, sans-serif;
        font-size:14px;
        color:#00C;
    	background-color: #FFF;
    	font-weight : normal;
    	line-height : 1.1em;
    	overflow : hidden;
    	white-space : wrap;
    	text-decoration:none;
    	text-transform:capitalize;
    	text-align:left;
    	padding: 2px 5px 2px 5px;
    	border-bottom: 1px solid #F00;
    		
    }
    
    
    img {
       padding: 2px 5px 2px 5px;
    	
    	border: 1px solid #AAAADD;
    	float: right;
        margin-right: 5px;
    
    }

  • #9
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,540
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    We need to see the PHP script that is displaying the pages.

  • #10
    New Coder
    Join Date
    Dec 2009
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here's the php (pagination) and the CSS for the pagination part. Thanks
    PHP Code:
    <?php
        
    /*
            Place code to connect to your DB here.
        */
        
    $username="root";
    $password="root";
    $database="pagination";

    $dbh=mysql_connect(localhost,$username,$password) or die ('I cannot connect to the database because: ' mysql_error());
    @
    mysql_select_db($database);
        
    // include your code to connect to DB.

        
    $tbl_name="louie";        //your table name
        // How many adjacent pages should be shown on each side?
        
    $adjacents 3;
        
        
    /* 
           First get total number of rows in data table. 
           If you have a WHERE clause in your query, make sure you mirror it here.
        */
        
    $query "SELECT COUNT(*) as num FROM $tbl_name";
        
    $total_pages mysql_fetch_array(mysql_query($query));
        
    $total_pages $total_pages[num];
        
        
    /* Setup vars for query. */
        
    $targetpage "index.php";     //your file name  (the name of this file)
        
    $limit 15;                                 //how many items to show per page
        
    $page $_GET['page'];
        if(
    $page
            
    $start = ($page 1) * $limit;             //first item to display on this page
        
    else
            
    $start 0;                                //if no page var is given, set start to 0
        
        /* Get data. */
        
    $sql "SELECT image_path, title, image_text FROM $tbl_name ORDER BY id DESC LIMIT $start, $limit";
        
    $result mysql_query($sql);
        
        
    /* Setup page vars for display. */
        
    if ($page == 0$page 1;                    //if no page var is given, default to 1.
        
    $prev $page 1;                            //previous page is page - 1
        
    $next $page 1;                            //next page is page + 1
        
    $lastpage ceil($total_pages/$limit);        //lastpage is = total pages / items per page, rounded up.
        
    $lpm1 $lastpage 1;                        //last page minus 1
        
        /* 
            Now we apply our rules and draw the pagination object. 
            We're actually saving the code to a variable in case we want to draw it more than once.
        */
        
    while($row mysql_fetch_array($result)){
            echo 
    "<img src='{$row['image_path']}' alt=' ' /><br />"
            echo 
    "".$row['title']."<br />"
            echo 
    "".$row['image_text']."<br />";
        }  
        
    $pagination "";
        if(
    $lastpage 1)
        {    
            
    $pagination .= "<div class=\"pagination\">";
            
    //previous button
            
    if ($page 1
                
    $pagination.= "<a href=\"$targetpage?page=$prev\">« previous</a>";
            else
                
    $pagination.= "<span class=\"disabled\">« previous</span>";    
            
            
    //pages    
            
    if ($lastpage + ($adjacents 2))    //not enough pages to bother breaking it up
            
    {    
                for (
    $counter 1$counter <= $lastpage$counter++)
                {
                    if (
    $counter == $page)
                        
    $pagination.= "<span class=\"current\">$counter</span>";
                    else
                        
    $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";                    
                }
            }
            elseif(
    $lastpage + ($adjacents 2))    //enough pages to hide some
            
    {
                
    //close to beginning; only hide later pages
                
    if($page + ($adjacents 2))        
                {
                    for (
    $counter 1$counter + ($adjacents 2); $counter++)
                    {
                        if (
    $counter == $page)
                            
    $pagination.= "<span class=\"current\">$counter</span>";
                        else
                            
    $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";                    
                    }
                    
    $pagination.= "...";
                    
    $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
                    
    $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";        
                }
                
    //in middle; hide some front and some back
                
    elseif($lastpage - ($adjacents 2) > $page && $page > ($adjacents 2))
                {
                    
    $pagination.= "<a href=\"$targetpage?page=1\">1</a>";
                    
    $pagination.= "<a href=\"$targetpage?page=2\">2</a>";
                    
    $pagination.= "...";
                    for (
    $counter $page $adjacents$counter <= $page $adjacents$counter++)
                    {
                        if (
    $counter == $page)
                            
    $pagination.= "<span class=\"current\">$counter</span>";
                        else
                            
    $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";                    
                    }
                    
    $pagination.= "...";
                    
    $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
                    
    $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";        
                }
                
    //close to end; only hide early pages
                
    else
                {
                    
    $pagination.= "<a href=\"$targetpage?page=1\">1</a>";
                    
    $pagination.= "<a href=\"$targetpage?page=2\">2</a>";
                    
    $pagination.= "...";
                    for (
    $counter $lastpage - (+ ($adjacents 2)); $counter <= $lastpage$counter++)
                    {
                        if (
    $counter == $page)
                            
    $pagination.= "<span class=\"current\">$counter</span>";
                        else
                            
    $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";                    
                    }
                }
            }
            
            
    //next button
            
    if ($page $counter 1
                
    $pagination.= "<a href=\"$targetpage?page=$next\">next »</a>";
            else
                
    $pagination.= "<span class=\"disabled\">next »</span>";
            
    $pagination.= "</div>\n";        
        }
        echo 
    "\n".$pagination;
    ?>
    and separate pagination CSS
    Code:
    .pagination a{
    	font-family:Verdana, Geneva, sans-serif;
    	font-size:12px;
    	font-weight:bold;
    	white-space:nowrap;
    	text-align:right;
    	
    }
    
    div.pagination {
    	
    	padding: 3px;
    	margin: 3px;
    }
    
    div.pagination a {
    	
    	padding: 2px 5px 2px 5px;
    	margin: 2px;
    	border: 1px solid #AAAADD;
    	
    	text-decoration: none; /* no underline */
    	color: #000099;
    }
    div.pagination a:hover, div.pagination a:active {
    	border: 1px solid #000099;
    
    	color: #000;
    }
    div.pagination span.current {
    	padding: 2px 5px 2px 5px;
    	margin: 2px;
    		border: 1px solid #000099;
    		
    		font-weight: bold;
    		background-color: #000099;
    		color: #FFF;
    	}
    	div.pagination span.disabled {
    		padding: 2px 5px 2px 5px;
    		margin: 2px;
    		border: 1px solid #EEE;
    	
    		color: #DDD;
    	}

  • #11
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Feel like an idiot...

    OK...NOW FOR A REAL NEWBY...(not really, just feeling like one. Can one say 'brainfart'?)

    I'm TOTALLY stumped and I'm gonna feel incredibly stupid when the answer comes my way...

    /home/****/public_html/wp-content/themes/shopperpress/thumbs/

    Were the h-e double toothpick do I get the **** from?

    It's the server path for images and I feel like an idiot that I can't figure this out.

    Pocket

  • #12
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,540
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    Pocket ...

    Copy and paste the script below into notepad,
    save it as test.php and upload it. Then go to the URL.
    It will show you ALL of your server PHP settings, including
    the directory path that you're looking for.

    PHP Code:
    <?php
    phpinfo
    ();
    ?>


  •  

    Posting Permissions

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