Jump to content

oha055

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.ohauge.net

Profile Information

  • Gender
    Male
  • Location
    Norway

oha055's Achievements

Member

Member (2/5)

0

Reputation

  1. Nevermind! got it working! if(count($array) > 0)
  2. Hi! I have got an array which contains messages for different types of errors on my website (for login errors and such). My problem is however, that when the array is empty it still shows the message box (the CSS). here is the code I am using: public function showMessages() { if (count($this->_messages > 0)) { echo '<div id="messages">'; foreach ($this->_messages as $msg) { echo $msg . '<br />'; } echo '</div>'; } } I am starting to think that I need to be doing this in JavaScript. I would prefer to do it using PHP only, if it is possible though. Thanks for the help!
  3. Got it working! This is the code. I am new to PHP so feel free to comment if there are other, better ways of doing this private function showBlog() { $imageId = count($this->_filenames) - 1; if (isset($_GET['id'])) { $imageId = $_GET['id']; } ?> <center><img src="images/gallery/<?php echo $this->_filenames[$imageId]; ?>" /></center> <div id="navigation"> <div id="prev"> <a href="?id=<?php echo $imageId - 1; ?>">prev</a> </div> <div id="next"> <a href="?id=<?php echo $imageId + 1; ?>">next</a> </div> </div> <?php }
  4. Hi! I am currently making a really simple photo blog. The query fetches every reference to the images which are stored on the server. I have a problem when it comes to dynamically cycling through these though. After running the query, I store each image reference in a twodimensional array like this: [["id"], ["date"], ["title"], ["filename"]] (an Array of Arrays). The image displays just fine by doing this: $pointer; //starting from the last element (image) in the array <img src="images/gallery/<?php echo $images[3][$pointer] ?>" alt="<?php echo $images[2][$pointer] ?>"> The problem is that, when I update the pointer, say for instance pointer++, the current image on the screen doesnt update. I know for a fact that the pointer updates, because I have echoed it. The basic idea is to have a previous and next link just under the image, so that the viewer can cycle the available images. Any help is greatly appreciated
  5. Thank you for the quick reply. I'll just stick to headers then
  6. Hi! So I know that when redirecting to administrator pages after login is very often done like this: header(location:admin.php); But what if I didnt want to use header? I'm asking because I would just like to include the admin section within the part of the website I'm currently residing, if that makes any sense. Also, I think using headers is a bit cumbersome. I have just recently started learning PHP, so please excuse me if this is a dumb question
  7. Ok, thanks! I thought it could maybe work by only using php, but I guess not! I'll check out js then
  8. Hi! So I have got some code that looks like this: if (isset($_GET['view_log'])) { // show content (text from db) } When I click the button named "view_log" everything displays just fine, however I would like to be able to click the button again and make the content disappear. Is this possible using only PHP?? Thanks for the help! It is greatly appreciated!
  9. Thanks for the reply! ok, so any way I like. But do you think maybe this would be a bit overkill for a personal website? Also, do you know of any good books on CMS? Thanks!
  10. Hi! So I'm fairly new to PHP, and am currently making a website from scratch including as much PHP functionality as I can for learning purposes. As I have just finished making a blog function, I started to wonder. Is it normal to store every part of a website in a the database? The blog part of the website I just created has of course all the differet blog entries stored in a table in the db, but is it also normal practice to store about, contact etc. in tables too? Or should categories like these be created using brand new .php documents? I am in the progress of making a page controller and thought I should clearify things first, before I go any further. This question may seem stupid, but I don't know alot about what the normal practices of doing things like these in php are. Anyways, hope someone can help me out!
  11. Thanks to both of you! Much appreciated! I went for this solution: <?php $lines = explode('-', $text); array_shift($lines); foreach($lines as $line) { echo '*', $line, "<br />"; } ?>
  12. Hi! I have a problem when echoing some lines of an exploded string. The output of the code is: * [EMPRY LINE] * line with some writing #1 * line with some writing #2 * line with some writing #3 etc. I don't get why the first (empty) line is included.. <?php $lines = explode('-', $text); foreach($lines as $line) { echo '*', $line, "<br />"; } ?> any help is appreciated!
  13. Thank you! Btw, does anyone know of a good PHP book for learning about this topic? I'm looking at amazon.com and there are so many PHP books to choose from..
  14. Thank you! Yeah, I'm sure Google has got the answers, but I didn't know what to search for
×
×
  • 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.