Jump to content

sleepyw

Members
  • Posts

    81
  • Joined

  • Last visited

Everything posted by sleepyw

  1. Problem solved....was a combination of a minor CSS issue (z-index) and an order issue with the PHP generating some of the images.
  2. Just to show multiple rows and the behavior of how the last item in each row doesn't show the overlayed icon:
  3. This is driving me nuts. I've stripped the code down to the most basic elements. I've looked online at other examples. But I cannot get this to work. I basically have a big image gallery, and in the bottom-right corner of each thumbnail, I want to overlay a small clickable icon. However, the last image of a row (for example, if I have 3 rows of images, the last one on the right of each column) will not show the icon. If I try it with just one image, nothing shows up at all for an overlay. Here's the code: <div style='text-align: center; padding: 5px; margin: 0px; margin-right: 0px; float: left; width: 120px; position: relative;'> <img src='images/hires.png' style='position: absolute; top: 40px; left: -60px;'> <img src='images/folder_orange.png'> </div> <div style='text-align: center; padding: 5px; margin: 0px; margin-right: 0px; float: left; width: 120px; position: relative;'> <img src='images/hires.png' style='position: absolute; top: 40px; left: -60px;'> <img src='images/folder_orange.png'> </div> The resulting page looks like this: I've played with the code so many ways, but can't figure this out. Anyone?
  4. Hi again requinix! OK...I need to edit my post. It actually did work, but now the bullet point character is not being accepted when it previously was (I think that's the \u2022). Edit #2: I moved the \u2022 up further into the regexp and it's working now. Run into this a lot where the order is critical, but not sure what the order is supposed to be. Thanks again for your help!
  5. I'm using the frmvalidator.addValidation code (with the associated validator.js file) and I cannot for the life of me find anywhere how to include an allowable character of a line break to the regexp. For example, I might have something like: frmvalidator.addValidation("Notes","regexp=^[A-Za-z0-9\u005F\ \.\-\@\,\%\*\!\?\$\&\'\#\+\=\:\;\(\)\u2022]{1,300}$","Notes can only contain the following non-alphanumeric characters: ,'?!/*&%$#@:;_+=@"); But if a user enters a line break, it won't accept it. I've tried adding \u000D, \u000A, \u000C, U+000D, \r\n, \n ..... nothing works. Am I missing something really obvious?
  6. Ack - can't edit my above post anymore. Tinkering a little...I think it's working now....will report back. UPDATE: yes - it's working! Thank you both for your assistance!
  7. OK, thanks again to both of you! I think I made the changes you both suggested. It's not likely someone would start an email address with the "@" symbol, so I'm not too concerned with that. Good news is I'm not getting the implode error anymore. Bad news is the result is coming out wonky. As a test, I typed in the names John Smith and Lisa White. The out put was "John.Smith,.Lisa.White@xyz.com". And if there is any email address with "@" in it, it ignores the whole function and just uses the original string as-is. So obviously, I'm missing something that separates each recipient--it's checking the entire string. Do I need to put [$key] in the strpos and/or str_replace? Here's what I changed the code to: $exploded_new_recipients = explode(';', $recipient); // separate each item into new var $recipient foreach ($exploded_new_recipients as $key => $recipient) { // remove beginning and end white space from each $recipient = trim($recipient); // if item does not include @, replace the space with a '.' and add end email domain if ((strpos($recipient,'@')) == false) { $new_recipients = str_replace(" ", ".", $recipient) . "@xyz.com";} else {$new_recipients = $recipient;} // update var $exploded_new_recipients[$key] = $new_recipients; } // put string back together with ', ' between each value $final_email_list = implode(', ', $exploded_new_recipients);
  8. Well, I have to admit I'm lost and getting an error on the implode function (although I'm sure most of the rest of this is probably wrong, too). Here's what I have (including comments to show what I'm trying to do). The current $recipient will likely have semicolons separating each name/email address, which explains the explode ';'... $exploded_new_recipients = explode(';', $recipient); // separate each item into new var $recipient foreach ($exploded_new_recipients as $key => $recipient) { // remove beginning and end white space from each $recipient = trim($recipient); // if item does not include @, replace the space with a '.' and add end email domain if ((strpos($recipient,'@')) == false) { $new_recipients = str_replace(" ", ".", $recipient) . "@xyz.com";} else {$new_recipients = $recipient;} // update var $exploded_new_recipients[$key] = $recipient; } // put string back together with ', ' between each value $final_email_list = implode(', ', $recipient);
  9. Thank you again for taking the time to reply! Let me see if I can piece this together (I'm not super proficient with PHP). If I run into issues, I'll post the code I'm working on and hopefully you will still be around to point me in the right direction.
  10. Thank you, requinix. That makes sense, but what will hang me up if the foreach. I don't think I know how to do that...although the rest I think I could manage.
  11. I'm having a probably server-side issue that I cannot fix, so I need to find a workaround. I have a page designed to allow people to enter their report and email it to a list of people (it will vary each time). There are 2 ways people can enter an email recipient: full email address or first and last name (which is how you find people in the corporate Outlook Exchange accounts). So when the recipient field is entered, it may contain a mix of full email addresses or just first and last names (separated by commas). For example, here's my original array of email recipients: $recipient = "bob.smith@abc.com, John Smith, Barb Johnson"; The problem is with the first and last names. When the email sends, it adds the entire domain of the server to the email address. For example, if the server I'm using is "test.server.xyz.com" and I enter "John Smith", when the email gets sent, it sends to "John.Smith@test.server.xyz.com" instead of just "John.Smith@xyz.com". So I'm wondering if there's code that would search an array using mixed email addresses, locate just the ones with first and last names, and fix them. How would I code this so it ended up as: $new_recipients = "bob.smith@abc.com, John.Smith@xyz.com, Barb.Johnson@xyz.com"; Thanks in advance! Note: I've asked IT if they can fix something on the server end to correct this, but I'm not counting on their help, so looking for a workaround.
  12. I appear to have found the issue from some outside help....swapping the quotes again (single/double quotes) seemed to work when I tried it again. Previously it gave me errors. @gristoi Yeah I saw the single quote, but that was my trascription error here, not in my actual code. $Domain had a result, as I tested it when echoing the data back to make sure something was actually there.
  13. I've been baffled by this for 2 days now and cannot figure it out after exhaustive searches. I'd like to think I'm doing this correctly, but cannot get it to work. I'm trying to use a variable within a query WHERE statement, and it shows 0 results. If I directly hardcode the text instead of using the variable, it works. The variable is pulling from a $_GET, and if I echo that variable, it is showing the correct text. Here's my code: $Domain = $_GET['Domain']; $result = mysql_query(SELECT Code, Title, Domain, Status FROM tablename WHERE Domain="$Domain" ORDER BY Code'); If I swap out "$Domain" for direct text, like "ABC", it works. I have tried swapping out the quotes and single quotes throughout the statement, removing the quotes around $Domain, concatenating the statement separately....all yield erros or the same result. And as stated, if I echo $Domain, it shows "ABC" (or whatever it's supposed to show), so i know it's pulling correctly from the $_GET. Anyone know what I'm doing wrong?
  14. OK - I temporarily removed the banner and was able to read the error (typical syntax error I missed). It appears as though your suggestion is working! Muchas gracias, kind sir!
  15. Barand - it's not working. The entire page is coming back blank (I can't see if there's an error because of a banner at the top lkely covering it). And I'm not sure what you mean by "normalized" my data. The table is a project list, and each column is a person that worked on the project. The 3 columns represent different roles, and people can be in any of the 3 columns. I'm not sure if that has anything to do with what you mean or not. EDIT: I see you reworked the code a little, and I modified mine, but the result is the same (an entirely blank page, except for the banner).
  16. Ugh - title should say sort, not sport, sorry. This should be easy, but for the life of me, I cannot get this to work. I've been staring at it for so long, I'm going nuts. Ultimately, what I'm trying to do is combine the unique results of a query (of 3 columns of a table) to populate a drop-down menu. I have a function in place, however, that function only grabs data from one of the 3 fields I designate, not all 3. So I'm trying to create a new query to search all 3 fields, remove duplicates, sort alphabetically, and then display them in the drop-down list. Here's the function I originally had, but I don't know how to alter this (if possible) to include combining 3 fields instead of having to list 1: function filldropdown($sql, $sfieldname) { $result=mysql_query($sql); while($row=mysql_fetch_assoc($result)){ echo "<option value='" . $row[$sfieldname] . "'>" . $row[$sfieldname] . "</option>"; } mysql_free_result($result); return; } And then this is the code that adds the list to the page, except you'll notice at the end of the query, I have to list only 1 field to pull from (TW), instead of it listing TW1, 2 and 3. <? filldropdown("SELECT distinct TW, TW2, TW3 from TABLE", "TW"); ?> So instead, I'm trying to do this (I've simplified this to hopefully make it easier to understand my thought process of what I'm trying to do). What am I doing wrong? $TW1 = mysql_query("SELECT distinct TW from TABLE"); $TW2 = mysql_query("SELECT distinct TW2 from TABLE"); $TW3 = mysql_query("SELECT distinct TW3 from TABLE"); // combine and sort results of TW, TW2, TW3 fields into a single list $TW1result = mysql_fetch_array($TW1); $TW2result = mysql_fetch_array($TW2); $TW3result = mysql_fetch_array($TW3); $CombinedTW = array_merge($TW1result, $TW2result, $TW3result); $UniqueTW = array_unique($CombinedTW); $ALLTW = asort($UniqueTW); while($ALLTW) { echo "<option value='" . $ALLTW . "'>" . $ALLTW . "</option>"; }
  17. I managed to figure it out. Here's essentially what I did: mysql_query('SELECT TABLE1.id, TABLE1.customer.name, SUM(TABLE2.orders) as total_dollars FROM TABLE1, TABLE2 WHERE TABLE1.id = TABLE2.id GROUP BY id');
  18. Sorry for the confusing title....best way I could explain it briefly. I have 2 tables. For the sake of discussion, we'll say TABLE1 is a db of customer information, and TABLE2 is a db of that customer's orders (so there are multiple rows in TABLE2 with each order they've placed). In TABLE1, there is an ID field (the unique customer number). In TABLE2, that number is also used for each row for that customer's orders (to identify that customer). What I'm trying to do is create a HTML table as an output on a page that will display some info from the customer from TABLE1, but then I want to total up the customer's orders from TABLE2 and display that combined amount in the same HTML table. I thought I could do it, but after sitting and trying to code this for a couple hours, it became clear I was missing something, as what I'm doing to combine and total the relevant info from TABLE2 is not working. Here's what I'm doing, even though the 2nd half of it is wrong. I'm hoping someone can spot my error(s) and point me in the correct direction. I'm obviously not going about it the right way. <? // get id numbers for relevant customers $result1 = mysql_query('SELECT id, customer_name FROM TABLE1'); while($row1 = mysql_fetch_array($result1)){ // run query of order amounts in TABLE2 based on customer id from TABLE1 $result2 = mysql_query('SELECT order_total FROM TABLE2 WHERE id="$row1[id]"'); while($row2 = mysql_fetch_array($result2)){ $totaldollars += $row2['order_total'];} ?> <tr> <td align="center" valign="top"><? echo $row1['customer_name']; ?> </td> <td align="center" valign="top">$ <? echo $totaldollars; ?> </td> </tr>
  19. Thank you for taking a look. The intent was not to put the files in a database....for ease of use (to be able to just upload via FTP and have everything appear--which is works perfectly in that respect). I'm not sure if the code you put in your post was the suggested fix, but I inserted it and it doesn't do anything.
  20. I received some code from someone several months ago when I was searching for a way to simply upload photos to an FTP site and have the PHP automatically generate thumbnails for each gallery/directory. It uses jquery for displaying the images themselves. I cleaned it up and modified the PHP portion a little, but it's not code I'm familiar with (readdir, etc.). This is for an internal "stock photo" site our department uses. All of the file names are the keywords of the photos. We used to have the images on a SharePoint site, so the keywords were searchable. But since I had to relocate the images and create my own gallery, I don't have that search function anymore. I'm clueless about how to read through the directories with the search function like a query in MySQL. I'm trying to add the keyword GET function to the URL so the page would display the images including the keyword entered by the user (with an IF/ELSE statement to ignore the keyword search if ithe GET is empty). That's not the problem. The entire set of code is below, as its free for use to anyone else that is looking for something where they don't have to manually create thumbnails for an image gallery. The first block of code is the original code. The second block is where I'm trying to insert the search box and the code to perform the search. The third block is the original ending code. The 2nd block, where I need help, is where it would be something like 'QUERY($files) WHERE $files is LIKE %$keyword%'. The search needs to be global (all subdirectories, not just the top level). Obviously that's just an incomplete piece, but an idea of what I'm trying to do. Is this an easy query to create? <? // USER DEFINED $dir = "pics/"; // directory of images as related to index.php $height ="100"; //thumbnail image height -- needs to be defined for IE $width ="100"; //thumbnail image width -- needs to be defined for IE ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Photo Gallery</title> <link href="css/css.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script> <script type="text/javascript" src="js/jquery.mousewheel-3.0.6.pack.js"></script> <script type="text/javascript" src="js/fancybox/jquery.fancybox.js?v=2.1.0"></script> <link rel="stylesheet" type="text/css" href="js/fancybox/jquery.fancybox.css?v=2.1.0" media="screen" /> </head> <? $gallery = $_GET["gallery"]; $keyword = $_GET["keyword"]; $dir = $dir.$gallery."/"; //Put files into an array // create a handler to the directory $dirhandler = opendir($dir); // read all the files from directory $nofiles=0; while ($file = readdir($dirhandler)) { // if $file isn't this directory or its parent //add to the $files array if ($file != '.' && $file != '..') { $nofiles++; $files[$nofiles]=$file; } } //close the handler closedir($dirhandler); //Back button to appear at the top of each page to go to the previous directory if not on the main page if ($gallery !="" or $keyword !="") { echo "<div><a href='javascript:history.go(-1)'><img src='images/up.png' border='0'></a></div>"; } //*************************************************************************// // KEYWORD SEARCH BOX- create text box to search entire directory for that keyword and display page in grid pattern with results ?> <div style='position:relative; left:10px;'> <form action='index_search.php?keyword=$keyword' method='get' name='search'> <input type='text' name='keyword' size='25'> <input type='submit' value='Search Keyword'> </form> </div> <? // PERFORM KEYWORD SEARCH if ($keyword !="") { echo "<div class='keytext'>Keyword search: <b>" . $keyword . "</b><br/></div>"; /*********************************************************************************************************/ /*********************************************************************************************************/ /* ***** THIS IS WHERE THE SEARCH OF DIRECTORY FILES NEEDS TO OCCUR AND OUTPUT RESULTS AS $files */ /* get results where $file LIKE %$keyword%; */ /*********************************************************************************************************/ /*********************************************************************************************************/ //Show images foreach ($files as $file) { if ($file!="."&&$file!="..") { $extention = explode('.', $file); if ($extention[1] != "") { echo "<div class='imgwrapper'>"; echo"<a class='fancybox' rel='group'' href='$dir$file' return false' title='$filename'>"; echo "<img src='timthumb.php?src=$dir$file&h=$height&w=$width' alt='$extention[0]' width='$width' height='$height'/>"; echo"</a><br/>"; $file_name = current(explode('.', $file)); echo substr($file_name,0,21); echo "</div>"; } } } } else { // starts the split from keyword or no keyword //***********************************************************************// sort($files); // sort folder names alphabetically //Show the folders foreach ($files as $file){ if ($file!="."&&$file!="..") { sort($files); //Sorts the array (file names) alphabetically -- not the directory/folder names $extention = explode('.', $file); if ($extention[1] == "") { echo "<div class='imgwrapper'>"; echo "<a href='?gallery=$gallery/$file'>"; echo "<img src='images/folder.jpg' border='0'><br/>"; echo current(explode('.', $file)); echo "</a>"; echo "</div>"; } } } ?> <div style="clear:both"></div> <? //Show images foreach ($files as $file){ if ($file!="."&&$file!="..") { $extention = explode('.', $file); if ($extention[1] != "") { echo "<div class='imgwrapper'>"; echo"<a class='fancybox' rel='group'' href='$dir$file' return false' title='$filename'>"; echo "<img src='timthumb.php?src=$dir$file&h=$height&w=$width' alt='$extention[0]' width='$width' height='$height'/>"; echo"</a><br/>"; $file_name = current(explode('.', $file)); echo substr($file_name,0,21); echo "</div>"; } } } } // ends the else splitting the search from non-search ?> <script type="text/javascript"> $(document).ready(function() { $(".fancybox").fancybox(); }); </script> Thanks in advance if anyone can help.
  21. I had taken something that someone else created and simplified them for display purposes here. As for JS vs. PHP, it's an issue because I'm not as familiar with JS (functions and such) as simple PHP (the server this content is being hosted on doesn't support PHP). Thank you for your reply and suggestion!
  22. I've got some code that will toggle items on and off, and all works. However, I have 4 items that are clickable, and whichever is clicked, the div field for that item opens in the same area of the sacreen. Therefore, when one of the items is clicked, anything else open needs to close, or they stack on top of each other. I cannot figure out how to get any other items to close when a new one is clicked. Here are the elements I'm using right now: CSS: .unhidden { background-color: #ff0000; height: 190px; width: 300px;} .hidden { visibility: hidden;} JS: <script type="text/javascript"> function unhide(divID) { var item = document.getElementById(divID); if (item) { item.className=(item.className=='hidden')?'unhidden':'hidden'; } } </script> HTML DIV that is clicked: <div><a href="javascript:unhide('ONE');" >ONE</a></div> <div id="ONE" class="hidden">Text that only shows up when ONE is clicked.</div> <div><a href="javascript:unhide('TWO');" >TWO</a></div> <div id="TWO" class="hidden">Text that only shows up when TWO is clicked.</div> <div><a href="javascript:unhide('THREE');" >THREE</a></div> <div id="THREE" class="hidden">Text that only shows up when THREE is clicked.</div> <div><a href="javascript:unhide('FOUR');" >FOUR</a></div> <div id="FOUR" class="hidden">Text that only shows up when FOUR is clicked.</div> I've tried several variations (creating new functions, each that would hide the previous item when clicked), or adding condiitons to the existing JS to hide the others. I'm somewhat of a JS newb, and I could figure this out if it were PHP, but i don't use JS much. This particular task requires JS. Any ideas how to modify what I'm using to work? Thanks in advance.
  23. I've been away from PHP for a bit and thought I was updating something simple until I sat down to write the code, and I'm completely stumped. Here's what I'm trying to do: 1. Search for all codes from a db table - each result has 3 letters followed by 4 numbers (e.g., ABC1234) 2. From those results, each item from that array needs to have the first 3 characters stripped from it, leaving JUST the last 4 numbers 3. I then need to sort all of those results to show ONLY the highest number. For example: $code_search = mysql_query("SELECT Code FROM table"); That will yield an array with results like: "ABC1234", "XYZ9345", "QHD3062", "PVT7655" I need to remove the first three letters from each of those to just show the last 4 numbers, sort those in descending order, and display the highest number, which in the above example would be "9345". Here's the code to show what I'm TRYING to do, which is obviously wrong because I've got a command (substr) trying to strip characters from an array when it needs to be a string....but after searching for an hour, I can't seem to find the right code to remove the letters from the array results. $code_search = mysql_query("SELECT Code FROM table"); $code_results = mysql_fetch_array($code_search); // remove first three letters from above array to only show final 4 numbers $high_code_num = substr ($code_results, 3, 4); // sort above results descending to just show the top result (highest number) $sorted_codes = rsort ($high_code_num); // show just the top result only $top_course_code = $sorted_codes[0]; Ay help for this lost soul? TIA
×
×
  • 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.