Jump to content

jarvis

Members
  • Posts

    543
  • Joined

  • Last visited

Everything posted by jarvis

  1. Hi All, Sorry I'm struggling with trying to get distinct values from an array. I have the following code which pulls a list of clients from a news table: list($client_newsRecords, $client_newsMetaData) = getRecords(array( 'tableName' => 'news', 'orderBy' => 'client ASC', )); I then use the list to create a drop down: <select name="fieldname" size="1" onChange="openDir( this.form )"> <option selected="selected">-- Please Select --</option> <?php foreach ($client_newsRecords as $record): ?> <option value="downloads.php?client=<?php echo urlencode($record['client']); ?>" selected><?php echo $record['client']; ?></option> <?php endforeach ?> </select> The problem is, if several news articles are added with the same client, the drop down list shows loads of the same client in the list. Hence the reason for the removal of any duplicates. Any help is much appreciated Thanks again in advanced
  2. developerdave, you the man! Thank you!
  3. Don't be sorry, I'm just grateful for the help! That's cerainly done the job nicely, thanks! One tiny question, why does the very first image sit on a line of it's own, then it starts the whole rows? Sorry! & thanks
  4. Lol! Phew, thought it was me. The html it putputs is: <table class="client_category" width="600" align="center" border="1" cellpadding="0" cellspacing="0"> <tr> <td> <img src="/cmsAdmin/uploads/thumb/27_2.jpg" width="100" height="100" alt="AP Racing" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/68_2.jpg" width="100" height="100" alt="Autotorq" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/Axeon.jpg" width="100" height="100" alt="Axeon" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/Axtec.jpg" width="100" height="86" alt="Axtec" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/Bosal_001.jpg" width="100" height="24" alt="Bosal" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/bosch.jpg" width="100" height="100" alt="Bosch" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/capoco.jpg" width="100" height="100" alt="Capoco Design" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/7_2.jpg" width="100" height="100" alt="Chevrolet" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/chevron.jpg" width="100" height="100" alt="Chevron" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/38_2.jpg" width="100" height="100" alt="Connaught" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/37_2.jpg" width="100" height="100" alt="Continental Tyres" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/corus.jpg" width="100" height="100" alt="Corus" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/30_2.jpg" width="100" height="100" alt="Cummins" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/daftrucks_001.jpg" width="100" height="100" alt="DAF Trucks" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/56_2.jpg" width="100" height="100" alt="Ferrari" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/greenchem.jpg" width="100" height="100" alt="GreenChem" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/leyland.jpg" width="100" height="100" alt="Leyland Trucks" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/28_2.jpg" width="100" height="100" alt="Meguiar's" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/51_2.jpg" width="100" height="100" alt="Micheldever" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/Multipart_Colour.jpg" width="100" height="27" alt="Multipart" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/network-q_001.jpg" width="100" height="26" alt="Network Q" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/16_2.jpg" width="100" height="100" alt="Optare" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/65_2.jpg" width="100" height="100" alt="Revolve" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/Schrader.gif" width="100" height="39" alt="Schrader" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/stadco.jpg" width="100" height="100" alt="Stadco" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/58_2.jpg" width="100" height="100" alt="TomTom WORK" /> </td></tr><tr><td> <img src="/cmsAdmin/uploads/thumb/53_2.jpg" width="100" height="100" alt="Vauxhall Commercial Vehicles" /> </td></tr><tr><td> </td> </tr> </table> Thanks again!
  5. Thanks again developerdave. Sorry I'm sending you mad! I posted the same amend to the code as you. But as I mentioned above, it just lists the images down the page rather than in rows. Thanks
  6. NOTE: That error refers to the same line - thanks. Changing the line to: $float = (($i % 5) !== 0) ? '</td><td>' : '</td></tr><tr><td>'; Displays the page without errors but then the images are just in a list down the page rather than a table. Sorry again!
  7. Thought so, that however leads to: Parse error: syntax error, unexpected ';' Sorry to bother you (especially at work!) Thanks though!!
  8. Thanks developerdave. That gives the error: Parse error: syntax error, unexpected ')' in which is line $float = ($i % 5) !== 0) ? '</td><td>'; : '</td></tr><tr><td>'; Should I remove the bracket from 0) or add another in front of ($i%5? Many thanks
  9. Thanks developerdave. I've already got it working with CSS but really need it working with a table (dont ask!)
  10. Hi All, Am sure this is something straight forward, I've the following code which lists images from a db table: <?php foreach ($clientsRecords as $record): ?> <?php foreach ($record['client_logo'] as $upload): ?> <img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="<?php echo $record['client_name'] ?>" /> <?php endforeach; ?> <?php endforeach; ?> I'd like to convert this into a table with say 5 images per row. Is this possible? Thanks
  11. Sussed it: $startwidth = (($imagewidth - $watermarkwidth)); $startheight = "0";
  12. Hi All, Hope someone can point out the obvious! The following code positions my watermark graphic to the top left hand corner: $imagesource = $_GET['path']; $filetype = substr($imagesource,strlen($imagesource)-4,4); $filetype = strtolower($filetype); if($filetype == ".gif") $image = @imagecreatefromgif($imagesource); if($filetype == ".jpg") $image = @imagecreatefromjpeg($imagesource); if($filetype == ".png") $image = @imagecreatefrompng($imagesource); if (!$image) die(); $watermark = @imagecreatefromgif('watermark.gif'); $imagewidth = imagesx($image); $imageheight = imagesy($image); $watermarkwidth = imagesx($watermark); $watermarkheight = imagesy($watermark); $startwidth = (($imagewidth - $watermarkwidth)/100); $startheight = (($imageheight - $watermarkheight)/100); imagecopy($image, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight); #imagecopy($image, $watermark, 0, 0, $watermarkwidth, $watermarkheight); imagejpeg($image); imagedestroy($image); imagedestroy($watermark); Altering: $startwidth = (($imagewidth - $watermarkwidth)/100); $startheight = (($imageheight - $watermarkheight)/100); To $startwidth = (($imagewidth - $watermarkwidth)/0); $startheight = (($imageheight - $watermarkheight)/0); Positions the watermark to the middle. How can I set it to the top right? Many Thanks
  13. Hi, is this along the right lines: $SourceFile = $_GET['path']; function watermarkImage ($SourceFile, $DestinationFile) { list($width, $height) = getimagesize($SourceFile); $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($SourceFile); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height); $src = imagecreatefromgif('watermark.gif'); imagecopymerge($image_p, $src, 0, 0, 0, 0, 800, 600, 75); echo $SourceFile; if ($DestinationFile<>'') { imagejpeg ($image_p, $DestinationFile, 100); } else { header('Content-Type: image/gif'); imagejpeg($image_p, null, 100); }; imagedestroy($image); imagedestroy($image_p); }; Thanks!
  14. Hi All, Hope someone can help. The below code displays a watermark over an image, how can I alter the code so it actually writes it on the image? Otherwise, you can download the pic and the watermark isn't on it.: $imagesource = $_GET['path']; $filetype = substr($imagesource,strlen($imagesource)-4,4); $filetype = strtolower($filetype); if($filetype == ".gif") $image = @imagecreatefromgif($imagesource); if($filetype == ".jpg") $image = @imagecreatefromjpeg($imagesource); if($filetype == ".png") $image = @imagecreatefrompng($imagesource); if (!$image) die(); $watermark = @imagecreatefromgif('watermark.gif'); $imagewidth = imagesx($image); $imageheight = imagesy($image); $watermarkwidth = imagesx($watermark); $watermarkheight = imagesy($watermark); $startwidth = (($imagewidth - $watermarkwidth)/2); $startheight = (($imageheight - $watermarkheight)/2); imagecopy($image, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight); imagejpeg($image); imagedestroy($image); imagedestroy($watermark); Thanks again!
  15. Solved: $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; $filename = basename($pageURL); #echo $filename; //debug if ($filename == 'index.php') { echo 'home'; } elseif ($filename == 'about.php') { echo 'about'; } elseif ($filename == 'services.php') { echo 'services'; } elseif ($filename == 'affiliate.php') { echo 'affiliate'; } elseif ($filename == 'links.php') { echo 'links'; } else { echo 'contact'; }
  16. Sorry to sound daft, but if $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; $filename = basename($pageURL); echo $filename; //debug Can give me the filename, then don't I just need to say if filename = $filename, then show x y or z? As $filename would be links.php, so don't I just need to say, it $filename is equal to links.php show whatever?
  17. Hi thorpe, No, no rewrite in place. I thought I could just grab the filename, then do a simple statement to match the filename, if it matches, show a particular image!?
  18. Hi, Am probably being thick (not enough coffee yet!!!). Why is the below not working: $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; $filename = basename($pageURL); echo $filename; //debug if ($filename == 'index.php') { echo 'home'; } elseif ($filename == 'about.php') { echo 'about'; } elseif ($filename == 'services.php') { echo 'services'; } elseif ($filename == 'affiliate.php') { echo 'affiliate'; } elseif ($filename == 'links.php') { echo 'links'; } else($filename == 'contact.php') { echo 'contact'; } The idea is it get the filename from the URL and depending which page, a different image will be shown. Sorry it's a silly question. Your help is appreciated! Many thanks
  19. Thanks fooDiggi, Do I simply replace: ImageCopyResized($im,$im_big,0,0,300,230,$width,$height,MAX_XY_SMALL,MAX_XY_SMALL); With imagecopyresampled($im,$im_big,0,0,300,230,$width,$height,MAX_XY_SMALL,MAX_XY_SMALL); Thanks
  20. Hi All, I've got the following script which resizes my images. It then produces: 1) A cropped thumbnail 2) A scaled down image Is there anything I can do to improve the images quality of the resized file? The client using it is uploading very high res images you see. Thanks <?php function saveThumb($gal,$fn) { define("MAX_XY_SMALL", 150); // maximum width or height of thumbnail image define("MAX_XY_LARGE", 550); // maximum width or height of thumbnail image $fpath = "categories/$gal/$fn"; //print $fpath."\n"; /* GetImageSize returns an array: * $info[0] - horizontal size of image in pixels * $info[1] - vertical size of image in pixels * $info[2] - type of image (1=GIF, 2=JPEG, 3=PNG) */ $info = GetImageSize("$fpath"); //print_r($info); // do we need to resize image? if ($info[0] > MAX_XY_SMALL || $info[1] > MAX_XY_SMALL) { // is image landscape? if ($info[0] >= $info[1]) { $width = MAX_XY_SMALL; $height = MAX_XY_SMALL; // or portrait? } else { $height = MAX_XY_SMALL; $width = MAX_XY_SMALL; } } else { // use original dimensions $width = $info[0]; $height = $info[1]; } if ($info[0] > MAX_XY_LARGE || $info[1] > MAX_XY_LARGE) { // is image landscape? if ($info[0] >= $info[1]) { $width_large = MAX_XY_LARGE; $height_large = $info[1]*MAX_XY_LARGE/$info[0]; // or portrait? } else { $height_large = MAX_XY_LARGE; $width_large = $info[0]*MAX_XY_LARGE/$info[1]; } } else { // use original dimensions $width_large = $info[0]; $height_large = $info[1]; } // create new thumbnail image //echo "<br>$width - $height<br>"; $im = ImageCreateTrueColor($width, $height); $im_large = ImageCreateTrueColor($width_large, $height_large); /* determine image type and load original image. Notice new tests for image * types. The GD extension has changed a lot over the years, dropping GIFs * and adding PNG support. By testing, we avoid trying to process an image * PHP can't deal with */ $im_big = ""; // default is no image switch ($info[2]) { case 1 : if (ImageTypes() & IMG_GIF) // test for GIF support $im_big = ImageCreateFromGIF("$fpath"); break; case 2 : if (ImageTypes() & IMG_JPG) // test for JPEG support $im_big = ImageCreateFromJPEG("$fpath"); break; case 3 : if (ImageTypes() & IMG_PNG) // test for PNG support $im_big = ImageCreateFromPNG("$fpath"); break; case 4 : if (ImageTypes() & IMG_BMP) // test for BMP support $im_big = ImageCreateFromBMP("$fpath"); break; } if ($im_big) { /* resize original image into thumbnail - see PHP Manual for details on * the arguements ImageCopyResized takes */ #ImageCopyResized($im,$im_big,0,0,0,0,$width,$height,MAX_XY_SMALL,MAX_XY_SMALL); #ImageCopyResized($im,$im_big,0,0,150,150,$width,$height,MAX_XY_SMALL,MAX_XY_SMALL); ImageCopyResized($im,$im_big,0,0,300,230,$width,$height,MAX_XY_SMALL,MAX_XY_SMALL); ImageCopyResized($im_large,$im_big,0,0,0,0,$width_large,$height_large,$info[0],$info[1]); } else { // couldn't load original image, so generate 'no thumbnail' image instead $width = 150; $height = 150; $im = ImageCreate($width, $height); // create a blank image $bgc = ImageColorAllocate($im, 0, 0, 0); // background color = black $tc = ImageColorAllocate($im, 255, 255, 255); // text color = white ImageFilledRectangle($im, 0, 0, $width, $height, $bgc); // draw rectangle ImageString($im, 3, 9, 36, "No thumbnail", $tc); // add text ImageString($im, 3, 17, 48, "available", $tc); } /* save our image in thumb directory - if the second argument is left out, * the image gets sent to the browser, as in thumbnail.php */ ImageJPEG($im, "categories/".$gal."/t_".$fn, 100); ImageJPEG($im_large, "categories/".$gal."/".$fn, 100); // clean up our working images ImageDestroy($im_big); ImageDestroy($im); ImageDestroy($im_large); } ?> Thanks in advanced
  21. Sorry to bump, just wondering if anyone can help at all? Apologies again for the plea Thanks very much in advanced! Your help is much appreciated!
  22. Ok, I think I'm making head way but still not getting it exactly right. Instead of: echo '<script type="text/javascript">alert("You forgot to enter your email address!");</script>'; I change it to $email_popup = '<script type="text/javascript">alert("You forgot to enter your email address!");</script>'; If i then add this at the end of my page as <?php if (isset($_POST['submitted'])) { echo $email_popup; }?> This displays the top of the page, the form but still fails to show the main bg (called in via css) I then though about changing the pop up to: echo 'div id="login_bg">'; $email_popup = '<script type="text/javascript">alert("You forgot to enter your email address!");</script>'; echo '</div>'; This doesn't work as once you clear the pop up, it shows the entire bg image again at the end of the page! There must be an easy way to get around this???? TIA
  23. Thanks YourNameHere, however, the client really wants the pop up. How can I alter my script to show the pop up and stop the site going white in the bg? Many thanks
  24. Hi All, Odd one this, I've got the following code (below) which is a simple log in form. The client wanted a pop to inform you when you've not completed a field and an asterix to appear. This is fine. However, if you forget to enter some info, the pop up appears but the page behind goes blank, as if the rest of the page wont load until you click OK. How can I stop this? Thanks in advanced! <?php // This is the login page for the site. // Include the configuration file for error management and such. require_once ('./includes/config.inc.php'); // Set the page title and include the HTML header. $page_title = 'Login'; include ('./includes/header.html'); $email_error = ''; $pw_error = ''; $error_message = ''; if (isset($_POST['submitted'])) { // Check if the form has been submitted. require_once ('../mysql_connect.php'); // Connect to the database. // Validate the email address. if (!empty($_POST['email'])) { $e = escape_data($_POST['email']); } else { echo '<script type="text/javascript">alert("You forgot to enter your email address!");</script>'; $e = FALSE; $email_error = '<span class="required"><img src="images/star.gif" /></span>'; } // Validate the password. if (!empty($_POST['pass'])) { $p = escape_data($_POST['pass']); } else { $p = FALSE; echo '<script type="text/javascript">alert("You forgot to enter your password!");</script>'; $pw_error = '<span class="required"><img src="images/star.gif" /></span>'; } if ($e && $p) { // If everything's OK. // Query the database. $query = "SELECT user_id, name, acc_type FROM users WHERE (email='$e' AND pass=SHA('$p')) AND active IS NULL"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); if (@mysql_num_rows($result) == 1) { // A match was made. // Register the values & redirect. $row = mysql_fetch_array ($result, MYSQL_NUM); mysql_free_result($result); mysql_close(); // Close the database connection. $_SESSION['user_id'] = $row[0]; $_SESSION['name'] = $row[1]; $_SESSION['acc_type'] = $row[2]; // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $acc_type = $_SESSION['acc_type']; if ($acc_type == '1') { $url .= '/print.php'; } else { $url .= '/category.php'; } ob_end_clean(); // Delete the buffer. header("Location: $url"); exit(); // Quit the script. } else { // No match was made. echo '<script type="text/javascript">alert("Either the email address and password entered do not match those on file or you have not yet activated your account!");</script>'; } } else { // If everything wasn't OK. $error_message = '<span class="required">Please fill in all boxes to log in!</span>'; } mysql_close(); // Close the database connection. } // End of SUBMIT conditional. ?> <!-- box_top --> <div id="box_top"> <img src="images/login_box_top.jpg"> </div> <!-- /box_top --> <!-- box_content --> <div id="login_box_content"> <!-- left_column --> <div id="login_left_column"> <img src="images/client_login_text.gif" /> <form action="login.php" method="post"> <table border="0" width="320"> <tr> <td><img src="images/email_address.gif" /></td> <td><div class="myBoxLh"></div><input type="text" name="email" style="width:160px;" maxlength="90" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /><div class="myBoxRh"></div></td> <td><?php if (isset($_POST['submitted'])) { echo $email_error; }?></td> </tr> <tr> <td><img src="images/password.gif" /></td> <td><div class="myBoxLh"></div><input type="password" name="pass" style="width:160px;" maxlength="20" /><div class="myBoxRh"></div></td> <td><?php if (isset($_POST['submitted'])) { echo $pw_error; }?></td> </tr> <tr> <td colspan="2"><div align="right"><input type="image" src="images/submit.jpg" name="submit" value="Login" class="submit_small" /></div> <input type="hidden" name="submitted" value="TRUE" /></td> <td><img src="images/spacer.gif" width="14"/></td> </tr> </table> </form> </div> <!-- /box_content --> <!-- box_bottom --> <div id="login_box_bottom"> <img src="images/login_box_bottom.jpg"> </div> <!-- /box_bottom --> <!-- login_copyright --> <div id="login_copyright"> <img src="images/login_copyright.jpg"> </div> <!-- /login_copyright --> </div> <!-- /wrapper --> <?php // Include the HTML footer. include ('./includes/footer_login.html'); ?>
  25. Thanks Cags
×
×
  • 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.