Jump to content

ToonMariner

Members
  • Posts

    3,342
  • Joined

  • Last visited

Everything posted by ToonMariner

  1. I always use the latter version - I'm sure someone will state otherwise but have encountered problems with the other versions in the past. PLUS If you format your queries in that matter your code is more readable..
  2. You should NEVER store usernames / passwords in cookies - they can easily be spied upon!!!!!!
  3. Grab your percentages for your 2 crims... then calculate the relative chance by what portion of their overall chance they possess. Pass the 2 users chances to the 'best_crim' function and then see how won by generating a random number between 0 and 1 and comparing to the LARGEST relative power - if its great then the less likely crim wins!!! <?php function best_crim($crim1per, $crim2per) { $crimpower['crim1'] = $crim1per/($crim1per + $crim2per); / relative power of crim 1. $crimpower['crim2'] = 1 - $crimpower['crim1']; // relative power of crim 2. $perpetrator = do_battle($crimpower); return $perpetrator; } function do_battle($crimpower) { $prob = rand(0,1); // gen random criminality factor. if ($prob > max($crimpower)) { // probability is higher than most powerful crims relative share - they lose. $winner = array_keys($crimpower, min($crimpower)); } else { // probability is less than or equal than most powerful crims relative share they win. $winner = array_keys($crimpower, max($crimpower)); } return $winner[0]; } // some query to grab crim power of crims .... $crim1 = 0.23; //$crim1 = 23% $crim1 = 0.17; //$crim1 = 17% $the_crim = best_crim($crim1, $crim2); echo 'Perpetrator is ' . $the_crim; // add or remove % accordingly. ?> You could take the call to do_battle out of best_crim if you need to calculate that kind of thing else where but this should fit your current requirement.
  4. have a look for something like mencoder (believe its the replacement for ffmpeg).
  5. yes - its a super global - like $_POST, $_GET, $_COOKIE, $_SERVER, $_SESSION - all super globals and are available ANYWHERE within your code.
  6. yes but you don't have to. $_FILES has global scope so its available anywhere within your code.
  7. you have a couple of possibilities. in css.... .mytext, .someclass { color:#ff0000; } .someclass { text-align:center; background-color:#000000; } or kind of using your original code... (note the color: .mytext WILL fail so don't use it) .mytext { color:#ff0000; } .someclass { text-align:center; background-color:#000000; } <p class="someclass mytext"> ... </p>
  8. if you want to hide the fact that you are using one style sheet for each of these sites you can use a mod_rewrite in a .htaccess file to redirect any request for a css file to another url. Options +FollowSymlinks RewriteEngine On RewriteRule \.css$ http://www.mastersite.com/style.css [NC,L] (May or may not work depending on whether there are controls on where mod_rewrite can redirect to.) alternatively you could simply give the full url of your style sheet(s) in the href of your link tag. <link rel="stylesheet" type="text/css" href="http://www.yoursite.com/style.css" />
  9. ToonMariner

    centre Div

    remove the left and right properties (and remember expression is only understood by IE). just use margin: 0 auto;
  10. http://www.alistapart.com/articles/succeed/
  11. no - don't use a frame. using a frame won't look any better than if you build it and style it properly.
  12. http://css-discuss.incutio.com/?page=BoxModelHack the reason this is happening is because you have not used a doc type declaration that pushes ie6 into standards 'compliant' mode...
  13. without it ie works in quirks mode - with a good dtd ie works in standards 'compliant' mode
  14. you don't know how long it is since I've formulated a query!!! (about 2 months now!) Thanks buddy - needed the refresher A LOT!
  15. you should NOT be ourring this kind of information in a textarea its tabular data and should be in a table... you could use some ajax o update the table and add new content to teh top of it so that the latest infor is most prominant.
  16. there is nothing wrong with putting a margin on the body. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb"> <head> <title>Starbuzz Coffee</title> <style type="text/css"> body { background-color: #d2b48c; margin: 20px 20%; border: 1px dotted #999; padding: 10px 10px 10px 10px; font-family: sans-serif; } </style> </head> <body> <h1>Starbuzz Coffee Beverages</h1> <h2>House Blend, $1.49</h2> <p>A smooth, mild blend of coffees from Mexico, Bolivia and Guatemala.</p> <h2>Mocha Cafe Latte, $2.35</h2> <p>Espresso, steamed mil and chocolate syrup.</p> <h2>Cappuccino, $1.89</h2> <p>A mixture of espresso, steamed milk and foam.</p> <h2>Chai Tea, $1.85</h2> <p>A spicy drink made with black tea, spices, milk and honey.</p> </body> </html> try that - the doc type is why you are not seeing the results in internet exploder...
  17. Hi everyone, Having a spot of bother with a join query... I have 3 tables media, user and media votes and one of the parameters i need to return is the number of votes an item in teh media table has - this is determined by the number of records in teh media_vote table. I have the following query... SELECT `media`.* , `user`.`username` , DATEDIFF(NOW(), `media`.`added`) AS `period` , IF (`media`.`rating` > 0, COUNT(`media_votes`.`vote_id`), 0) AS `vote_no` FROM `media` , `user` , `media_votes` WHERE `media`.`flag` != 'm' AND `user`.`user_id` = `media`.`user_id` AND `media`.`categories` NOT IN (21, 40) AND `user`.`active` = 'y' AND `media_votes`.`media_id` = `media`.`media_id` GROUP BY `media_votes`.`media_id` ORDER BY `media`.`added` DESC all is dandy EXCEPT when teh item has no votes in the media_vote table. IF (`media`.`rating` > 0, COUNT(`media_votes`.`vote_id`), 0) AS `vote_no` was my feeble attempt to get round this but its clearly the `media_votes`.`media_id` = `media`.`media_id` portion which is giving me the headache and I just can't think how to get round it. Any help would be very much appreciated...
  18. IE6 (as always) is the one that really struggles with the z-index stacking order. Firstly to require a stacking order on these elements I am assuming they are positioned relatively or absolutely? After that is just a case of setting the z-index to get what you want from good browsers and then a bit of suck-it-and-see with an ie6 style sheet only.
  19. close the body tag just prior to teh closing html tag </body> </html>
  20. Avoid divitis and NEVER USE AN ID MORE THAN ONCE ON A PAGE!!! use SEMANTIC markup keep your presentational code in a style sheet (don't use align="center") you code could be re-written like so <div id="datadisplay"> <h1>{OVERALL_HEADER}</h1> <h2>Tasks by categories</h2> <div id="cattext">{LOOP: CATS} <td><a href="{SITE_URL}projects.php?cat={CATS.id}">{CATS.title}</a></td> IF("{CATS.counter}"%"3"){ <tr>{:IF} {/LOOP: CATS} </tr> </div> <p>BLAHHHH</p> <p>BLAHHHH</p> </div> The one part where I fall over is the table rows and table cells but no table. Is this tabular data or not? if it is use a table - if not get rid of the tr and td. Hopefully though you will see that if you stick to correct mark up and don't go mad with classes and ids, and when you do use them you use a sensible name you can create a well structured document that is both easy to build and easy to maintain. DON'T GET BOGGED DOWN WITH CRAP - KISS (Keep It Simple Stupid - not calling anyone stupid its just what the thing stands for!).
  21. the real question is WHY do you need to wrap a table in a tag??? or even WHY are you using a table???
  22. http://code.google.com/p/swfobject/wiki/documentation My advice would be to use the static publishing solution - you can even ignore the javascript itself and just use the mark up in step 1.
  23. not sure the session is actually that useful here - to record ALL data you will need to log it on every page load. This would mean writing a snippet that is included in every page that opens a file (maybe a file per user so you don't get any problems with locks) and logs the data required on a new line. Client side is pointless as you won't have access to the data... If your requirement is a little less strict then perhaps you could collect data in a session array and dump it say every time the array hits 5 records - may help a little on performance but lets be honest its not going to make a massive difference.
  24. what I was alluding to is that if (navigator.appName.indexOf("Microsoft")!= -1) { document.floater.style.position="absolute"; document.floater.style.zIndex="10"; document.floater.style.left="0px"; document.floater.style.top="20%"; }else{ document.getElementById('floater').style.position="absolute"; document.getElementById('floater').style.zIndex="10"; document.getElementById('floater').style.left="0px"; document.getElementById('floater').style.top="20px"; } need only be document.getElementById('floater').style.position="absolute"; document.getElementById('floater').style.zIndex="10"; document.getElementById('floater').style.left="0px"; document.getElementById('floater').style.top="20%";
×
×
  • 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.