PHP - Displaying Images From Result Set
Hi!
I want the image of my site to be clickable so that it shows the next image contained in the result set of the sql query. Code: [Select] <?php require_once('includes/connection.inc.php'); $conn = dbConnect(); $sql = 'SELECT filename FROM images ORDER BY image_id DESC LIMIT 1'; $msg = ''; if(!$sql) { echo "Something went wrong with the query. Please try again."; } $result = $conn->query($sql) or die(mysqli_error()); if(mysqli_num_rows($result) == 0) { header('Location: empty_blog.php'); $conn->close(); } else { $row = $result->fetch_row(); $image = $row[0]; } ?> <?php include('header.php'); ?> <div class="content main"> <img id="image" src="images/<?php echo $image; ?>"/> </div> <?php include('includes/footer.inc.php'); ?> All the filenames of the images are contained correctly in the $result variable, all I need to do now is to fetch the next image in the set. How would I go about this? Any help is greatly appreciated! Similar Tutorialsi have it set up so the user picks the year and session and then the database shows all the games in that specific year and session and then displays them with a link to their photo galleria and also shows the record(wins - losses - ties) but the way i have it know its not displaying the first result here is the code Code: [Select] <?php //declares $y as year played and $s as session $y = ' '; $s = ' '; //handles submition of form for picking year and session if (isset($_POST['submit'])) { $data = mysql_real_escape_string($_POST['session']); $exploeded = explode(",", $data); $y = $exploeded[0]; $s = $exploeded[1]; } //Query for the selection menu $squery = "SELECT DISTINCT(Year_Played), Sessions FROM pinkpanther_games"; $sresults = mysql_query($squery) or die("squery failed ($squery) - " . mysql_error()); //checks $y and $s to see if their is a vaule if ($y == ' '){$y = '20112012';} if ($s == ' '){$s = '2';} //Query for getting record and for getting all the appropriate info for displaying the games $query = " SELECT (SELECT COUNT(id) FROM pinkpanther_games WHERE Year_Played = $y AND Sessions = $s AND Win_Loss = 'Tie' ) AS 'Tie', (SELECT COUNT(id) FROM pinkpanther_games WHERE Year_Played = $y AND Sessions = $s AND Win_Loss = 'Win') AS 'Win', (SELECT COUNT(id) FROM pinkpanther_games WHERE Year_Played = $y AND Sessions = $s AND Win_Loss = 'Loss') AS 'Lose', Opponent AS Opponent, Score AS Score, Gallery_no AS Gal, Win_Loss AS Record FROM pinkpanther_games WHERE Year_Played = $y AND Sessions = $s"; $results = mysql_query($query) or die("Query failed ($query) - " . mysql_error()); $row_a = mysql_fetch_assoc($results); //Set record variables $wins = $row_a['Win']; $loss = $row_a['Lose']; $tie = $row_a['Tie']; //creates from and selection menu for year and session echo "<tr><td colspan='2'><form method='post' action=''><select name='session' class='txtbox2'>"; while ($srow = mysql_fetch_assoc($sresults)){ echo "<option value='" . $srow['Year_Played'] . "," . $srow['Sessions'] . "'>" . $srow['Year_Played'] . " Session " . $srow['Sessions'] . "</option>"; } echo "</select><input type='submit' name='submit' value='Go' class='txtbox2' /></form></td></tr>"; //displays record echo "<tr><td colspan='2'>" .$wins . " - " . $loss . " - " . $tie . "</td></tr>"; echo "<tr></tr>"; //displays games and scores in appropriate year and session while ($row = mysql_fetch_assoc($results)){ $opp = $row['Opponent']; $score = $row['Score']; $gal = $row['Gal']; $wlt = $row['Record']; //styles games acording to if win lose or tie if ($wlt == 'Win'){ echo "<tr><td class='win'>"; echo "<a href='galleries.php?g=$gal'" . $gal . " >" . $opp . "</a>"; echo "</td><td class='win'>"; echo $score . ""; echo "</td></tr>"; } if ($wlt == 'Loss'){ echo "<tr><td class='loss'>"; echo "<a href='galleries.php?g=$gal'" . $gal . " >" . $opp . "</a>"; echo "</td><td class='loss'>"; echo $score . ""; echo "</td></tr>"; } if ($wlt == 'Tie'){ echo "<tr><td class='tie'>"; echo "<a href='galleries.php?g=$gal'" . $gal . " >" . $opp . "</a>"; echo "</td><td class='tie'>"; echo $score . ""; echo "</td></tr>"; } } ?> i cannot figure out why my first result is not displaying properly it successfully shows all results but me first myurl.com/other.php?id=2 now showing any thing kindly help to solved this problem! it seems like problem is in variable $http$ids but dunno how to combine them to get result $Ids always b numeric number <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); $http = "myurl.com/other.php?id=" ; $conn=odbc_connect('greeting','',''); if (!$conn) {exit("Connection Failed: " . $conn);} $sql="SELECT * FROM mytable"; $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} echo "<table border= 1><tr>"; echo "<th>ID</th>"; echo "<th>Like</th>"; echo "<th>title</th></tr>"; while (odbc_fetch_row($rs)) { $ids=odbc_result($rs,"ID"); $title=odbc_result($rs,"title"); echo "<tr><td>$ids</td>"; echo "<td><fb:like href=\"$http$ids\" layout=\"button_count\" show_faces=\"false\" width=\"100\" font=\"tahoma\" colorscheme=\"dark\"></fb:like> </td>"; echo "<td>$title</td></tr>"; } echo "</table>"; odbc_close($conn); ?> Hi, I am new to php but not to programming. I created a script on a windows platform which connects to the mysql database and returns the results of a table. A very basic script which I wrote to simply test my connection worked. The script works fine on my windows machine but not on my new mac. On the mac it simply does not display any records at all. I know that the database connection has been established because there is no error but I can not see why the result set is not being displayed on screen, as I said it worked fine on my windows machine. The Mac has mysql (with data) and apache running for php. Please could someone help as I have no idea what to do now? Script below: Code: [Select] $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'root'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'test'; mysql_select_db($dbname); mysql_select_db("test", $conn); $result = mysql_query("SELECT * FROM new_table"); while($row = mysql_fetch_array($result)) { echo $row['test1'] . " " . $row['test2'] . " " . $row['test3']; echo "<br />"; } mysql_close($con); Hi I am building a product search engine using MySql and PHP (Jquery / AJAX). As i am getting the search results i wondered is it possible to count the instances of a category? For example: If i search for "Dell Laptops" i get 400+ results back because it has lots of laptops and accessories. What i am aiming for it to do is while looping through look at the categories and if its the first instanc eof it i want it to begin a count. until it has finished looping and then i can display it. Results: 436 [ Laptops(127) - Accesories (244) - Components(65) ] Im not even sure where to start here so any advice will be helpful Here is the code im using to generate the search: $id = str_replace(" ", "%", "$id"); $q = "SELECT * FROM products WHERE prod_name LIKE '%$id%' order by fee asc LIMIT 20"; Hello! I am busy developing a script that returns all users that have the cell "Available" set to 1 but I am unsure how to do this, I am familiar with basic SQL and I have made this: $sql = "SELECT * FROM `clans` WHERE `available` =1 LIMIT 0 , 30"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); echo ($row['name']); but it only displays information from the first row found, and I want it to display all the rows found, how can I do this? Thanks - GreenFanta This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=330221.0 Hello all,
Am trying to calculate some data and display the result of the current month in a chart form. i just don't know how to get the current month. this is not working..
<?php include('mysql_connect.php'); $date = 'MONTH(CURRENT_DATE())'; $status = 'paid'; //mysql_select_db("hyprops", $con); $query = mysql_query("SELECT sum(amount) 'amount', department FROM requisition WHERE status = '$status' AND date='$date' "); $category = array(); $category['name'] = 'department'; //$series1 = array(); //$series1['name'] = 'actual'; $series2 = array(); $series2['name'] = 'amount'; //$series3 = array(); //$series3['name'] = 'Highcharts'; while($r = mysql_fetch_array($query)) { $category['data'][] = $r['department']; // $series1['data'][] = $r['actual']; $series2['data'][] = $r['amount']; // $series3['data'][] = $r['highcharts']; } $result = array(); array_push($result,$category); //array_push($result,$series1); array_push($result,$series2); //array_push($result,$series3); print json_encode($result, JSON_NUMERIC_CHECK); mysql_close($con); ?>Please how can i solve this issue? Thanks in advance Hello - Suppose I had a MySQL result set that was something like this: ITEM: COLOR: ball red ball blue book red book green book black If I were to use the code: Code: [Select] do { echo $row_myQuery['item'] . " - " . echo $row_myQuery['color'] . "<br />"; } while ($row_myQuery= mysql_fetch_assoc($myQuery)); Then I end up with this: Code: [Select] ball - red ball - blue book - red book - green book - black MY QUESTION: What I'd like to know is, how could I re-write that php code so that I could get an output like this?: Code: [Select] ball - red, blue book - red, green, black Thanks! My first post and I am not a programmer or familiar with the correct vocabulary associated with php. I thought I would give the following a go as it is the holidays and my php programmer is no where to be found. I am ok at following scripts to get a simple result, unfortunately the listing manager I am using is coded with Zend. The system is built on a curve2.com and I am pretty much stuck with what exists. I would like to add some more php outputs, which I don't think are too complicated, but I can't seem to get my head around pulling information from multiple tables in to 1 result. I am trying to pull all the data from a 'Listing' table in to 4 columns, which works ok. What I can not get around is trying to link up the 'Image' table to my 'Listing' table and pulling the main image in to my php output. There is a common 'id' but each 'id' has 4+ images and I would like to select the just main one and resize it smaller. So far, I have the following, which I have put together from following examples on this website. 'id' is the unique id for each record. <? $query="select * from listings"; $result=mysql_query($query); $cols=4; echo "<table>"; do{ echo "<tr>"; for($i=1;$i<=$cols;$i++){ $row=mysql_fetch_array($result); if($row){ $img = $row['image_path']; ?> <td> <table> <tr valign="top"> <td><img src="images/<?=$img ?>" /></td> <td> <b><a href="http://www.coralbayrealestate.com/search/show.php?id=<?=$row['id'] ?> "> <?=$row['title'] ?> </a> </b><br /> <?=$row['state'] ?><br /> $USD <?=number_format ($row['price']) ?><br /> </td> <td width="20"> </td> </tr> </table> </td> <? } else{ echo "<td> </td>"; } } } while($row); echo "</table>"; ?> The image table, called 'images' has 3 fields 'id' - individual photos id's 'listid' - Id record to the listing table 'fname' - image name Any guidance would be much appreciated on how to get the primary image on to the table. Happy holidays and best wishes to all for 2011. Sandydr So I am trying to display an image from a database (I know it's not the best idea but it's what I was told to do). Anyway I'm having problems displaying it. Here is the code for displaying the image. $cat = $_GET['cat']; include 'includes/openDbConn.php'; $sql = 'SELECT * FROM CushionsCategories WHERE CushionCategory = "'.$cat.'"'; echo $sql; $result = mysql_query($sql); echo '<table>'; while($val = mysql_fetch_assoc($result)){ $cush = 'SELECT * FROM Cushion WHERE SKU = "'.$val['CushionSKU'].'"'; echo $cush; $cushres = mysql_query($cush); $cushval = mysql_fetch_assoc; $img = 'SELECT * FROM Images WHERE SKU = "'.$val['CushionSKU'].'"'; echo $img; $imgres = mysql_query($img); $imgval = mysql_fetch_assoc($imgres); if( $i % 3 == 0 ) { echo '</tr><tr>'; } echo '<td><img src="image.php?sku='.$val['CushionSKU'].'" name="'.$imgval['FileName'].'" description="'.$imgval['Description'].'" /></td>'; } echo '</tr></table>'; and the page that gets the image: $sql = 'SELECT Image FROM Images WHERE SKU = "'.$sku.'"'; //echo $sql; $result = mysql_query($sql) or die("Invalid query: " . mysql_error()); // set the header for the image header("Content-type: image/jpeg"); echo mysql_result($result, 0); Thanks for any help in advance. Hello I am using this script right here http://www.nearby.org.uk/sphinx/search-example5-withcomments.phps and am trying to show images from my db but I can only get it to show the first image. Does anyone know how to make it show all images if images even exist for that particular search result? I changed the query to $CONF['mysql_query'] = ' SELECT l.link_id AS id, l.title AS title, l.fulltxt AS body, l.url AS url, m.media_id AS im_id, m.title AS im_title, m.thumb_link AS im_t_link FROM search1_links AS l LEFT JOIN search1_media AS m ON (m.link_id = l.link_id) WHERE l.link_id IN ($ids) '; and added if ($row['im_id']) { echo '<img src="'.($row['im_t_link']).'" height="100px" width="100px"> '; } right here //Actully display the Results print "<ol class=\"results\" start=\"".($currentOffset+1)."\">"; foreach ($ids as $c => $id) { $row = $rows[$id]; $link = htmlentities(str_replace('$id',$row['id'],$CONF['link_format'])); print "<li><a href=\"$link\">".htmlentities($row['title'])."</a><br/>"; if ($CONF['body'] == 'excerpt' && !empty($reply[$c])) print ($reply[$c])."</li>"; else if ($row['im_id']) { echo '<img src="'.($row['im_t_link']).'" height="100px" width="100px"> '; } print htmlentities($row['body'])."</li>"; } print "</ol>"; if ($numberOfPages > 1) { print "<p class='pages'>Page $currentPage of $numberOfPages. "; printf("Result %d..%d of %d. ",($currentOffset)+1,min(($currentOffset)+$CONF['page_size'],$resultCount),$resultCount); print pagesString($currentPage,$numberOfPages)."</p>"; } Can anyone help me to be able to display all images if they exist? Thanks. I had this page working fine where it retrieves a set of images from the database depending on what thumbnail was click on the previous page. Now I am trying to add an edit and delete button to each of the pictures and it will not display any of it now! This is the code I am using: Code: [Select] <?php $id = $_GET[id]; ?> <?php $max_items = 16; /* max number of news items to show */ require_once('config.php'); $db = mysql_connect (DB_HOST,DB_USER,DB_PASSWORD); if(!$db) { die('Failed to connect to server: ' . mysql_error()); } mysql_select_db (DB_DATABASE,$db); function displayNews($all = 0) { global $db, $max_items; if ($all2 == 0) { /* query for news up to $max_items */ $query13 = "SELECT image,id,description,projectcode,thumbnail " . "FROM project WHERE projectcode='$id' ORDER BY id DESC LIMIT $max_items"; } else { /* query for all news */ $query13 = "SELECT image,id,description,projectcode,thumbnail " . "FROM project WHERE projectcode='$id' ORDER BY id DESC"; } $result13 = mysql_query($query13) or print("<p>Error fetching entries from the database, error: " . "Statement: " . $query13 . "</p>" . mysql_error()); while ($row13 = mysql_fetch_array($result13)) { $title = htmlentities ($row13['description']); $news = nl2br (strip_tags ($row13['projectcode'], '<a><b><i><u>')); $image = $row13['image']; $thumbnail = $row13['thumbnail']; $id = $row13['id']; /* display the data */ echo "<div class='portfolioproject'>";?> <div class='boxgrid captionfull'> <a id="<?php echo $id ?>" class="example_group" href="images/gallery/<?php echo $image ?>" title="<?php echo $title ?>" rel="gallery"><img alt="" src="images/gallery/<?php echo $thumbnail ?>" width="122px" height="122px"</a> </a>} <?php //Check whether the session variable SESS_MEMBER_ID is present or not if(isset($_SESSION['SESS_MEMBER_ID']) || (!trim($_SESSION['SESS_MEMBER_ID']) == '')) { echo "<form class='editbtn' action='editportfolio.php' method='POST'>"; echo "<input type='hidden' name='idf' value='$id' />"; echo "<input src='images/editbtn.png' type='image' value='Edit' />"; echo "</form>"; echo "<form class='editbtn' action='deleteportfolio.php' method='POST'>"; echo "<input type='hidden' name='ide' value='$id' />"; echo "<input src='images/delbtn.png' type='image' value='Delete' />"; echo "</form>"; } else { echo ""; } echo "</div>"; } /* if not displaying all news, give a link to do so */ if ($all == 0) { echo "<div class='show_all'><a class='show' href=\"{$_SERVER['PHP_SELF']}" . "?action=all\">Show all</a></div>\n"; } } /* this is where the script decides what do do */ echo "\n"; switch($_GET['action']) { case 'all': displayNews(1); break; default: displayNews(); } echo "\n"; ?> <?php //Check whether the session variable SESS_MEMBER_ID is present or not if(isset($_SESSION['SESS_MEMBER_ID']) || (!trim($_SESSION['SESS_MEMBER_ID']) == '')) { echo "<span class='show_all'>"; echo "<a class='show' href='admincp.php'> Admin</a>"; echo "</span>"; echo "<span class='show_all'>"; echo "<a class='show' href='logout.php'> Logout</a>"; echo "</span>"; } else { echo ""; } ?> No error messages are displayed, only the 'show all' button, and the 'admin' and 'logout' buttons if signed in! Any help on this would be much appreciated! Thank you Martin Hi All take a look at http://www.buypromo.co.uk/index.php in IE 7 or 8 the images at the bottom of the page are not showing up, whereas therest are find, any ideas? thanks Guys, i need your help,i have one table employee with empno=number,image=blob, images uploaded sucessfully and insert into database but when i am trying to retrieve records image are not displaying instead of it some encrypted form shows please help me hi all I am finishing off the final touches to my PHP postcard script and want to be able to display thumb file types only I have found a script to resize the images but this creates larger ones so i want to be able to switch between the two. <?php // CHANGE PARAMETERS HERE BEGIN $senderName = " Holidays From Home "; // Eg.: John's Postcards $senderEmail = "holidaysfromhome@voluntary.awardspace.co.uk"; // Eg.: john@postcard.com // Change only if you have problems with urls $postcardURL = "http://".$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"]; // CHANGE PARAMETERS HERE END $result = 0; $msg = ""; $msg1 = ""; $pic = ""; function displayPhotos() //edit photos and change image sizes { global $pic; $columns = 5; $act = 0; $act1 = 0; $sel = 0; // Open the actual directory if($handle = opendir("thumbs")) { // Read all file from the actual directory while($file = readdir($handle)) { if(!is_dir($file)) { if(isset($pic[1])) { if($pic[1] == $act1){$sel = "checked";} else{$sel = "unchecked";} } if($act == 0){echo "<tr>";} echo "<td align='center'><img src='thumbs/$file' alt='postcard' BORDER =1 /><br/><input type='radio' name='selimg' value='$file,$act1' $sel/></td>"; //displays the images $act++; $act1++; if($act == $columns){$act = 0;echo "</tr>";} } } echo "</tr>"; } } ?> my thumbnail images all end in (_th.jpg) and my large files all end in (.jpg). I am really stuck any help would be much appreciated Hey guys, I wrote a code for displaying images in columns, but for some reason it's not working. Can you take a look and tell me what I'm doing wrong? $i = 0; if($i % 4 == 0){ echo ' <td width="25%" align="center" valign="top"> <a href= "'.$slika_velika.''.$slika_v.'" rel="lytebox" title="'.$naziv.' - '.$mjesto.' - '.$medalja.'" target="_blank"><img src="'.$slika_mala.''.$slika_m.'"width="200" height="150" border="0"></a><br> </td> <td width="25%" align="center" valign="top"> '.$naziv.' - '.$mjesto.' </td> <td width="25%" align="center" valign="top"> '.$medalja.' </td><br /> '; echo '</tr><tr>'; } $i++; } The output I'm getting now is one image below another. I would like to display them one next to another. Please help!!! I'm having real problems with a rss box that I'm trying to incorporate onto the homepage of our website... The code I'm using as a basis I got from here - http://www.dynamicdrive.com/dynamicindex18/rssdisplaybox/index.htm It worked okay displaying title, date and content, however, we wanted it to display the first image of the blog entry as well. In the outputbody.php (the file that dictates what is shown in the rss box) I incorporated this code (shown in bold EDIT: with the bold tags around it! ) - Code: [Select] <?php //Function for ouputting the body of each RSS item displayed (inside loop)- DynamicDrive.com //For syntax pf bpdu, see: http://simplepie.org/docs/installation/from-scratch/ and http://simplepie.org/docs/reference/ //Function by default defines 3 different body outputs (templates). Modify or add additional templates as desired [b] function get_image($text) { $imageurl=""; preg_match('/<\s*img [^\>]*src\s*=\s*[\""\']?([^\""\'>]*)/i' , $text, $matches); $imageurl=$matches[1]; if (!$imageurl) { preg_match("/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $text, $matches2); $youtubeurl = $matches2[0]; if ($youtubeurl) $imageurl = "http://i.ytimg.com/vi/{$matches2[3]}/1.jpg"; } return $imageurl; }[/b] function shortencontent($content, $len=40){ if(strlen($content) > $len){ return substr($content, 0, $len - 6) . ' . . .'; } else { return $content; } } function outputbody($item, $template=""){ if ($template=="" || $template=="default"){ //DEFAULT TEMPLATE ?> <div class="rsscontainer"> <div class="rsstitle"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></div> <div class="rssdate"><?php echo $item->get_date('d M Y g:i a'); ?></div> <div class="rssdescription"><?php echo shortencontent($item->get_description(), 400); ?></div> [b]<div class="rssimage"><?php echo get_image(); ?></div>[/b] </div> <?php } //end default template else if ($template=="titles"){ //"TITLES" TEMPLATE ?> <div class="rsscontainer"> <div class="rsstitle"><a href="<?php echo $item->get_permalink(); ?>" target="_new"><?php echo $item->get_title(); ?></a></div> <div>Category: <?php echo $item->get_category(); ?></div> </div> <?php } //end titles template else if ($template=="titlesdates"){ //"TITLESDATES" TEMPLATE ?> <div class="rsscontainer"> <span class="rsstitle"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></span> <span class="rssdate"><?php echo $item->get_date('m/d/y g:i a'); ?></span> </div> <?php } //end titlesdates template else if ($template=="mytemplatename"){ //"mytemplatename" TEMPLATE ?> //DEFINE ADDITIONAL CUSTOM TEMPLATE(s) USING SAME LOGIC STRUCTURE AS ABOVE //For syntax of template body, see SimplePie docs: http://simplepie.org/docs/installation/from-scratch/ and http://simplepie.org/docs/reference/ <?php } else die ("No template exists with such name!"); } //Closing function bracket ?> While it creates an imagebox nothing is shown and when you open the empty image box in the browser it displays the following URL - http://www.oururl.%20.%20.%20.</div>%20%20%20%20%20%20%20%20<div%20class= I have little PHP knowledge but don't really know where to start with this... please can anyone help or point me in the right direction. I appreciate that it is frustrating dealing with someone with limited knowledge but please have a little patience with me... Cheers people! I am trying to display two images per row. Will add in table tags later so it will look nicer. Anyway, it is leaving off the second image. So, I have 6 images and image number two is blank.
$dirname = "Files/$listingid/images/"; $images = glob($dirname."*"); /* $html .= '<table width="100%">'; foreach($images as $image){ $html .= "<tr><td><center>"; $html .="<img src=\"$image\" width=\"300\">"; $html .= "</a></center></td>"; $html .= "</td></tr>"; } $html .= "</table>"; */ $countImages = count($images) ; $imagesPerRow = 2; for ($i = 0 ; $i < $countImages; $i++) { //display image here $image = $images[$i] ; $html .= "<img width = \"200\" src='$image'>" ; if ($i % $imagesPerRow == 0) { //have displayed an entire row $html .= '<br>' ; } } Hi, sincerely hope i can get some help here. im pulling some images from my database but i want to display them horizontally for example 3 or 4 images in a row then it moves to a new row. so far i have only being able to display the images vertically. I am not sure if i should be using css or there is a way to do it with php. would appreciate any assistance. I have been tryin to get this done for sometime now and i need to complete this project. I'm new at this ok I got the images to upload to the directory on the server. now I got some code to try to display the image on the same page after you submit it to the directory. so it's like, submit form-> images goes in server directory->echoes back out on same page but just above the upload form. please any help greatly appreciated. thanks. here is the code so far. Code: [Select] <?php // An Example about listing Images. $dir = "uploads/"; $odir = opendir($dir); while($file = readdir($odir)){ if(filetype($file) == "image/JPEG") { echo $file; } ?> <!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=utf-8" /> <title>Untitled Document</title> </head> <body> <p>UPLOAD YOUR PORTFOLIO AND PRICES</p> <p> </p> <p> <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form></p> </body> </html> |