Jump to content

Psycho

Moderators
  • Posts

    12,157
  • Joined

  • Last visited

  • Days Won

    129

Everything posted by Psycho

  1. I'm not sure of a max length, but why would you want to put that much "functionality" in the trigger? In my opinioin, a trigger is just that - just a trigger to call a function. I would suggest just using the element IDs in the trigger and have the first part of the function do the determination as to whether the elements are checked or not. Here is some sample code (not tested, but logic should be sound) onclick="myfunction('home'+'/'+'help')" Add as many IDs as needed separated by a delimeter character (in this case the forward slash) function myfunction(params) { var paramAray = params.split('/'); var inputVal for (var i=0; i<paramAray.length; i++) { inputVal += (document.getElementById(paramAray[i]).checked==true)?1:0; } //Continue with function as before and use inputVal }
  2. Just because I want to throw fuel on the fire... You are all wrong when you say that javaScript is only run client-side. JavaScript can be run server-side. So there! http://en.wikipedia.org/wiki/Server-side_JavaScript http://www.amazon.com/Server-Side-JavaScript-Developing-Integrated-Applications/dp/020143329X http://docs.huihoo.com/javascript/ServerJSv14/docs/contents.htm
  3. Well, I would partially agree. Although some people would consider "dynamically" displaying a paragraph as "dynamic" content, I do not. There is an important distinction there. True dynamic content (in my opinion) is content that you can't predetermine before the user clicks some particular action - such as paginated records or an IM tool. With the user's request above I am assuming it is static text that will just be changing display property (if the text changed each time he expanded it then that would be dynamic). In those situation I typically support handling it all in the in-line JavaScript code. However, no matter what your girlfriend says, size does matter. Even though many people have broadband connections - not all do. And even so, reducing bandwidth is somethign to pay attention to. If you have many different expandable sections with a lot of text, then it could be advantageous to dynamically load the content. There is no one rule fits all - each situation is different.
  4. Yes, you can use PayPals IPN (Instant Payment Notification): https://www.paypal.com/ipn There are some scripts readily available, just google for them. There are some examples on the link above as well.
  5. Unless you are dealing with a LOT of text, AJAX would be overkill (and the delay would make it a poor choice as well). This is really a javascript/css issue, so this is in the wrong forum. But here is a down-and-dirty working example: <script type="text/javascript"> function displayPara(fieldID, displayBol) { var paraObj = document.getElementById(fieldID); var showObj = document.getElementById(fieldID+'_show'); var hideObj = document.getElementById(fieldID+'_hide'); paraObj.style.display = (displayBol)? '' : 'none' ; showObj.style.display = (!displayBol)? '' : 'none' ; hideObj.style.display = (displayBol)? '' : 'none' ; } </script> <a href="#" onclick="displayPara('para1', false);" id="para1_hide" style="display:none;">Hide Text</a> <a href="#" onclick="displayPara('para1', true);" id="para1_show" style="">Show Text</a> <div id="para1" style="display:none;">The text you want to hide/display will go here</div>
  6. OK, as I alluded to before I had to mock up a couple of tables to test on since I don't have your database. This should be easily corrected by moving the WHERE clause into the JOIN as follows: SELECT horsecat.category, horsecat.horseCatID, lookuphorsecat.userID FROM horsecat LEFT JOIN lookuphorsecat ON horsecat.horseCatID = lookuphorsecat.catID AND lookuphorsecat.userID = '$dbOutput' On further review I would probably go one step further with an IF/ELSE in the select clause like this (also added table references for clarity): SELECT hc.category, hc.horseCatID, IF(luhc.userID='$dbOutput',1,0) as checked FROM horsecat hc LEFT JOIN lookuphorsecat luhc ON hc.horseCatID = luhc.catID AND luhc.userID = '$dbOutput' Now the query will return a value for "checked" 1=true/0=false
  7. Well, I don't know exactly how you are doing the parent links. Do all the parent links go to the same page (but with different variable on the query string), or do they have a specific link that is entered in the link_types table? I will assume the first option: $query = "SELECT link_types.id, link_types.name, COUNT(links.name) as count FROM link_types JOIN links ON link_types.id = links.type_id"; $result = mysql_query($query, $connection) or die (mysql_error()); while ($row = mysql_fetch_array($result)) { echo "<a href=\"show_records.php?id={$row['id']}\">{$row['name']} ({$row['count']})</a>"; } FYI: Why would you use the at symbol on the mysql_query() call if you are also going to include error handling with the die function? I would think that the at symbol (which suppresses errors) would cancel out the error handling.
  8. But, will you know whether the string was shortened or not so you know whether or not to show the elipses? Also, it won't prevent words from being cut inappropriately.
  9. Well, you would probably want to include some logic to only show elipses if the value goes beyond 10 characters. Also, when using that functionality it is typically done only at word breaks - otherwise you might have some unintended consequences: <?php $text = "I need an association between point A and point B"; echo substr($str, 0, 13) . '...'; //Output "I need an ass..." ?> To do this properly you would need to decide that if 10 characters (or whatever you use) will break a word, do you want to take one less word or one more word. This code will take the last word that meets or exceeds the length given <?php function partialString($input, $length) { $words = explode(' ', $input); $output = ''; while ((strlen($output)+1)<=$length && count($words)>0) { $output .= array_shift($words) . ' '; } $output = trim($output); $elpise = (strlen($output)<strlen($input))?' ...':''; return $output . $elpise; } $str = 'hello my name is danny and i love football'; echo partialString($str, 10); //Output "hello my name ..." ?>
  10. Check the max upload size in the php.ini file. That sets the real max file upload size. The restriction you are putting in your script is only cosmetic.
  11. You would want two tables - one for the link types and another for the actual links. Here are examples of two possible tables (I am only showing the most basic informationneeded here): link_types: id | name 1 Construction 3 Fast Food links: id | type_id | Name 12 1 Contractor Jim 13 3 McDonalds 14 1 Bob's Electrical 15 3 Burger King 16 3 Wendy's Now, if you wanted to creats links for each type just do a query such as: SELECT link_typesname, COUNT(links.name) as count FROM link_types JOIN links ON link_types.id = links.type_id You can then loop through the results to create a link to the "overview" page for each link type and include the number of items included.
  12. You are not understanding what the JOIN does in this instance. With a LEFT JOIN ALL records from the first table are returned even when there is no matching records in the second table. In the instances where there are no matching records from the second table the values that would be pulled from that table are returned as NULL. Did you even try running the code I posted? I created a quick test and it works exactly how you say you want it to - all records from the first table are returned and if the record exists in the second table the usesrID field has a value. If it doesn't exist then userID is NULL. Using that knowledge the value of $checked is set appropriately. In my test I did need to do a GROUP by on the first table because I had duplicate entries in teh second table. But, as I said, I don't know enough about your table structure to give a full solution. But, the logic I gave above will work as you need, it just needs to be modified to fit your table structure.
  13. In the background as in without the user's input? Hmm, I would consider any automatic downloading of content to my computer to be a malicious activity. You might want to look into imbedding the font into the HTML page. Not sure what browsers support it though. http://www.microsoft.com/typography/web/embedding/weft/
  14. There is a problem in the logic. For the first checkbox it iterrates through all of the results from the second query. Then for subsequent checkboxes there are no more results to extract from row 2. You are better off doing a single query. I made some assumptions on field names since I don't know your table designs. <form method="post" name="frmRegister" id="frmRegister"> <table width="500" align="left" cellspacing = "7"> <?php $sql = "SELECT horsecat.category, horsecat.horseCatID, lookuphorsecat.userID FROM horsecat LEFT JOIN lookuphorsecat ON horsecat.id = lookuphorsecat.catID WHERE lookuphorsecat.userID = '$dbOutput'"; $result = mysql_query($sql); while ($fields = mysql_fetch_assoc($result)) { extract($fields); $checked = ($userID)?'checked="true" ':''; echo " <tr>\n"; echo " <td><p class=\"text3\">".str_replace(" ", " ", $category)."</p></td>\n"; echo " <td><input type=\"checkbox\" name=\"categories[]\" value=\"$horseCatID\" $checked\></td>\n"; echo " </tr>\n"; } // end while ?>
  15. Hmm, your code was processed by the foum - include it in [ c o d e ] tags.
  16. You can't add hyperlinks to that code - you need to use preg_replace with the appropriate regualr expressions - which I already provided. This doesn't need to be difficult, just use the code I provided. I have added comments to the code so you can see what is supported. <?php //bbcode $patterns = array( //BB Code "/\[([bisu]|marquee)\](.*?)\[\/\\1\]/i", //Handles bold, italic, strikethrough & underline "/\[url\](.*?)\[\/url\]/i", //Handles URLs w/o link description "/\[url=(.*?)\](.*?)\[\/url\]/i", //Handles URLs w/ link description "/\[img\](.*?)\[\/img\]/i", //handles images "/\[quote\](.*?)\[\/quote\]/i", //handles quote blocks "/\[code\](.*?)\[\/code\]/i", //Handles code blocks "/\[(size|color)=(.*?)\](.*?)\[\/\\1\]/i", //Handles font sizing "/\[br\]/i", //Handles line breaks $replacements = array( //BB Code "<\\1>\\2</\\1>", //Handles bold, italic, strikethrough & underline "<a href=\"\\1\">\\1</a>", //Handles URLs w/o link description "<a href=\"\\1\" target=\"_blank\">\\2</a>", //Handles URLs w/ link description "<img border=\"0\" src=\"\\1\">", //handles images "<div><b>Quote:</b> <i>\\1</i></div>", //handles quote blocks "<b>Code:</b><div style=\"line-height:12px; width:99%; white-space:nowrap; overflow:auto; max-height:25em;\">\\1</div>", //Handles code blocks "<font \\1=\"\\2\">\\3</font>", //Handles font sizing "<br />", //Handles line breaks ); $string = "this string has [b]bold text[/b] in it"; $result = preg_replace($patterns,$replacements,$string); echo $result; ?> For the lists you need to show how you want the user to enter the tags. Like this [list]Item 1 Item 2 Item 3[/list] Or this [list] [*]Item 1 [*]Item 2 [*]Item 3[/list] Or what???
  17. Well, as I already stated, the only reason this has gone on so long is that you never properly stated what you needed. Not stating that you were trying to encrypt links to an external source was a big oversight. You might be able to do that with images by reading the content of the image and writing that to the page. But, I can't think of any way to do that with a youtube video. And, jsut for the record the TOS stated that you could not modify "any part of the website". I would consider the URLs to be included in that. It may not be a violation of the letter of the requirement, but I'd consider it a violoation of the intent. Besides, this is all pretty pointless with YouTube videos since clicking on the video while it's playing will open up YouTube to that contents page. Doh!
  18. Did you look at the code I provided? It already has support for links. As for Lists, how do you want it to work? Do you want the user to specify each list item or do you want to interpret a link break as a new list item?
  19. var titlePattern = "<a class=\"newstopic\" title=\"click here\" class=topic href=\"index.php?showtopic=(\d?)\">(([^<]|.)+?)</div>" ; Did you know you are missing the quotes around the class parameter value?
  20. One class or five - either will work. Personally I would go with separate classes and select the appropriate class based upon a config value. I just wouldn't be confident that there is a one-size-fits-all solution for each type of database.
  21. From YouTube's TOS Modifying the URL to a YouTube video would violate this TOS. It looks to me like you are trying to display content on your website that you did not create and are not even giving proper credit to those who did. Sounds like plagiarism to me.
  22. What image? You asked how to transform BBCode bold tags into HTML Bold tags - so that is what paul2436 provided. I made the assumption that you may need more than just the ability to handle bold tags, so I gave you a comprehensive solution - that also includes images. However, I made an assumption. If you need more than bold functionality you need to state that.
  23. Well, if your application uses a different database, don't you have to change ALL the functionality that deals with the database? In other words, wouldn't you also need to change the INSERTs, UPDATEs, and SELECTs as well? I would suggest that you create (or use available) classes for all database operations. Use a different class for each database type you want to use. Then in each one include a function to properly escape the code using the correct function for that database type. So the mysql class will include mysql_real_escape_string(), while the other classes would use different functions. But the method of calling that function will be the same for each class - so your base code does not need to be modified for the database you are using.
  24. Well, this is obviously an assignment, so I will not give you the solution. But, your array is incorrect to begin with. It states that "This should take the form of an associative array with genres as keys " Your example above has no defined keys for the topmost array elements - you simply created sub-arrays which will have the indexes 0, 1, 2, etc. The array should look more like this: $films = array ( 'Horror' => array ('film1', 'film2', 'film3'), 'Drama' => array ('film1', 'film2', 'film3'), 'Action' => array ('film1', 'film2', 'film3') );
  25. Here is some code that converts many different BBCode tags. Take out whatever you don't want to use: <?php //bbcode $patterns = array( //BB Code "/\[([bisu]|marquee)\](.*?)\[\/\\1\]/i", "/\[url\](.*?)\[\/url\]/i", "/\[url=(.*?)\](.*?)\[\/url\]/i", "/\[img\](.*?)\[\/img\]/i", "/\[quote\](.*?)\[\/quote\]/i", "/\[code\](.*?)\[\/code\]/i", "/\[(size|color)=(.*?)\](.*?)\[\/\\1\]/i", "/\[marquee\](.*?)\[\/marquee\]/i", "/\[br\]/i", //Emoticons "/\:\)/", "/\:\(/", "/\:O/", "/\:P/", "/\:\|/", "/\:D/", "/\:\?/", "/\;\)/"); $replacements = array( //BB Code "<\\1>\\2</\\1>", "<a href=\"\\1\">\\1</a>", "<a href=\"\\1\" target=\"_blank\">\\2</a>", "<img border=\"0\" src=\"\\1\">", "<div><b>Quote:</b> <i>\\1</i></div>", "<b>Code:</b><div style=\"line-height:12px; width:99%; white-space:nowrap; overflow:auto; max-height:25em;\">\\1</div>", "<font \\1=\"\\2\">\\3</font>", "<br />", //Emoticons "<img src=\"smilies/happy.gif\" border=\"0\">", "<img src=\"smilies/angry.gif\" border=\"0\">", "<img src=\"smilies/omg.gif\" border=\"0\">", "<img src=\"smilies/tounge.gif\" border=\"0\">", "<img src=\"smilies/dry.gif\" border=\"0\">", "<img src=\"smilies/biggrin.gif\" border=\"0\">", "<img src=\"smilies/confused.gif\" border=\"0\">", "<img src=\"smilies/wink.gif\" border=\"0\">" ); $string = "this string has [b]bold text[/b] in it"; $result = preg_replace($patterns,$replacements,$string); echo $result; ?>
×
×
  • 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.