PHP - Display More The Just .jpg From Thumbs With Glob()?
Hi I am trying display thumbs from a directory, BUT , I cannot figure out how to show more then just .jpg. For example, how could I make this code show the following file extensions, .jpg .png .gif ? Here is the code spinet and if you could advise that would be awesome Thanks so much for your time in advance Code: [Select] <?php $largeArray = glob("images/*.jpg"); $counter = 0; foreach (array_slice(glob("images/thumbs/*.jpg"),0,600) as $thumb) { echo ("<div class='thumbgall'><a href='$largeArray[$counter]' rel='lightbox'><img src='$thumb'/></a></div>"); $counter++; } ?> Similar TutorialsI am attempting to us glob to display contents of a users folder using a session variable. Example: I have a session variable called department Code: [Select] $row_fullname['department']; In department I have the name of the department the user belongs to such as: office, plant, maintenance, and groundskeeping I created a folder called docs inside of docs there are 4 subfolders called office, plant, maintenance, and groundskeeping I found this code which will display the contents of the folder: Code: [Select] <?php $files = glob( './docs/office/*.*' ); foreach ( $files as $file ) { echo '<a href="./docs/office/' . basename( $file ) . '"target="_blank">' . basename( $file ) . '</a><br />'; } ?> The above code works fine, but I would like it to only display the contents of a departments folder only if the user is part on that department. Here is an example that I know is completely wrong but it may help explain what I am trying to do. Code: [Select] <?php ]<?php $files = glob( './docs/echo $row_fullname['department'];/*.*' ); foreach ( $files as $file ) { echo '<a href="./docs/echo $row_fullname['department'];/' . basename( $file ) . '"target="_blank">' . basename( $file ) . '</a><br />'; } ?>Thanks for your time Hello, I'm trying to make a little piece of code that will search for all files (including subdirectories) ending with .txt and set them to 777 foreach (glob("*.txt") as $file) { system("chmod 777 '$file'"); } Am I on the right path? thanks what i'm trying to do here is what ever globistr find for casing, rename the folder to lowercase. is this correct the code below Code: [Select] $chid = (strtolower($_POST['chid'])); $findbatch = globistr($chid); $results = glob($findbatch); if ( !empty($results) ) { $result = $results[0]; rename("/temp/files/" . $results . "/", "/temp/files/" . strtolower($chid) . "/"); } else { $missing_dir = 'Folder containing files, Not Found: ' . $chid . "\r"; $errfile = fopen("/rec/" . $chid . "-errlog.txt", "a"); fwrite($errfile, $missing_dir . "\n"); fclose($errfile); exit(); } I need to create a function that lists subfolders of a given folder, that contain at least one .txt file. I found the following function, which displays a list of file that match a pattern in a directory tree: function find($dir, $pattern){ $dir = escapeshellcmd($dir); $files = glob("$dir/$pattern"); foreach (glob("$dir/{.[^.]*,*}", GLOB_BRACE|GLOB_ONLYDIR) as $sub_dir) //look in subdirectories { $arr = find($sub_dir, $pattern); //recursive call $files = array_merge($files, $arr); // merge array with files from subdirectory } return $files; } $txtFiles=find("project/sys","*.txt"); foreach ($txtFiles as $txtFile) { echo '<h2>'.$txtFile.'</h2>'; //display all text files } My question is, how do I change the function to return only folders that contain at least one text file. But, the functions should look inside child folders of "project/sys" and list a child folder only once if that folder or any of its child folders contain at least one text file. I'll give an example of the output I'm looking for: Folder list project/sys/diagram project/sys/bin project/sys/scripts project/sys/styles project/sys/meta The above folders may not contain a text file directly, but their children folders do. However, I'm not interested in their children folder and I want to list the above level folder only once for each folder. Thanks in advance I would like to go from a glob list, which is working great, to a download link kinda thing. So, The glob list is shown and each file has a link. The problem is that the download folder for PHP is apparently NOT within my website, but in another portion of the server. Also that when I modify the code to work within the website, it doesnt work. Probably because of the glob array. Anyone have an idea on how to fix this? Code: Code: [Select] <?php $dir = "/downloads/"; $files = glob($dir."*.zip", GLOB_NOSORT); // echo'<select name="Files">'; foreach($files as $file){ // echo'<option value="'.$file.'">'.basename($file).'</option>'; echo '<p><a href="/downloads/'.basename($file).'">'.basename($file).'</a></p>'; }; // echo'</select>'; ?> I am using glob() to see a list of .zip files on my website. I wanted to display them on a drop down list. I got that working fine, but the file path shows up with it. Any idea how to remove it? Here is the code I am using. Code: [Select] <?php $dir = "/downloads/"; $files = glob($dir."*.zip", GLOB_NOSORT); echo'<select name="Files">'; foreach($files as $file){ echo'<option value="'.$file.'">'.$file.'</option>'; } echo'</select>'; ?> Hi, I want to store files to variable array using glob() like $files[0] = xyz.txt $files[1] = pqr.txt . . . $files[n] = nfile.txt I know how to list files from directory using glob() Code: [Select] <?php foreach (glob("*.txt") as $filename) { echo "$filename size " . filesize($filename) . "\n"; } ?> How can I do that ? Hi guys, Im trying to resize and create thiumbnails while uploading an image but it doesnt work, as i am new to php and i have followed other tutorials, i might have made a mistake which i dont understand. i have a table called test (find attached image) and what i need is when i upload an image, it copies the location of both image and on fly created thumb into my database i appreciate your help & please excuse me for messed up code <?php session_start(); include ("../global.php"); //welcome messaage echo "Welcome, " .$_SESSION['username']."!<p>"; $username=$_SESSION['username']; //get user id & credit limit $query=mysql_query("SELECT id FROM users"); while($row = mysql_fetch_array($query)) { $id = $row['id']; echo $id; } $credit=mysql_query("SELECT credit FROM users"); while($row = mysql_fetch_array($credit)) { $creditcheck = $row['credit']; echo "your credit is: $creditcheck"; } $reference = rand(11111111,99999999); //image1 define ("MAX_SIZE","100"); define ("WIDTH","150"); define ("HEIGHT","100"); function make_thumb($img_nameone,$filenameone,$new_w,$new_h) { $ext=getExtension($img_nameone); if(!strcmp("jpg",$ext) || !strcmp("jpeg",$ext)) $src_imgone=imagecreatefromjpeg($img_nameone); if(!strcmp("png",$ext)) $src_imgone=imagecreatefrompng($img_nameone); $old_x=imageSX($src_imgone); $old_y=imageSY($src_imgone); $ratio1=$old_x/$new_w; $ratio2=$old_y/$new_h; if($ratio1>$ratio2) { $thumb_w=$new_w; $thumb_h=$old_y/$ratio1; } else { $thumb_h=$new_h; $thumb_w=$old_x/$ratio2; } $dst_imgone=ImageCreateTrueColor($thumb_w,$thumb_h); imagecopyresampled($dst_imgone,$src_imgone,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); if(!strcmp("png",$ext)) imagepng($dst_imgone,$filenameone); else imagejpeg($dst_imgone,$filenameone); imagedestroy($dst_imgone); imagedestroy($src_imgone); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if ($creditcheck<=0) Header("Location: buy-credit.php"); else if ($creditcheck>=0){ if(isset($_POST['register'])) $submit = mysql_query("INSERT INTO test (reference) VALUES ('$reference')"); { $image=$_FILES['myfileone']['nameone']; if ($image) { $filename = stripslashes($_FILES['myfileone']['nameone']); $extension = getExtension($filenameone); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) { echo '<h1>Unknown extension!</h1>'; $errors=1; } else { $size=getimagesize($_FILES['myfileone']['tmp_name']); $sizekb=filesize($_FILES['myfileone']['tmp_name']); if ($sizekb > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } $image_nameone=time().'.'.$extension; $newname="rentimages/".$image_nameone; $copied = copy($_FILES['myfileone']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; } else { $thumb_name='rentimages/thumbs/thumb_'.$image_name; $thumb=make_thumb($newname,$thumb_name,WIDTH,HEIGHT); }} }} if(isset($_POST['register']) && !$errors) { $locationone="rentimages/$nameone"; $image1 = mysql_query ("UPDATE test SET image1='$newname', thumb='$thumb_name' WHERE reference='$referenceran'"); } } } ?> <html> <body> <form action='imagetests.php' method='POST' enctype='multipart/form-data'> File: <input type='file' name='myfileone'><p /> <input type='submit' name='register' value='Update'> <p /> </body> </html> Hi folks... Trying to get a bit of gallery code to work the way I want it to and would appreciate some feedback from more experienced folks... What it's doing, or is supposed to be doing, is taking a thumb called 'thumb.jpg' from each folder within my gallery folder and displaying it in reverse order on a page. I only want a maximum number of images to display on the page at any one time, so that if I end up uploading loads of folders in the future, it will only display a set amount of thumbs on one page. I want the thumbs displayed in reverse order, so that the newest appears first. Here's the code... and as far as I can see, it should work... and I'm sure I have had it working in the past (I've just come back to working on it after a while) however now, it's putting the thumbs in a random order. My folders are all in the gallery folder, and are named 001, 002, 003, 004, 005, 006, etc. I want them to display with 006 at the top and to de-increment, but only for the most recent 16 folders. Code: [Select] <?php $images = "gallery/"; # Location of galleries $cols = 4; # Number of columns to display $max = 16; # Maximum number of galleries to show if ($handle = opendir($images)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $files[] = $file; } } closedir($handle); } $colCtr = 0; echo "<div id=\"updates\"><table><tr>"; $c = count($files) - 1; //$c = the number of files in the array, minus 1 = highest index in the array. for($i = $c; $i > ($c - $max); $i--) //$i = $c, $i is greater than the array count minus $max, $i de-increments on each loop. This will give us a countdown for the number of galleries required. { if($colCtr %$cols == 0) echo "</tr><tr>"; echo "<td><img src=\"" . $images . $files[$i] . "/thumb.jpg\" width=\"240px\" height=\"180px\" alt=\"" . $alt . "\" /></td>"; //echo'ing out the $file[$i] on the loop, will give us the last required number of files in the file array. $colCtr++; } echo "</table></div>" . "\r\n"; ?> I also want to work out how to set a start number for the galleries, so that I can paginate them... so, once I have 36 galleries (for example) I can have the latest 16 on the first page, and the next 16 on the 2nd page... and the 4 that run over would drift off into obscurity until I get round to deleting them... maybe with a variable named $min... How would I do that...? Like this, or differently? : Code: [Select] <?php $images = "gallery/"; # Location of galleries $cols = 4; # Number of columns to display $min = 16; # Minimum number of galleries to show $max = 32; # Maximum number of galleries to show if ($handle = opendir($images)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $files[] = $file; } } closedir($handle); } $colCtr = 0; echo "<div id=\"updates\"><table><tr>"; $c = count($files) - 1; //$c = the number of files in the array, minus 1 = highest index in the array. for($i = $c; ($i + $min) > ($c - $max); $i--) //$i = $c, $i plus $min is greater than the array count minus $max, $i de-increments on each loop. This will give us a countdown for the number of galleries required. { if($colCtr %$cols == 0) echo "</tr><tr>"; echo "<td><img src=\"" . $images . $files[$i] . "/thumb.jpg\" width=\"240px\" height=\"180px\" alt=\"" . $alt . "\" /></td>"; //echo'ing out the $file[$i] on the loop, will give us the last required number of files in the file array. $colCtr++; } echo "</table></div>" . "\r\n"; ?> Any help greatly appreciated! Have page#1 with thumbs view_thumbs.php , when a thumb is clicked thumb link goes to page#2 which is the video_play.php page(which must play embed codes from xml sheet) Using GET method to identify incoming link from page#1. QUESTION is how can i retrieve file(embed code) from xml to play on page#2 with incoming GET info from page#1? (embeds not you only from you tube, so no youtube solutions only, just retrieve file) I somehow have to fill play video div on page#2/video_play.php according to GET data from page#1/view_thumbs.php Hi the file file upload whenever i upload an image to main directory it saves one image into photos folder and copy another into thumbs folder but whenever i upload image to a different album (not main directory) it doesnt copy the other image to thumbs folder what i'm i doing wrong this is the line that i chose the folder... function make_locations ($locs) { $html = '<select name="locations" class="input"><option value="0">-- Main Directory --</option>'; foreach ($locs AS $key => $value) { $html .= '<option value="' .$value['album_id']. '">' .addslashes($value['album_name']). '</option>'; } $html .= '</select>'; return $html; } this is the whole code <?php /** * create a sub album directory for photos * to be stored in */ function create_album ($album_name, $sub_album = 0) { global $db; $sql = "INSERT INTO " .ALBUMS_TABLE. " ( album_name, sub_album ) VALUES ( '" .addslashes($album_name). "', " .intval($sub_album). " )"; if ($db->query($sql)) { return TRUE; } else { return FALSE; } } /** * get a list of sub albums */ function get_albums ($sub_album = 0) { global $db; $sql = "SELECT * FROM " .ALBUMS_TABLE. " WHERE sub_album = " .intval($sub_album); $db->query($sql); // initialise album storage $albums = array(); while ($row = $db->fetch()) { $albums[] = $row; } return $albums; } /** * get a list of photos within an album */ function get_photos ($album = 0) { global $db; $sql = "SELECT * FROM " .PHOTOS_TABLE. " WHERE album_id = " .intval($album). " ORDER BY photo_id ASC"; $db->query($sql); // initialise album storage $photos = array(); while ($row = $db->fetch()) { $photos[] = $row; } return $photos; } /** * get a large version of a particular photo */ function get_large ($photo, $album = 0, $next = '') { global $db, $template, $account_details; // shall we get the next / previous photo switch ($next) { case "next" : $next_sql = "AND photo_id > " .intval($photo). " ORDER BY photo_id ASC"; break; case "previous" : $next_sql = "AND photo_id < " .intval($photo). " ORDER BY photo_id DESC"; break; default : $next_sql = "AND photo_id = " .intval($photo); break; } $sql = "SELECT * FROM " .PHOTOS_TABLE. " WHERE album_id = " .intval($album). " " .$next_sql. " LIMIT 1"; $db->query($sql); if ($db->num_rows() == 0) { return ''; } else { $photo_info = $db->fetch(); // note the total directory $location = 'photos/' .$photo_info['photo_proper']; // now we need to resize list($width, $height) = getimagesize($location); if ($width < 300) { $new_width = $width; $new_height = $height; } elseif ($width > $height) { $new_width = 300; $new_height = $height * ($new_width / $width); } elseif ($width < $height) { $new_width = $width * ($new_height / $height); $new_height = 300; } // work out the next link $next = '<a href="portfolio.php?p=' .$photo_info['photo_id']. '&a=' .$photo_info['album_id']. '&next=next">Next</a>'; $previous = '<a href="portfolio.php?p=' .$photo_info['photo_id']. '&a=' .$photo_info['album_id']. '&next=previous">Previous</a>'; return '<div id="largephoto"><img src="' .$location. '" height="' .$new_height. '" width="' .$new_width. '" class="large"><br /><div id="prevnext">' .$previous. ' :: ' .$next. '</div></div>'; } } /** * get an array of locations */ function get_locations () { global $db; // initialise array $locations = array(); // select albums $sql = "SELECT album_id, album_name FROM " .ALBUMS_TABLE; $db->query($sql); while ($row = $db->fetch()) { $locations[] = $row; } return $locations; } /** * make the locations table */ function make_locations ($locs) { $html = '<select name="locations" class="input"><option value="0">-- Main Directory --</option>'; foreach ($locs AS $key => $value) { $html .= '<option value="' .$value['album_id']. '">' .addslashes($value['album_name']). '</option>'; } $html .= '</select>'; return $html; } /** * delete an album from the database * does not delete the photos in it */ function delete_albums ($album_ids) { global $db; if (sizeof($album_ids) > 0) { $sql = "DELETE FROM " .ALBUMS_TABLE. " WHERE album_id IN (" .implode(',', $album_ids). ")"; if ($db->query($sql)) { return TRUE; } } return FALSE; } /** * delete a set of photos */ function delete_photos ($photo_ids) { global $db; if (sizeof($photo_ids) > 0) { // select photo names for deletion $sql = "SELECT photo_proper FROM " .PHOTOS_TABLE. " WHERE photo_id IN (" .implode(',', $photo_ids). ")"; $db->query($sql); $unlink_ids = array(); while ($row = $db->fetch()) { $unlink_ids[] = $row['photo_proper']; } // now delete the photos if (sizeof($unlink_ids) > 0) { $sql = "DELETE FROM " .PHOTOS_TABLE. " WHERE photo_id IN (" .implode(',', $photo_ids). ")"; if ($db->query($sql)) { // remove photo from directory for ($i = 0; $i < sizeof($unlink_ids); $i++) { unlink("photos/" .$unlink_ids[$i]); unlink("photos/thumbs/" .$unlink_ids[$i]); } return TRUE; } } } return FALSE; } /** * upload a set of files */ function upload_files ($save_dir = '', $album = 0) { global $db; // check the save dir is writable if (!is_writable($save_dir)) { return FALSE; } // specify allowed file types $allowed_types = array ( 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif' ); // keep a list of uploaded files $uploaded = array(); // store bytes uploaded $total_bytes = 0; // go through the list of files while (list($key, $value) = each($_FILES['userfile']['name'])) { // check file has been passed if (!empty($value)) { // find extension $extension = substr($_FILES['userfile']['name'][$key], strpos($_FILES['userfile']['name'][$key],".") + 1); // time + $key for name $name = time(). "_" .$key. "." .$extension; // save url $add = $save_dir. "/" .$name; if (move_uploaded_file($_FILES['userfile']['tmp_name'][$key], $add)) { chmod($add, 0777); // add photo to database create_photo($_FILES['userfile']['name'][$key], $name, $album); } } } return TRUE; } /** * insert photo details into the database */ function create_photo ($photo_name, $key_name, $album = 0) { global $db; // get the filesize if (!$size = filesize("photos/" .$key_name)) { $size = 0; } // insert the photo in the database $sql = "INSERT INTO " .PHOTOS_TABLE. " ( photo_name, photo_date, photo_proper, photo_size, album_id ) VALUES ( '" .addslashes($photo_name). "', " .time(). ", '" .addslashes($key_name). "', " .intval($size). ", " .$album. " )"; if ($db->query($sql)) { return TRUE; } else { return FALSE; } } /** * get a complete raw copy of the directory */ function get_dir_contents ($dir) { // declare content array $contents = array(); // check gallery exists if (is_dir($dir)) { if ($handle = opendir($dir)) { while (FALSE !== ($file = readdir($handle))) { if ($file != '.' && $file != '..' && $file != 'thumbs') { if (file_exists($dir. '/thumbs/' .$file) || thumbnail($file, $dir. '/' .$file, $dir. '/thumbs')) { $contents[] = $dir. '/thumbs/' .$file; } else { $contents[] = 'no_image.gif'; } } } } } return $contents; } /** * create a thumbnail of a photo and store it * in the thumbs directory */ function thumbnail ($filename, $source_file, $destination, $new_h = 75, $new_w = 75) { if (!is_file($source_file)) { return FALSE; } // get the image details list($old_w, $old_h, $type) = getimagesize($source_file); // create source image switch($type) { case 1: $source = @imagecreatefromgif($source_file); break; case 2: $source = @imagecreatefromjpeg($source_file); break; case 3: $source = @imagecreatefrompng($source_file); break; default : return FALSE; } // work out dimensions if ($old_w < $old_h) { $thumb_w = $new_w; $thumb_h = $old_h * ($new_h / $old_w); } elseif ($old_w > $old_h) { $thumb_w = $old_w * ($new_w / $old_h); $thumb_h = $new_h; } elseif ($old_w == $old_h) { $thumb_w = $new_w; $thumb_h = $new_h; } $thumb = @imagecreatetruecolor($thumb_w, $thumb_h); // create image imagecopyresized($thumb, $source, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_w, $old_h); // check we have a proper destination if (!is_dir($destination)) { mkdir($destination, 0777); } // save image switch ($type) { case 1: case 2: imagejpeg($thumb, $destination. '/' .$filename); break; case 3: imagepng($thumb, $destination. '/' .$filename); break; } // memory saving imagedestroy($thumb); imagedestroy($source); // thumbnail created successfully return TRUE; } /** * make the table to show the directories and photos */ function make_table ($list, $type, $row = 3) { // initialize gallery html array $gallery_html = array(); // check if we have a list > 0 if ($size = sizeof($list)) { switch ($type) { case "GALLERIES" : $gallery_html[] = '<div id="galleries">'; break; case "PHOTOS" : case "RAW" : $gallery_html[] = '<div id="photos">'; break; } // loop through list for ($i = 0; $i < sizeof($list); $i++) { // shall we open a new list if ($i % $row == 0) { $gallery_html[] = '<ul>'; } // add to list switch ($type) { case "GALLERIES" : // create the delete link $delete_link = ''; if ($_SESSION['logged_in']) { $delete_link = '[ <a href="admin.php?mode=deletealbum&a=' .$list[$i]['album_id']. '">Delete</a> ]'; } $gallery_html[] = '<a href=portfolio.php?albums='.$list[$i]['album_id'].'><img src="folder.gif" class="directory"><br />' .addslashes($list[$i]['album_name']). '</a><br />' .$delete_link. '</li>'; break; case "PHOTOS" : // construct photo name $name = $list[$i]['photo_proper']; // construct location $location = "photos/"; // create thumbnail if (!file_exists($location. "/thumbs/" .$name)) { thumbnail($name, $location. "/" .$name, $location. "/thumbs/"); } // construct date $date = '<div class="date">' .date("d/m G:ia", $list[$i]['photo_date']). '</div>'; // create the delete link $delete_link = ''; if ($_SESSION['logged_in']) { $delete_link = '[ <a href="admin.php?mode=deletephoto&p=' .$list[$i]['photo_id']. '">Delete</a> ]'; } // image information list($width, $height) = getimagesize($location . $list[$i]['photo_proper']); // add to the html $gallery_html[] = '<li><a href="' .$location . $list[$i]['photo_proper']. '" rel="lightbox[racing]" title="Photos"><img src="' .$location. "/thumbs/" .$name. '" class="picture"><br />View</a><br />' .$delete_link. '</li>'; break; case "RAW" : $gallery_html[] = '<li><img src="' .$list[$i]. '" class="picture"></li>'; break; } // shall we close the list if ( ($i + 1) % $row === 0 || ($i + 1) == $size) { $gallery_html[] = '</ul>'; } } $gallery_html[] = '</div>'; } return implode('', $gallery_html); } ?> Hi everyone, im not sure if this topic belongs in CSS so please move if it is but... I have a style sheet with some boxes i want my SQL results to go into, i want to know how to echo the results into the boxes. heres the html: Code: [Select] <!DOCTYPE html> <head> <title>Compaines | Removalspace.com</title> <style type="text/css"> <!-- body { background-image: url(styles/downloaded%20styles/todo/todo/images/bg.png); } --> </style> <link href="styles/downloaded styles/todo/todo/css/style.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="styles/downloaded styles/todo/todo/css/style9.css" /> <link rel="stylesheet" type="text/css" href="styles/downloaded styles/todo/todo/css/demo.css" /> <link href='http://fonts.googleapis.com/css?family=Terminal+Dosis' rel='stylesheet' type='text/css' /> <style type="text/css"> <!-- .Stile1 {color: #333333} --> </style> </head> <body> <!--start container --> <div id="container"> <header> <nav> <div id="logo"><a href="#"><img src="images/removalspace1.png" alt="Logo here" width="463" height="135" /></a> </div> <div id="search-top"> <form method="post" action="search.php"> <input type="text" onFocus="if(this.value=='Search')this.value='';" onBlur="if(this.value=='')this.value='Search';" value="Search" id="search-field"/> <input type="submit" value="" id="search-btn"/> </form> </div> <div id="nav_social"><a href="http://www.facebook.com/pages/Removalspace/181434181939226"><img src="styles/downloaded styles/todo/todo/images/facebook_32.png" alt="Become a fan" width="32" height="32" /></a><a href="#"><img src="styles/downloaded styles/todo/todo/images/twitter_32.png" alt="Follows on Twitter" /></a><a href="#"><img src="styles/downloaded styles/todo/todo/images/linkedin_32.png" alt="Linked in" /></a><a href="contact.php"><img src="styles/downloaded styles/todo/todo/images/email_32.png" alt="Contact" width="32" height="32" /></a> </div> </nav> </header> <div class="content"> <ul class="ca-menu"> <li> <a href="removals.php"> <span class="ca-icon">A</span> <div class="ca-content"> <h2 class="ca-main">Bringing removals home</h2> <h3 class="ca-sub">All in one place</h3> </div> </a> </li> <li> <a href="storage.php"> <span class="ca-icon">I</span> <div class="ca-content"> <h2 class="ca-main">Find the storage space</h2> <h3 class="ca-sub">Near You</h3> </div> </a> </li> <li> <a href="advertise_page.php"> <span class="ca-icon">C</span> <div class="ca-content"> <h2 class="ca-main">Advertise</h2> <h3 class="ca-sub">Your Business</h3> </div> </a> </li> <li> <a href="contact.php"> <span class="ca-icon">S</span> <div class="ca-content"> <h2 class="ca-main">Sophisticated Team</h2> <h3 class="ca-sub">Professionals in action</h3> </div> </a> </li> </ul> <!--star main --> <main> <div class="abox"> <figure> <fcapion> <h1>Company... </h1> </fcaption><a href="index-delete.php"></a><a href="#"><img src="images/images-8.jpeg" alt="I love graphic" width="200" height="200" /></a></figure> </div> <div class="abox"> <figure> <fcapion> <h1>Address... </h1> </fcaption> <a href="#"><img src="images/storagespace.jpg" alt="I love graphic" width="200" height="200" /></a> </figure> </div> <div class="abox"> <figure> <fcapion> <h1>Phone...</h1> </fcaption><a href="#"></a><a href="#"><img src="images/transport.jpg" alt="I love graphic" width="200" height="200" /></a></figure> </div> </main> <!--end main --> <!--start middle --> <middle> <div class="enter"> <P >Sign up to removalspace.com to advertise your business, choose from easy payment packages or add a FREE listing. Click the link to get started<br></P> <div class="imgteaser"> <a href="login-or-register.php"><img src="images/free listing2.jpg" alt="Todo el Todo" width="413" height="220" /><span class="desc"> <strong>Sign Up For Free!</strong> Start by making a FREE listing today.</span></a></div> </div> <div class="section_slogan"><img src="styles/downloaded styles/todo/todo/images/quote-right.png" alt="images" /><span class="cursive"> Nobody likes moving but finding the right people is easy at least with Removalspace.com</span><img src="styles/downloaded styles/todo/todo/images/quote-left.png" alt="images" /></div> <div class="middle_box"><h1><img src="styles/downloaded styles/todo/todo/images/fav.png" width="16" height="16" /> <a href="#">Resources</a></h1> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Search thousands of removal companies </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Search for a storage facility near you </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Contact Us </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> About removalspace. </ol> </div> <div class="middle_box"><h1><img src="styles/downloaded styles/todo/todo/images/fav.png" width="16" height="16" /> <a href="#">Blogs</a></h1> <p><img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Recent Post</p> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Post your comments </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Read Reviews </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Recent removalspace things. </ol> </div> <div class="middle_box"> <h1><img src="styles/downloaded styles/todo/todo/images/fav.png" width="16" height="16" /> <a href="#">Other </a></h1> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Advertisment Page <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Affiliate Links </ol> <ol> <img src="styles/downloaded styles/todo/todo/images/dialog-ok.png" width="16" height="16" /> Our Packages. </ol></div> </middle> </div> <!--end middle --> <!--start footer --> <footer> <div id="footer"> <div id="footerleft"> <h2>removalspace</h2> <ul> <li><a href="http://www.imediacreatives.it">Contact</a></li> <li><a href="styles/downloaded styles/todo/todo/...">About Us</a></li> <li><a href="styles/downloaded styles/todo/todo/...">Other</a></li> </ul> </div> <div id="footermiddle"> <h2>User Comments</h2> <ul> <li><a href="styles/downloaded styles/todo/todo/...">Read Reviews</a></li> <li><a href="http://www.imediacreatives.it">Leave A Comment</a></li> <li><a href="styles/downloaded styles/todo/todo/...">Read Blogs</a></li> </ul> </div> <div id="footerright"> <h2>our mission</h2> <ul> <li><a href="">Who Are We?</a></li> <li><a href="">What We Do</a></li> <li><a href="">Our Mission</a></li> </ul> </div> <details> <summary> <p> Copyright © removalspace.com -2012.</p></summary><p></p> </details> </div> </footer> <!--end footer --> </div> <!--end container --> <!-- Free template distributed by http://freehtml5templates.com --> </body> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> </html> heres the php code: Code: [Select] <?PHP include ('db.php'); $query = "SELECT * FROM companies ORDER BY approved DESC, company_name ASC"; $result = mysql_query($query); ?> <table border="0" cellpadding="1" cellspacing="2" bordercolor="#0066FF" background="images/table-images/back.png"> <tr> <th background="images/table-images/pattern.png">Company Name</th> <th background="images/table-images/pattern-head.png">Contact Name:</th> <th background="images/table-images/pattern.png">Contact Number:</th> <th background="images/table-images/pattern-head.png">Contact Email:</th> <th background="images/table-images/pattern.png">Address 1:</th> <th background="images/table-images/pattern-head.png">Address 2:</th> <th background="images/table-images/pattern.png">Area:</th> <th background="images/table-images/pattern-head.png">Postcode:</th> <th> - </th> <th> - </th> <th> - </th> <tr> <?php while ( $row = mysql_fetch_array($result)) { $approved = $row['approved']; SWITCH ($approved) { case 0: break; case 1: ?> <tr> <td><?PHP echo $row['company_name']; ?></td> <td><?PHP echo $row['contact_name']; ?></td> <td><?PHP echo $row['phone']; ?></td> <td><?PHP echo $row['email']; ?></td> <td><?PHP echo $row['street1']; ?></td> <td><?PHP echo $row['street2']; ?></td> <td><?PHP echo $row['location']; ?></td> <td><?PHP echo $row['postcode']; ?></td> <td></td> <td></td> <td></td> </tr> <?PHP break; case 2: ?> <tr> <td><?PHP echo $row['company_name']; ?></td> <td><?PHP echo $row['contact_name']; ?></td> <td><?PHP echo $row['phone']; ?></td> <td><?PHP echo $row['email']; ?></td> <td><?PHP echo $row['street1']; ?></td> <td><?PHP echo $row['street2']; ?></td> <td><?PHP echo $row['location']; ?></td> <td><?PHP echo $row['postcode']; ?></td> <td><?PHP echo $row['basicpackage_description']; ?></td> <td>-</td> <td>-</td> </tr> <?PHP break; case 3: ?> <tr> <td><?PHP echo $row['company_name']; ?></td> <td><?PHP echo $row['contact_name']; ?></td> <td><?PHP echo $row['phone']; ?></td> <td><?PHP echo $row['email']; ?></td> <td><?PHP echo $row['street1']; ?></td> <td><?PHP echo $row['street2']; ?></td> <td><?PHP echo $row['location']; ?></td> <td><?PHP echo $row['postcode']; ?></td> <td><?PHP echo $row['basicpackage_description']; ?></td> <td><?PHP echo $row['premiumuser_description']; ?></td> <td><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></td> </tr> <?PHP break; } } echo "</table>"; ?> That is currently set to echo out a table but i only want "company" "address" "phone" to make things easier. Company name = box1 street1,street2, location, postcode = box2 (for address) phone = box3 I hope theres enough information for any help, thank you in advance! Hello. I am not entirely certain if this is even possible, but I don't see why it wouldn't. The document that I have is: Code: [Select] <?php include('../connection.php'); $query="SELECT * FROM projects"; $result=mysql_query($query); echo "<table border='1' cellpadding='10'>"; while($row = mysql_fetch_array( $result )) { echo "<tr>"; echo "<td>$row[id]</td>"; echo "<td>$row[name]</td>"; echo "<td>$row[text]</td>"; echo "<td><img src='../uploads/$row[image]'/></td>"; echo "<td><a href='editprojects.php?id=$row[id]'>Edit</a></td>"; echo "<td><a href='deleteprojects.php?id=$row[id]'>Delete</a></td>"; echo "</tr>"; } echo "</table>"; mysql_free_result($result); mysql_close($connection); ?> Basically, the only important line from that file is: Code: [Select] echo "<td><img src='../uploads/$row[image]'/></td>"; What I am doing is uploading images and other files to a PHP database. [image] = carries all the uploaded files. That single line shows every uploaded image in a row. But it doesn't show the SWF because obviously 'img src' isn't for swf's. Is it possible to add another code to THAT LINE to show the swf's? that single bit needs to be able to read images and swf's, Please help if you can. So I have this script. I connected the database and verified a working connection to the base, password correct. As I save the script on my server it saved the changes and I view the file online. The resulting page is blank. Really need help completing this code as it's essential to my sites organization, have a look below and help me if possible.
<?php I have written a bra calculator, when the user enters their measurements their bra size is displayed however as the code I have used to do this came from a help tutorial I do not understand how it was constructed as I am quite a newb. The form works perfectly when returning data however if there is no size for a particular measurement it just displays nothing. I would like it to display N/A I have tried adding various if elses but without success. Any help is much appreciated Code: [Select] <FORM ACTION="<?php echo $_SERVER['PHP_SELF']; ?>" METHOD=get> <input type="text" name="band" value="<?php echo $_GET['band']; ?>" /> <input type="text" name="bust" value="<?php echo $_GET['bust']; ?>" /> <INPUT TYPE=submit VALUE="Calculate"> </FORM> <?php $band = $_GET['band']; $bust = $_GET['bust']; $query = sprintf("SELECT size FROM bra_calculator WHERE band='%s' AND bust='%s'", mysql_real_escape_string($band), mysql_real_escape_string($bust)); $result = mysql_query($query); if (!$result) { echo "no"; } else { while ($row = mysql_fetch_assoc($result)) { echo $row['size']; } } mysql_free_result($result); ?> I want to grab a list of all the school programs I have in a database (math english biology chemistry ect ect) and dispaly them in a order so that they go alphabetically downward for 12 rows and then go across so it would look like soo: Academic Advisory Class Schedules Academic Assistance Counselling Center Academic Calendars Course Descriptions and Catalogue Academics Office Department Directory Administration Departments & Programs Adult Learners Fellowships Alumnimni Chapters Finals Schedules Alumni Events Athletics Campus Life At a Glance Campus Recreation Campus Safety & Security I know to get he I am just unsure what to do in the while array to make it look how I want Code: [Select] <?php $sql = "SELECT name,id FROM table_name ORDER BY name ASC"; $res =mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($res)){ //now what??? } ?> Back again!! I have been trying to think of a way to do this but its starting to make my brain itch a bit too much now!!! I have the code below to display my query. Basicly its to disply 3 images and when 'x=a multiple of 3' it ends the row and starts another. The only problem is, that the first result will not be displayed as x has to begin at 1. if x begins at 0, it will display the first result and begin a new line. Code: [Select] echo "<center><table border='0' cell padding='3'><tr>"; $x = 1; while ($x < $num) { $id=mysql_result($result,$x,"id"); $caption=mysql_result($result,$x,"cap"); $address=mysql_result($result,$x,"address"); $date=mysql_result($result,$x,"date"); $album=mysql_result($result,$x,"album"); $member=mysql_result($result,$x,"member"); echo "<td><center><img src='/images/uploads/main/thumb_".$address."'><br>$caption</center></td>"; echo ($x % 3 == 0)? "</tr><tr>" : ""; $x++; } echo "</tr></table>"; Can anyone point me in the right direction?? Thanks Eric Could somebody help to pint me in the right direction where to look for the correct syntax for my problem. The user logs in and is sent to the members area, their username is echoed out to display that they are logged in, my problem is that it is displaying all the users in my database (currently 2 usernames). I would just like to have the current users username displayed. Code: [Select] <?php $con = mysql_connect("server","username", "password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $con); $result = mysql_query("SELECT username FROM users" ); while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['username'] . "</td>";; echo "</tr>";} echo "</table>"; ?> What sholud i research to perform this task properly? thank you. Hello, I just reach the ultimate high in frustration because i can not display all the data from my database in a table using php. Im trying to display all the members from my database (id, username, email and account type) in my admin cp, and what is happening is that i am displaying all my data in one td. (Ex, in the <td></td>, it will display all the usernames at once, rather than separating them). Code: [Select] <?php include_once "../config.php"; include_once "admin_check.php"; $get_members = mysql_query("SELECT * FROM members ORDER BY id"); while ($row = mysql_fetch_array($get_members)) { $id .= $row['id']; $username .= $row['username']; $account_type .= $row['account_type']; $email .= $row['email']; } ?> <!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>Welcome Admin!</title> </head> <body> <h1>Welcome admin! <a href='../index.php'> Click here to go back! </a></h1> <table cellspacing="5" cellpadding="5" style="border: black thin solid" align="center"> <tr> <td>ID</td> <td>Username</td> <td>Email</td> <td>Account Type</td> </tr> <tr> <td><?php echo $id;?></td> <td><?php echo $username;?></td> <td><?php echo $email;?></td> <td><?php echo $account_type;?></td> </tr> </table> </body> </html> Now i tried making the table in the while loop, but i am also having the same problem. Please help. I have a PHP page that retrieves a PDF from a location on my server that isn't in the web server home path, for security reasons. When I try to retrieve the file on my development server everything works great, but when I try it on my account with HostGator it opens the PDF and I get an error after Adobe opens. "There was an error opening this document. The file is damaged and could not be repaired" Here is the code I'm using Code: [Select] $file = $file_info->file_name; if(file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/mime-type'); header('Content-Disposition: inline; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); } when I present it with a browser that is fails. I have been racking my brain for hours. I would appreciate some help. Thanks Troy |