Current location: Hot Scripts Forums » Programming Languages » PHP » display images from file


display images from file

Reply
  #1 (permalink)  
Old 09-05-10, 03:51 PM
williamh26 williamh26 is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 132
Thanks: 2
Thanked 0 Times in 0 Posts
display images from file

I have images in a filed named images i have this code but it does no product any results can you guys help me pleaseeee

Code:
<?php

 $error = "Could not connect to the database";
 mysql_connect('localhost','root','')   or die($error);
 mysql_select_db('hairsalon') or die($error);
 //max displayed per page
 $per_page = 2;

 //get start varible

 $start = $_GET['start'];

 //count records

 $record_count = mysql_num_rows (mysql_query("SELECT * FROM products"));

 //count max pages

 $max_pages = $record_count / $per_page; // may come out as decimal

 if (!$start)
    $start =0;

 //display data

 $get = mysql_query("SELECT  prodid, picturename  FROM products ORDER BY name LIMIT $start, $per_page");


  while ($row = mysql_fetch_assoc($get))
  {
     // get data
        $prodid = $row['prodid'];
       
        $picturename = $row['picturename'];

      echo "<a href=\"index.php?&content=updatetutor&id=$prodid\">";
    
      echo strtoupper("<td class = 'servBodL' width= 30%>$picturename</td>");
      echo "<p>";
  }
    echo" </table> ";
   echo"<br>\n";
   //SETUP PREV AND NEXT VARIABLES

   $prev = $start - $per_page;

   $next = $start + $per_page;

   // show pre button

   if(!($start< 1))

   echo "<a href='index.php?content=ourproducts&start=$prev'>Prev</a>\n";
   //show page numbers

   //set variable for first page

   $i=1;

   for($x=0; $x<$record_count; $x=$x+$per_page)
   {

     if($start!=$x)

     echo "<a href='index.php?content=ourproducts&start=$x'>$i</a>\n";

     else

     echo "<a href='index.php?content=ourproducts&start=$x'>$i</b></a>\n";
     $i++;
   }


    if (!($start>=$record_count=$per_page))
   echo "<a href='index.php?content=ourproducts&start=$next'>Next</a>\n";

   echo "<br>";
?>

Last edited by digioz; 09-05-10 at 06:23 PM. Reason: Use code tags
Reply With Quote
  #2 (permalink)  
Old 09-05-10, 04:01 PM
erthomp143 erthomp143 is offline
Newbie Coder
 
Join Date: Sep 2010
Location: San Jose, California
Posts: 25
Thanks: 0
Thanked 2 Times in 2 Posts
Ok, I take it that you have a database that holds the image name and that image is stored in a folder some where.
If that is correct you need something like this....
Code:
<img src="pathtofile/$picturename">
Reply With Quote
  #3 (permalink)  
Old 09-05-10, 05:02 PM
williamh26 williamh26 is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 132
Thanks: 2
Thanked 0 Times in 0 Posts
the pictures are the folder called images

Code:
echo "<td><img src='C:\wamp\www\hairsalon2\images\$picturename'></td>";

but still does not show

Last edited by digioz; 09-05-10 at 06:23 PM.
Reply With Quote
  #4 (permalink)  
Old 09-06-10, 03:20 AM
erthomp143 erthomp143 is offline
Newbie Coder
 
Join Date: Sep 2010
Location: San Jose, California
Posts: 25
Thanks: 0
Thanked 2 Times in 2 Posts
if your sure your path is correct, then
Code:
echo "<td><img src='C:\wamp\www\hairsalon2\images\".$picturename."'></td>";

if that doesn't work, try this
Code:
echo "<td><img src='images/".$picturename."'></td>";
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What script do I need for ths project? (Upload images script?) stevef22 PHP 2 10-30-09 05:25 PM
Display 10 random images from DIR with HTML Code for Image cyclotron Script Requests 2 05-14-06 08:59 AM
Error message not getting displayed. sanjeet Windows .NET Programming 0 12-20-05 10:48 AM
How to display images for each day in total year ajay007_bond JavaScript 2 06-18-05 05:04 AM


All times are GMT -5. The time now is 08:19 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.