Jump to content

webmaster1

Members
  • Posts

    607
  • Joined

  • Last visited

    Never

Everything posted by webmaster1

  1. Theres a good tutorial here if you scroll down: http://www.freewebmasterhelp.com/tutorials/phpmysql/4
  2. First create a file: output.php Modify the following example: <? include("dbinfo.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM yourtablename"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; $i=0; while ($i < $num) { $imageurl1=mysql_result($result,$i,"imageurl1"); $imageurl2=mysql_result($result,$i,"imageurl2"); $imageurl3=mysql_result($result,$i,"imageurl3"); echo " <img src='$imageurl1' width='250' height='188'> </br> <img src='$imageurl2' width='250' height='188'> </br> <img src='$imageurl3' width='250' height='188'> </br> </br> <hr> </br> "; $i++; } ?> Again this is based on outputting three image files. Just an example but a starting point.
  3. Really depends on your script. You'd need to post an example of what you're working with. Do you know how to ouput an image? (apologies if i'm incorrectly assuming you're a newb)
  4. If you only need the one file uploaded try this. http://www.tizag.com/phpT/fileupload.php It doesn't contain any validation and will not insert the path into mySQL but its a good starting point.
  5. The folder should be situated in whatever folder your storing your php page in. If your php is in your root directory (where your home page is) then this is where the upload folder should be. If your php page is in a folder then so should your upload folder. Whenever I try a tutorial I create a database according to the tutorial requirements rather than my own initially. Try creating a database with one index and three varchar fields for the paths. You'll need to modify the insert statement as well. Once your satisfied you can upload the three image files begin working your way backwards and edit the code to facilitate only one upload. I'll be logged in for a while in any case.
  6. Will do. I think I was using an old tutorial. It also uses $HTTP_POST_FILES instead of $POST.
  7. Ah, I forgot about that. I created a file called dbinfo.php that contains my details related to database connection. If you have these details in your form already it ok. Its just a neater way of going about it. It looks like this: <?php $host = 'localhost'; //usually localhost $username = 'XXX'; //your username assigned to your database $password = 'XXX'; //your password assigned to your user & database $database = 'XXX'; //your database name ?> Is your database created and can you connect to it?
  8. The code is set up so that it stores it in a folder called upload. You need to create this folder in the same path as your form for starters. Also make sure that this folder is writable to by the public. This section of the provided code determines where it goes: <?php //REPLACE THE WORD UPLOAD WITH YOUR FOLDER NAME $path1= "upload/".$HTTP_POST_FILES['ufile']['name'][0]; $path2= "upload/".$HTTP_POST_FILES['ufile']['name'][1]; $path3= "upload/".$HTTP_POST_FILES['ufile']['name'][2]; //NO NEED TO EDIT BELOW BUT THATS THE CODE THAT ACTUALLY COPIES THE FILE TO THE FOLDER copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1); copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2); copy($HTTP_POST_FILES['ufile']['tmp_name'][2], $path3);
  9. This should work fine as an example. Copy it, paste it, view it, edit it (you should only need to remove the code relating to the second and third file uploads) and let me know. <?php if (isset($_POST['submit'])) { //CHECK IF UPLOAD FILE FIELD 1 IS EMPTY $filesize1=$HTTP_POST_FILES['ufile']['size'][0]; if($filesize1==0) { $filesize1=FALSE; $message_filesize1="You forgot to enter this image file!"; //echo "$message_filesize1"; } else { $filesize1=TRUE; } //CHECK IF UPLOAD FILE FIELD 2 IS EMPTY $filesize2=$HTTP_POST_FILES['ufile']['size'][1]; if($filesize2==0) { $filesize2=FALSE; $message_filesize2="You forgot to enter this image file!"; //echo "$message_filesize2"; } else { $filesize2=TRUE; } //CHECK IF UPLOAD FILE FIELD 3 IS EMPTY $filesize3=$HTTP_POST_FILES['ufile']['size'][2]; if($filesize3==0) { $filesize3=FALSE; $message_filesize3="You forgot to enter this image file!"; //echo "$message_filesize3"; } else { $filesize3=TRUE; } //CHECK IF ANY THE FILES ARE THE SAME: $filenamecheck1= $HTTP_POST_FILES['ufile']['name'][0]; $filenamecheck2= $HTTP_POST_FILES['ufile']['name'][1]; $filenamecheck3= $HTTP_POST_FILES['ufile']['name'][2]; $filesize1=$HTTP_POST_FILES['ufile']['size'][0]; $filesize2=$HTTP_POST_FILES['ufile']['size'][1]; $filesize3=$HTTP_POST_FILES['ufile']['size'][2]; if ( (($filenamecheck1 == $filenamecheck2) || ($filenamecheck2 == $filenamecheck3) || ($filenamecheck1 == $filenamecheck3)) && ((!$filesize1==0 && isset($_POST['submit'])) && (!$filesize2==0 && isset($_POST['submit'])) && (!$filesize3==0 && isset($_POST['submit']))) ) { $filenamecheck_message = "one ore more of the files are the same"; //echo "$message_filenamecheck"; $message_filenamecheck = TRUE; $filenamecheck1= FALSE; $filenamecheck2= FALSE; $filenamecheck3= FALSE; } else { $message_filenamecheck = FALSE; $filenamecheck1= TRUE; $filenamecheck2= TRUE; $filenamecheck3= TRUE; } //CHECK IF FILE 1 IS NOT A *.JPEG OR *.GIF $filesize1=$HTTP_POST_FILES['ufile']['size'][0]; if ( ( ($HTTP_POST_FILES['ufile']["type"][0] == "image/gif") || ($HTTP_POST_FILES['ufile']["type"][0] == "image/jpeg") || ($HTTP_POST_FILES['ufile']["type"][0] == "image/pjpeg") ) // &&($HTTP_POST_FILES['ufile']["size"][0] < 50000) ) { $filetypecheck1=TRUE; } else { if (!($filesize1 == 0)) { $filetypecheck1=FALSE; $message_filetypecheck1="The first of the sumbitted files is not of a *.JPG ! *.GIF file type!"; //echo "$message_filetypecheck1"; } } //CHECK IF FILE 2 IS NOT A *.JPEG OR *.GIF $filesize2=$HTTP_POST_FILES['ufile']['size'][1]; if ( ( ($HTTP_POST_FILES['ufile']["type"][1] == "image/gif") || ($HTTP_POST_FILES['ufile']["type"][1] == "image/jpeg") || ($HTTP_POST_FILES['ufile']["type"][1] == "image/pjpeg") ) // &&($HTTP_POST_FILES['ufile']["size"][1] < 50000) ) { $filetypecheck2=TRUE; } else { if (!($filesize2 == 0)) { $filetypecheck2=FALSE; $message_filetypecheck2="The second of the sumbitted files is not of a *.JPG ! *.GIF file type!"; //echo "$message_filetypecheck2"; } } //CHECK IF FILE 3 IS NOT *.JPEG OR *.GIF $filesize3=$HTTP_POST_FILES['ufile']['size'][2]; if ( ( ($HTTP_POST_FILES['ufile']["type"][2] == "image/gif") || ($HTTP_POST_FILES['ufile']["type"][2] == "image/jpeg") || ($HTTP_POST_FILES['ufile']["type"][2] == "image/pjpeg") ) // &&($HTTP_POST_FILES['ufile']["size"][2] < 50000) ) { $filetypecheck3=TRUE; } else { if (!($filesize3 == 0)) { $filetypecheck3=FALSE; $message_filetypecheck3="The third of the sumbitted files is not of a *.JPG ! *.GIF file type!"; //echo "$message_filetypecheck3"; } } //CHECK IF FILE 1 EXISTS ALREADY $path1= "upload/".$HTTP_POST_FILES['ufile']['name'][0]; $filesize1=$HTTP_POST_FILES['ufile']['size'][0]; if ( (file_exists($path1)) && (!($filesize1 == 0)) ) { $fileexistcheck1=FALSE; $message_fileexistcheck1="The first file already exist on the server!"; //echo "$message_fileexistcheck1"; } else { $fileexistcheck1=TRUE; } //CHECK IF FILE 2 EXISTS ALREADY $path2= "upload/".$HTTP_POST_FILES['ufile']['name'][1]; $filesize2=$HTTP_POST_FILES['ufile']['size'][1]; if ( (file_exists($path2)) && (!($filesize2 == 0)) ) { $fileexistcheck2=FALSE; $message_fileexistcheck2="The second file already exist on the server!"; //echo "$message_fileexistcheck2"; } else { $fileexistcheck2=TRUE; } //CHECK IF FILE 3 EXISTS ALREADY $path3= "upload/".$HTTP_POST_FILES['ufile']['name'][2]; $filesize3=$HTTP_POST_FILES['ufile']['size'][2]; if ( (file_exists($path3)) && (!($filesize3 == 0)) ) { $fileexistcheck3=FALSE; $message_fileexistcheck3="The third file already exist on the server!"; //echo "$message_fileexistcheck3"; } else { $fileexistcheck3=TRUE; } //IF ALL INPUT FIELDS ARE DEFINED AS TRUE / VALIDATED if ($filesize1 && $filesize2 && $filesize3 && $filenamecheck1 && filenamecheck2 && filenamecheck3 && $filetypecheck1 && $filetypecheck2 && $filetypecheck3 && $fileexistcheck1 && $fileexistcheck2 && $fileexistcheck3) { $path1= "upload/".$HTTP_POST_FILES['ufile']['name'][0]; $path2= "upload/".$HTTP_POST_FILES['ufile']['name'][1]; $path3= "upload/".$HTTP_POST_FILES['ufile']['name'][2]; copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1); copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2); copy($HTTP_POST_FILES['ufile']['tmp_name'][2], $path3); include("dbinfo.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to establish a connection to the relevant database."); $path1= "upload/".$HTTP_POST_FILES['ufile']['name'][0]; $path2= "upload/".$HTTP_POST_FILES['ufile']['name'][1]; $path3= "upload/".$HTTP_POST_FILES['ufile']['name'][2]; $query = "INSERT INTO test VALUES ('','','','','','','','','','','','','','','',NOW(),'','$path1','$path2','$path3')"; mysql_query($query); //NEXT DISPLAY A SUMMARY OF WHAT HAS BEEN UPLOADED echo "The following image files have been uploaded:</br></br> "; echo "File Name :".$HTTP_POST_FILES['ufile']['name'][0]."<BR/>"; //echo "File Size :".$HTTP_POST_FILES['ufile']['size'][0]." KB<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type'][0]."<BR/>"; //echo "<img src=\"$path1\" height=\"150\">"; echo "<P>"; echo "File Name :".$HTTP_POST_FILES['ufile']['name'][1]."<BR/>"; //echo "File Size :".$HTTP_POST_FILES['ufile']['size'][1]."<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type'][1]."<BR/>"; //echo "<img src=\"$path2\" height=\"150\">"; echo "<P>"; echo "File Name :".$HTTP_POST_FILES['ufile']['name'][2]."<BR/>"; //echo "File Size :".$HTTP_POST_FILES['ufile']['size'][2]."<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type'][2]."<BR/>"; //echo "<img src=\"$path3\" height=\"150\">"; exit(); } } ?> <HTML> <HEAD> </HEAD> <BODY> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> <fieldset> <?php // IF ANY INDIVIDUAL INPUT FIELD IS DEFINED AS FALSE THEN DISPLAY ERROR MESSAGE if ($message_filesize1 || $message_filesize2 || $message_filesize3 || $message_filesize1 || $message_filesize2 || $message_filesize3 || $message_filenamecheck || $message_filetypecheck1 || $message_filetypecheck2 || $message_filetypecheck3 || $message_fileexistcheck1 || $message_fileexistcheck2 || $message_fileexistcheck3) echo '*This item could not be processed because some of the information is missing or incorrect.</br></br>'; ?> <ol> <li> <label for "ufile[]">Image File 1:</label> <input type="file" name="ufile[]" id="ufile[]"/> <?php if ($message_filesize1) echo ''.$message_filesize1.''; ?> <?php if ($message_filetypecheck1) echo ''.$message_filetypecheck1.''; ?> <?php if ($message_fileexistcheck1) echo ''.$message_fileexistcheck1.''; ?> </li> <li> <label for "ufile[]">Image File 2:</label> <input type="file" name="ufile[]" id="ufile[]"/> <?php if ($message_filesize2) echo ''.$message_filesize2.''; ?> <?php if ($message_filetypecheck2) echo ''.$message_filetypecheck2.''; ?> <?php if ($message_fileexistcheck2) echo ''.$message_fileexistcheck2.''; ?> </li> <li> <label for "ufile[]">Image File 3:</label> <input type="file" name="ufile[]" id="ufile[]"/> <?php if ($message_filesize3) echo ''.$message_filesize3.''; ?> <?php if ($message_filetypecheck3) echo ''.$message_filetypecheck3.''; ?> <?php if ($message_fileexistcheck3) echo ''.$message_fileexistcheck3.''; ?> </br> <?php if ($filenamecheck_message) echo ''.$filenamecheck_message.''; ?> </li> <li> <input name="submit" type="submit"> </li> </ol> </fieldset> </form> </BODY> </HTML> This can be done a lot neater using arrays for the error messages. Its just a newb approach.
  10. Excellent. Shits and grins all around. FYI it doesn't need to be proportionate either. One more question: Do you think I'll get away with this method for the following two scenarios? edit: forgot to say thank you!
  11. You're better off storing the images to a folder on your server and then inserting the path as a variable into your database. Its as simple as outputting the path within an image tag thereafter. I can post an example if you want to go down this road. Otherwise I think you need to us BLOB rather than VARCHAR (could be wrong).
  12. I think SKYPE may block certain ports. I had a similar problem with XAAMP Download a free port checker.
  13. Yes. It all works fine until I add the width attribute. I'm using an up to date IE. I tried adding the proportionate height to the resize but to no avail. Here's my output code: <?php include("dbinfo.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM test"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; $i=0; while ($i < $num) { $index=mysql_result($result,$i,"index"); $make=mysql_result($result,$i,"make"); $model=mysql_result($result,$i,"model"); $price=mysql_result($result,$i,"price"); $engine=mysql_result($result,$i,"engine"); $transmission=mysql_result($result,$i,"transmission"); $year=mysql_result($result,$i,"year"); $colour=mysql_result($result,$i,"colour"); $mileagem=mysql_result($result,$i,"mileagem"); $mileagekm=mysql_result($result,$i,"mileagekm"); $owners=mysql_result($result,$i,"owners"); $doors=mysql_result($result,$i,"doors"); $location=mysql_result($result,$i,"location"); $info=mysql_result($result,$i,"info"); $date=mysql_result($result,$i,"date"); $ipaddress=mysql_result($result,$i,"ipaddress"); $imageurl1=mysql_result($result,$i,"imageurl1"); $imageurl2=mysql_result($result,$i,"imageurl2"); $imageurl3=mysql_result($result,$i,"imageurl3"); echo " $index</br> $make</br> $model</br> $price</br> $engine</br> $transmission</br> $year</br> $colour</br> $mileagem</br> $mileagekm</br> $owners</br> $doors</br> $location</br> $info</br> $date</br> $ipaddress</br> <img src='.$imageurl1.' width='250' height='188'> </br> <img src='.$imageurl2.'></br> <img src='.$imageurl3.'></br> </br> <hr> </br> "; $i++; } ?>
  14. Just in case: My input form succesfully inserts the url path to mySQL and stores the actual image in a folder on the server. I can output the contents of the database table fine including the images but only at their default size.
  15. The parse error is gone so the page loads but now my image won't show (the usual red x in a box in the topleft of where the image should be). Do I need to include the height attribute and will it need to be proportional? That makes sense btw , I presume the misuse of the " was closing off the echo.
  16. Yep, I'm aware that its not kind to bandwidth and all that jazz. I've gone through several GD thumbnails tutorials and even looked at phpThumb but none of them seem to be dumbing it down enough for me. Lets say I want to avoid GD completley. Are you saying that this should work? <?php <img src=".$imageurl1." width = "whatever size I need it outputted as"> ?> edit: I end up with a parse error whenever I include the width attribute.
  17. :-X No takers eh? I geuss I can always have the client resize the images themselves and submit a thumbnail size along with the regular image. I'm just concerned that I'm creating work for them that the site should technically be doing for them in the first place.
  18. The most rudimentary tutorial example I've come across uses a function: <?php function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth) { $srcImg = imagecreatefromjpeg("$imageDirectory/$imageName"); $origWidth = imagesx($srcImg); $origHeight = imagesy($srcImg); $ratio = $origWidth / $thumbWidth; $thumbHeight = $origHeight * $ratio; $thumbImg = imagecreate($thumbWidth, $thumbHeight); imagecopyresized($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, imagesx($thumbImg), imagesy($thumbImg)); imagejpeg($thumbImg, "$thumbDirectory/$imageName"); } createThumbnail("img", "theFileName.jpg", "img/thumbs", 100); ?> Does anybody know how I would "trigger" this function? Would I use a button on a single page or can I call on it in my main input form where the images are uploaded? I'd apreciate any help; even being pointed in the right direction. I'm confidant that if I know where to start that I can work it out.
  19. Thanks again. Fixed the typo (oddly enough it didn't cause an issue either way).
  20. Hi All, I have a form that allows three image file uploads. I want to display (output into a browser from mySQL) the images in two different sizes (regular size and thumbnail size). I was really hoping it would be as simple as: <?php <img src=".$imageurl1." width = "whatever size I need it outputted as"> ?> This doesn't work and apparently I have go through this complicated process that relies on a GD Library (which I have installed). I've set up three folders: [*]upload/ - for images in the default size the user uploads [*]upload/regular - for images resized for outputting in site [*]upload/thumbnail - for images resized for outputting as thumbnails Here's a skeletal example of the code I'm working with: <?php if (isset($_POST['submit'])) { //LOTS OF OMITTED VALIDATION HERE $path1= "upload/".$HTTP_POST_FILES['ufile']['name'][0]; $path2= "upload/".$HTTP_POST_FILES['ufile']['name'][1]; $path3= "upload/".$HTTP_POST_FILES['ufile']['name'][2]; copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1); copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2); copy($HTTP_POST_FILES['ufile']['tmp_name'][2], $path3); include("dbinfo.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to establish a connection to the relevant database."); $query = "INSERT INTO test VALUES ('','','','','','','','','','','','','','','',NOW(),'','$path1','$path2','$path3')"; mysql_query($query); echo "The following image files have been uploaded:</br></br> "; echo "File Name :".$HTTP_POST_FILES['ufile']['name'][0]."<BR/>"; //echo "File Size :".$HTTP_POST_FILES['ufile']['size'][0]." KB<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type'][0]."<BR/>"; //echo "<img src=\"$path1\" height=\"150\">"; echo "<P>"; echo "File Name :".$HTTP_POST_FILES['ufile']['name'][1]."<BR/>"; //echo "File Size :".$HTTP_POST_FILES['ufile']['size'][1]."<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type'][1]."<BR/>"; //echo "<img src=\"$path2\" height=\"150\">"; echo "<P>"; echo "File Name :".$HTTP_POST_FILES['ufile']['name'][2]."<BR/>"; //echo "File Size :".$HTTP_POST_FILES['ufile']['size'][2]."<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type'][2]."<BR/>"; //echo "<img src=\"$path3\" height=\"150\">"; exit(); } } ?> <HTML> <BODY> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> <fieldset> <?php <ol> <li> <label for "ufile[]">Image File 1:</label> <input type="file" name="ufile[]" id="ufile[]"/> </li> <li> <label for "ufile[]">Image File 2:</label> <input type="file" name="ufile[]" id="ufile[]"/> </li> <li> <label for "ufile[]">Image File 3:</label> <input type="file" name="ufile[]" id="ufile[]"/> </li> <li> <input name="submit" type="submit"> </li> </ol> </fieldset> </form> </BODY> </HTML> Here's an example of the thumbnail generation code I'm working with though I don't even know where to start to stitch the three of them together <?php function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth ) { // open the directory $dir = opendir( $pathToImages ); // loop through it, looking for any/all JPG files: while (false !== ($fname = readdir( $dir ))) { // parse path for the extension $info = pathinfo($pathToImages . $fname); // continue only if this is a JPEG image if ( strtolower($info['extension']) == 'jpg' ) { echo "Creating thumbnail for {$fname} <br />"; // load image and get image size $img = imagecreatefromjpeg( "{$pathToImages}{$fname}" ); $width = imagesx( $img ); $height = imagesy( $img ); // calculate thumbnail size $new_width = $thumbWidth; $new_height = floor( $height * ( $thumbWidth / $width ) ); // create a new temporary image $tmp_img = imagecreatetruecolor( $new_width, $new_height ); // copy and resize old image into new image imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); // save thumbnail into a file imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" ); } } // close the directory closedir( $dir ); } // call createThumb function and pass to it as parameters the path // to the directory that contains images, the path to the directory // in which thumbnails will be placed and the thumbnail's width. // We are assuming that the path will be a relative path working // both in the filesystem, and through the web for links createThumbs("upload/","uploadthumbnails/",100); ?> <?php function createGallery( $pathToImages, $pathToThumbs ) { echo "Creating gallery.html <br />"; $output = "<html>"; $output .= "<head><title>Thumbnails</title></head>"; $output .= "<body>"; $output .= "<table cellspacing=\"0\" cellpadding=\"2\" width=\"500\">"; $output .= "<tr>"; // open the directory $dir = opendir( $pathToThumbs ); $counter = 0; // loop through the directory while (false !== ($fname = readdir($dir))) { // strip the . and .. entries out if ($fname != '.' && $fname != '..') { $output .= "<td valign=\"middle\" align=\"center\"><a href=\"{$pathToImages}{$fname}\">"; $output .= "<img src=\"{$pathToThumbs}{$fname}\" border=\"0\" />"; $output .= "</a></td>"; $counter += 1; if ( $counter % 4 == 0 ) { $output .= "</tr><tr>"; } } } // close the directory closedir( $dir ); $output .= "</tr>"; $output .= "</table>"; $output .= "</body>"; $output .= "</html>"; // open the file $fhandle = fopen( "gallery.html", "w" ); // write the contents of the $output variable to the file fwrite( $fhandle, $output ); // close the file fclose( $fhandle ); } // call createGallery function and pass to it as parameters the path // to the directory that contains images and the path to the directory // in which thumbnails will be placed. We are assuming that // the path will be a relative path working // both in the filesystem, and through the web for links createGallery("upload/","uploadthumbnails/"); ?> Do I really have to go through this malarchy just to resize an image?
  21. I've found a JS solution: http://www.dynamicdrive.com/dynamicindex4/thumbnail2.htm Given that I'll only have about twenty records (20 images viewers x 3 images = 60 images total) is it realistic to try and attempt squeezing all of this into the one page?
  22. Hi All, I want to output all existing records (text and three images) from a mySQL database. The image files are stored as paths btw. I want to output the three images dynamically rather than one beneath the other. By dynamic I mean: [*]An image viewer of sorts comprised of thumbnails that when clicked on display a larger size of the image. [*]Occurs within the one same page and each record has its own image viewer. A perfect example of what I'm looking for can be found here: http://www.carzone.ie/search/Alfa-Romeo/145/200840190195708/advert ??? My question is how should I approach this (PHP or Javascript or Ajax) ? ??? Does anyone know of any decent free open source tools or tutorials for this? I can't seem to pull up a whole lot of information on this through searching.
  23. Howdy, Firstly post your code in code blocks. Secondly it would be helpful to post a mock-up of a corrosponding html file that picks up on the styling (again in code blocks). That way we could copy and paste the two pages and try it for ourselves rather than speculating. Thirdly just ignore point one and two because this unfortunatley isn't the right spot for styling. If the CSS is directly affecting your PHP process and not just your page layout then maybe. Type the following into google: CSS Help Forum or CSS Firefox Conflicts or CSS Cross Browser Firefox or CSS Cross Browser. Good luck matey! Seems like a headscratcher... NUTS! This was obviously moved when I was posting. Stick to points one and two matey!
  24. Thanks Wildteen88! Form fully functioning as desired! This works fantastically and as a process is far more inteligent than I had originally tried to implement. It minimizes user task by automating the calculations in the background. As a result of stewing over your code for a bit (I'm very slow with PHP at the moment ) I now have a handle on arrays and dropdown menus. Not bad aspects to add to a newbs repertoire, eh? Here's a little feedback for you: I modified the mileage process just to deliver three error messages rather than two: [*]If the dropdown is empty. [*]If the text field is empty. [*]If the text field is not numeric. Its consists of an IF within an IF within an IF. I'm sure it could be streamlined a little more but its sufficently functional nonetheless. Here's how it goes: <?php //DEFINE THE ARRAY AS A VARIABLE $milage_unit_options = array('Miles', 'Kilometers'); //IF THE A VALUE IN THE DROPDOWN IS SELECTED if( array_key_exists($_POST['mileageu'], $milage_unit_options) ) { $mileageudropdowncheck = TRUE; //IF THE TEXT FIELD IS NOT EMPTY if (strlen($_POST['mileagev']) > 0) { $mileagev=TRUE; //IF THE TEXT FIELD IS NUMERIC if (is_numeric($_POST['mileagev'])) { $mileagevnumericcheck=TRUE; //IF THE FORM PROCESSES THIS FAR IT HAS PASSED THE IF EMPTY AND IF NUMERIC CHECKS AND IS NOW ALLOWED THE CONVERSION CALCULATION //CONVERSION TAKES PLACE HERE switch($_POST['mileageu']) { //CASE 0: MILES IS SELECTED FROM DROPDOWN case 0: $mileagem = $_POST['mileagev']; //CONVERT MILES TO KILOMETRES $mileagekm = $mileagem*1.609; break; //CASE 1: KILOMETRES IS SELECTED FROM DROPDOWN case 1: $mileagekm = $_POST['mileagev']; //CONVERT KILOMETRES TO MILES $mileagem = $mileagekm/1.609; break; } } //ELSE: IF THE TEXT FIELD IS NOT NUMERIC else { $mileagevnumericcheck=FALSE; $message_mileagevnumericcheck="Please input numeric values only (Do not include M or Km symbols.)!"; //echo "$message_mileagevnumericcheck"; } } //ELSE: IF THE TEXT FIELD IS EMPTY else { $mileagev=FALSE; $message_mileagev="You forgot to input the mileage in either miles or kilometres!"; //echo "$message_mileagev"; } } //ELSE: IF THE A VALUE IN THE DROPDOWN IS NOT SELECTED else { $mileageudropdowncheck = FALSE; $message_mileageudropdowncheck = " *Please ensure you have choosen Miles or Kilometers from the list provided"; //echo "$message_mileageudropdowncheck"; } ?> The error messages are called on beneath the relative fields as follows: <?php if (isset($message_mileageudropdowncheck)) echo $message_mileageudropdowncheck; ?> <?php if (isset($message_mileagev)) echo $message_mileagev; ?> <?php if (isset($message_mileagevnumericcheck)) echo $message_mileagevnumericcheck; ?> One thing I'm uncertain of is why I was supposed to remove the following two lines: $mileagem = mysql_real_escape_string($_POST['mileagem']); $mileagekm = mysql_real_escape_string($_POST['mileagekm']); I'm going to make an educated leap and assume that this was a typo and that you were instead referring to the removal of from the condition that checks that all variables are defined as TRUE before inserting the user input and uploading the image files. Two final questions before I close this thread off: [*]Why is it important to include an error message if the dropdown is blank? Will it not always have an option selected by default or will it vary from browser to browser? [*]I know from another thread that type="upload" fields will reset (blank) each time the form refreshes after a failed process (whenever an error is encountered). Does this hold true with dropdown menus (resets to first option with each refresh)? Thanks so much again!
  25. Use the code tags if you want the brainchilds to review your query.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.