Jump to content

Cetanu

Members
  • Posts

    395
  • Joined

  • Last visited

    Never

Everything posted by Cetanu

  1. Hi! I'm currently developing a photography portfolio for a friend. To display his images, rather than using a database and allowing it to get massive, I've decided to go ahead and stick them into a directory and then cycle through it. As it's currently set up, I open the directory and read it, use preg_split() to divide the files up according to file type, and then use a foreach() statement to display them. It works like a charm. But now I have a problem: I want to limit the amount of files that are echoed out. I've tried everything. Using this: $i = 0; foreach($images as $image){ // blahblahblah $i++ if($i > 10){ break; } } And that doesn't work. :| And I also decided to try and count() the array and stuff. Nothing worked. Furthermore, print_r() returns this: Array ( [0] => [1] => a_message.jpg [2] => ) Array ( [0] => [1] => cold_call.jpg [2] => ) Array ( [0] => [1] => ring_of_love.jpg [2] => ) Array ( [0] => thumbs ) Array ( [0] => [1] => unclear.jpg [2] => ) Isn't it supposed to return ONE array with different keys?! >.> Here is the code: $img_dir = "images/photographs/"; if(is_dir($img_dir)){ if($img_handle = opendir($img_dir)){ echo "<div id=\"index_thumbnails\"><div id=\"hidden_images\">"; while(($img = readdir($img_handle)) !== false){ if($img !== "Thumbs.db" && $img !== "." && $img !== ".."){ $images = preg_split('/([a-zA-Z0-9_-]*\.jpg$)/', $img, 0, PREG_SPLIT_DELIM_CAPTURE); if(empty($images)){ echo "<b>Sorry, there are no images to display!</b>"; } else{ foreach($images as $img_display){ if($img_display !== "" && $img_display !== "thumbs"){ $img_name = "images/photographs/{$img_display}"; $thumb_path = "images/photographs/thumbs/"; $size = getimagesize($img_name); $width = $size['0']; $height = $size['1']; $nwidth = round($width/20); $nheight = round($height/20); $img_thumb = imagecreatefromjpeg("{$img_name}"); $resized = imagecreatetruecolor($nwidth, $nheight); imagecopyresampled($resized, $img_thumb, 0, 0, 0, 0, $nwidth, $nheight, $width, $height); imagejpeg($resized, "{$thumb_path}{$img}_thumb.jpg"); echo "<img src=\"{$thumb_path}{$img}_thumb.jpg\" height=\"{$nheight}\" width=\"{$nwidth}\"/>"; } } } print_r($images); } } closedir($img_handle); echo "</div></div>"; } } Bear with the fact that I'm not using a function to shrink my images. xD I'm getting all of the work out of the way before I make a function and link it to a database to get image information. All help is appreciated! Thank you!
  2. Oh, because I wasn't matching classes, I was matching the content of the <li> to the name of a class. I.e., <li>Bio</li> matches class="bio".
  3. Okay, so. $('#head li').mouseenter(function(){ var name = $(this).html(); $('#bubble.'+name+'').show(); }); $('#head li').mouseout(function(){ $('#bubble').hide(); }); I'm trying to make the element whose class MATCHES the <li> class appear when the <li> is moused over. In that code, NAME is the variable that stores the information that matches up to the class... ...but I can't make the element appear! I know the variable is correct, so why doesn't the #bubble whose class = <li>'s information appear? Thanks.
  4. Okay, thanks...I think I got it.
  5. Could you help me along with this? I've not used JS for the column... I didn't know I could.
  6. I wanted to set the height of a <div> equal to 100% of the entire page, NOT the viewport. I want the container to extend all the way down. Basically, the page is set up in a two column format. The column on the left has a BG color and the one on the right doesn't. If the right's content goes farther than the view, the left column doesn't follow. Here is a link that I've hosted on file sharing. It isn't live or anything... http://dl.dropbox.com/u/3666815/portfolio/test.html Thanks in advance!! CSS: *{ margin:0; padding:0; } html, body{ min-height:100%; } body{ background: #fcfef5 url("images/bg/rightBG.png") no-repeat; background-position:top right; word-spacing: .1em; color: #555; width:100%; font-family: georgia, garamond, times new roman; } /* Text */ #right_text p { font-size:12px; width:70%; z-index:0; position:relative; margin:auto; text-indent:15px; margin-top:5px; } /* end TEXT */ /* Links */ a img{ border:none; } #links a{ color:#999; text-decoration:none; } #links a:visited{ color:#555; } #links a:hover{ color:#889d46; } #links a:active{ color:#000; } /* end LINKS */ /* Containers */ #left_Area{ background: #d8dec3 url("images/BG/leftBG.png") no-repeat; background-position: top right; float:left; width:50%; min-height:100%; } #header{ width:100%; padding-top:237px; } #links{ width:100%; text-align:right; margin-right:10px; } #right_text{ float:left; position:relative; z-index:0; width:45%; padding-top:250px; } #introBox{ width:10px; margin-top:200px; display:block; opacity:.1; height:10px; background: #d8dec3 ; } /* Inner Containers */ #treeBG{ width:100%; height:235px; background: url("images/bg/treeBG.png") no-repeat; background-position:bottom left; } #mainLinks{ width:80%; margin:auto; padding:15px; } /* end INNER CONTAINERS */ /* Links List */ #links ul{ list-style:none; padding:10px; } #links li{ padding:10px; background: #d8dec3; margin:5px; -moz-border-radius: 10px; z-index:1; position:relative; color: #889d46; font-family:tahoma ms, verdana; font-size:13px; } /* end LINKS LEST */ /* Images */ .mainHeader{ margin:10px; } #mainImg{ margin: 10px 20px; } /* Classes */ .clear{ clear:both; } HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!-- Website coded By ZACH! --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Zach W Portfolio - Grade 10 Section</title> <link rel="stylesheet" href="styleFF.css" type="text/css"/> <script> function roll_over(img_name, img_src) { document[img_name].src = img_src; } </script> <script src="jquery/doc.js" type="text/javascript"></script> <script> $(document).ready(function(){ $('li').mouseenter(function(){ $(this).animate({ width:'135%', opacity:'.92' }, 'slow' ); }); $('li').mouseleave(function(){ $(this).animate({ width:'96%' }, 'fast' ); }); $('a').click(function(){ $('body').fadeOut(); }); }); </script> </head> <body> <div id="left_Area"> <div id="header"></div> <div id="links"> <ul> <li><a href="index.php">BACK TO <br/> DIRECTORY </a> </li> <li><a href="">Goals</a></li> <li> Skills Analysis </li> </ul> </div> <div id="treeBG"></div> </div> <div id="right_text"> <p> I came to TVHS on February 2nd, 2009, and I absolutely love the school. I approach the end of the first half of my high school career, and this portfolio will display some work that I’ve done in my four months at Tech Valley High. The portfolio will also be an exhibit for my possible future, and a medium for me to display my skills. </p> <p>Well, I’ve grown up in New York State, though this hasn’t inhibited me from experiencing the culture of other parts of the world and the country. My Mom, brother, and I all live together; my Dad lives a mere 30 minutes from my house. At this point, I’ve taken four years of Spanish, four months of (unofficial) Chinese, and I can speak little bits of a whole bunch of other languages (including English). I love to draw, and since I was little I’ve loved to read and write as well. It’s my goal to learn how to use the English language properly (as convoluted as it is). I don’t have any idea what I want to do when I grow up. Currently, I work at the Rensselaerville Library and I take traditional Okinawan Karate. Among my other interests are: tennis, wildlife, Eastern philosophy, and web design. </p> <p>There are probably more things than I realize that have shaped who I am now, but I can recall a few. My exposure to horror movies at a young age definitely drove me to draw and write because I seek to release a lot of creativity when I do those things…I assume that the horror movies are fueling my imagination. Another thing would be my grandmother (matrilineal) who literally had a library of books and a wealth of knowledge. Being exposed to knowledge as a child has proved to perpetually fuel my desire for knowing things now. I can’t recall anything else, except my constant exposure to the world and knowledge. </p> <p> As I continue through high school I develop more and more goals. I’m happy to say that being at TVHS has allowed me to prepare adequately for the working place. One goal that I have now is to learn to speak and write Chinese fluently! I wouldn’t have this goal if I hadn’t been exposed to Chinese here. I also want to travel all over the world to see ancient sites and artifacts before they are destroyed by the escapades of humans. That goal wasn’t influenced by the school I’ve had it for awhile. I have no idea what college I want to go to, but I know that I want to go. I might want to be an artist—maybe an author – maybe a webmaster…I won’t know for a little bit. </p> <p> I think my definite skills are tech literacy, self-direction, and critical thinking. I’ve been able to create websites and pictures for the yearbook; almost all of my homework has been done on time, save for a few instances and my self-direction grade is my highest grade. In this portfolio, you’ll see a drawing I did for the yearbook and many projects that I’ve done over the year, all of which will accentuate my skills. </p> </div> <div id="clear"></div> </body> </html>
  7. I've checked that code outside of my file, and it worked. Inside of my file, it does not and I don't know why. if(!empty($_POST['submit'])){ connect($db="government"); preg_replace('#\{{1,1}(.*?)\}{1,1}#',"<$1>", $message); echo $message; echo "<script>alert('Success!'); location='editCont.php?page=editNews';</script>"; }
  8. This is a function similar to BBCode. I would like something like "{u}Hello{/u}" to be changed into <u>Hello</u>. The code snippet I showed is just for left bracket, but I assumed I could go from there after learning what I'm doing wrong.
  9. I have a simple (?) preg_replace statement that I would like to replace a { with a <, but I keep getting it wrong and right now RegEx really confuses me, so help is appreciated. preg_replace("/(\{.*)/", "<", $message); Thanks in advance.
  10. Cool! That's helpful, thanks.
  11. I meant the blinky caret that marks where the text is written (that's what it's called in several forum topics I've found).
  12. Edit, I'm searching the forums...but additional help is welcome.
  13. So, I am working on this very small editing feature that I would like to behave like forums' BBCode insert things. I have searched high and low for a tutorial or something of the sort to detect where a caret is and then insert my code there.... ...I really want it to be slim, and it should work with a textarea. Any help? Thanks!!!
  14. Yay! Thanks. Now, what is the difference between "author" and "user" style sheets? I may know what they are, just by a different title.
  15. #myGallery { width: 560px !important; height: 240px !important; } What does the exclamation do?!?!?!? It looks like a comment, but I totally don't understand. Even more, W3C validator says it works, so it must be right >.> Thanks!
  16. It kills a baby and a kitten each time you use it. :happy-03: :happy-03: I hate cats. xD Thanks guys.
  17. I do have one question: what does "global" do?
  18. Thanks guys, this makes it a little clearer for me. I'm going to take both of your suggestions and play around with my code. I'll get back to you to let you know the results. EDIT: It works, and I understand functions more...thanks a bunch!!
  19. So, I've been reading up on Functions and I like them! However, I need some help using variables in functions, since it's kind of confusing. I just made these functions: <?php function Protect($var){ $var = mysql_real_escape_string(htmlentities(stripslashes($var))); } function Preserve($var){ $content = nl2br(str_replace(" ", " ", $var)); } ?> Neither of them work. Dunno why. From what I understand... If I do this: function HelloThere($var){ Then when I use the function I can go... HelloThere($hello); And the $hello variable will be substituted for $var from when I defined the function. Am I not right, confusing, or misled? Please help!!! Thanks. PS I originally had this, but it didn't work: <?php function Protect($var){ $variable = $var; $protect1 = mysql_real_escape_string($variable); $protect2 = htmlentities($protect1); $protect3 = stripslashes($protect2); } function Preserve($var){ $content = nl2br(str_replace(" ", " ", $var)); } ?>
  20. Any ideas? (AKA bump xD )
  21. No errors appeared, but the max_health, health, attack, defense, stealth, etc. have not been inserted into... This executes. if($species == "Predator" || $species == "Alien" || $species == "Marine" && !empty($_POST['name'])) { mysql_query("INSERT INTO `rpg` (`name`, `species`, `player`) VALUES ('{$_POST['name']}', '{$_POST['Species']}', '{$_POST['player']}')") OR die(mysql_error()); } These do not... elseif($species == "Predator") { mysql_query("UPDATE `rpg` SET `max_health` = 25, `health` = 25, `attack` = 25, `defense` = 25, `honor` = 20 WHERE `player` = '{$_POST['player']}')") OR die(mysql_error()); } elseif($species == "Alien") { mysql_query("UPDATE `rpg` SET `health` = 20, `max_health` = 20, `attack` = 20 , `defense` = 20, `stealth` = 20 WHERE `player` = '{$_POST['player']}')") OR die(mysql_error()); } elseif($species == "Marine") { mysql_query("UPDATE `rpg` SET `health` = 15, `max_health` = 15, `attack` = 20, `defense` = 20, `melee` = 20 WHERE `player` = '{$_POST['player']}')") OR die(mysql_error()); }
  22. Unfortunately, it didn't work. :'( But, thanks for trying. Anyone else have ideas?
  23. My PHP code will only execute the first part of my code... <?php session_start(); ?> <html> <head> <title> Create a Character</title> <style type="text/css"> body{ background-color: #000; font-family: Arial, Tahoma; font-size: .78em; } fieldset{ padding: 10px; margin: 10px; border: 1px solid #57626B; width: 70%; float: left; } legend{ background-color: #6A8CA5; border: 1px solid #000; padding: 5px; } input{ font-style: italic; -moz-border-radius: 5px; -webkit-border-radius: 5px; } #tester{ background-color: #333; margin: 0 auto; padding: 10px; width: 70%; height: 80%; } #stats{ float: left; width: 25%; font-style: italic; color: #000; padding: 5px; border: 1px dashed #999; } </style> </head> <body> <div id="tester"> <?php //Creation script designed by Cetanu of http://mythscape.freezoka.com and http://tehfreerpg.proboards.com //This script is licensed by the Creative Commons for: Sharing, Attribution, Non-derivative, and non-commercial. //You MUST leave these notices in for LEGAL use of this script. YOU MAY NOT EDIT THIS SCRIPT LEGALLY. //For more: http://creativecommons.org/licenses/by-nc-nd/3.0/us/ if(empty($_SESSION['user_id'])){ die("<strong>You are not logged in. Please do so to access the RPG Sector.</strong>"); } if(empty($_POST['cont'])){ echo " Time to create your character!<br/> <form action='create.php' method='post'> <fieldset> <legend>Create Character for <strong>".$_SESSION['user_id']."</strong></i></u></legend> <p>Please choose a species.</p> <input type='radio' name='Species' id='pred' value='Predator'/>Predator (Yautja)<br/> <input type='radio' name='Species' id='alien' value='Alien'/>Alien (Xenomorph)<br/> <input type='radio' name='Species' id='human' value='Marine'/>Marine<br/> <br/> <label for='name'>Character Name</label> <input type='text' maxlength='25' id='name' name='name'/><br/> <input type='hidden' maxlength='30' value='{$_SESSION['user_id']}' id='player' name='player' readonly='readonly'/><br/> <input type='submit' name='cont' id='cont' value='Continue On'/> </fieldset> </form>"; } echo "<br/>"; if(!empty($_POST['cont'])){ $species = $_POST['species']; include "db.php"; if(empty($_POST['name']) || empty($_POST['Species'])){ echo "<script>document.write('You must input a species and a name!'); setTimeout(\"window.location.reload()\", 350);</script>"; } if ($species== "Predator" || "Alien" || "Marine" && !empty($_POST['name'])){ mysql_query("INSERT INTO rpg (name, species, player) VALUES ('{$_POST['name']}' , '{$_POST['Species']}' , '{$_POST['player']}')") or die(mysql_error()); } elseif($species=="Predator"){ mysql_query("UPDATE rpg SET max_health=25, health=25, attack=25, defense=25, honor=20 WHERE player='{$_POST['player']}')"); } elseif($species=="Alien"){ mysql_query("UPDATE rpg SET health=20, max_health=20, attack=20 , defense=20 , stealth=20 WHERE player='{$_POST['player']}"); } elseif($species=="Marine"){ mysql_query("UPDATE rpg SET health=15, max_health=15 , attack=20 , defense=20 , melee=20 WHERE player='{$_POST['player']}"); } else{ echo "Invalid Species. Try again!"; } mysql_query("INSERT INTO bank (player , amount) VALUES('{$_SESSION['user_id']}' , 5)"); header('Location: statadd.php'); } ?> </div> </body> </html> The part starts here...When it gets to the three elseif statements, they are the only things that won't execute. Everything else works. I don't get errors. <?php if(!empty($_POST['cont'])){ $species = $_POST['species']; include "db.php"; if(empty($_POST['name']) || empty($_POST['Species'])){ echo "<script>document.write('You must input a species and a name!'); setTimeout(\"window.location.reload()\", 350);</script>"; } if ($species== "Predator" || "Alien" || "Marine" && !empty($_POST['name'])){ mysql_query("INSERT INTO rpg (name, species, player) VALUES ('{$_POST['name']}' , '{$_POST['Species']}' , '{$_POST['player']}')") or die(mysql_error()); } elseif($species=="Predator"){ mysql_query("UPDATE rpg SET max_health=25, health=25, attack=25, defense=25, honor=20 WHERE player='{$_POST['player']}')"); } elseif($species=="Alien"){ mysql_query("UPDATE rpg SET health=20, max_health=20, attack=20 , defense=20 , stealth=20 WHERE player='{$_POST['player']}"); } elseif($species=="Marine"){ mysql_query("UPDATE rpg SET health=15, max_health=15 , attack=20 , defense=20 , melee=20 WHERE player='{$_POST['player']}"); } else{ echo "Invalid Species. Try again!"; } mysql_query("INSERT INTO bank (player , amount) VALUES('{$_SESSION['user_id']}' , 5)"); header('Location: statadd.php'); } ?>
  24. Okay, I'll go look into some AJAX. Thanks.
×
×
  • 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.