Jump to content

purpleshadez

Members
  • Posts

    38
  • Joined

  • Last visited

    Never

Everything posted by purpleshadez

  1. explode is a php function that splits a string into an array using a delimiter. you can set the delimiter as a character which is unlikely to appear in your data. In the example I gave I used the colon. explode takes a string and breaks it into chunks each time the delimiter is found. It doesn't do anything with the database. the point I was getting at, albeit rather indirectly, was you are duplicating work by adding a seperate record when the only thing changing is the access list. Basically yes. With option 2, which may be the better one based on your update, you could set the required colummn to 'no' once completed to remove it from the list. Or if you require an audit, rather than ENUM have it so you could set it so you can choose something like Required/Not Required/Completed, or 1/2/3 and use the code to define the status. You can then use one record have a cleaner DB and keep track of who has access to what. To answer your original question though you could use a loop to add each entry to the DB for seperate records. You are using a check box so you would need to create an array then loop through that to add the data into the DB.
  2. There a two easier ways that I can think of off the top of my head. 1, Concatenate the data required for the "Access Needed" field e.g: $access = 'PC:Network:Parking'; Then to read you can split the data into an array with the explode function. $access = explode(':', $access_data); 2, Add a seperate field in the database for each requirement and set it as ENUM(Yes/No) Option 1 allows you to add as many different requirements as you want without amending the DB but could get messy or be inconsistent. Option 2 would require you to add a new field for each new option but will be more structured. That's my opinion at least.
  3. As thorpe has said, it needs to be defined. As far as I'm aware, there are 2 options in code igniter. 1.) If you need to use the session library throughout your application then check to ensure that it is autoloaded in application/config/autoload.php. It should be on line 42. // Option 1 $autoload['libraries'] = array('session', 'database'); 2.) If you only need it for say, a backend then place the line below in the constructor of your backend controller. // Option 2 $this->load->library('session'); Bootnote: I have just noted that you are using your own library. this page advises that you will need to use get_instance() to use the native CI resources. $CI =& get_instance(); $CI->load->library('session');
  4. IMO it depends on how well you pick up the basics as it were. Unfortunately I cannot comment on how easy you will find it to learn you could have never written a line of code in your life, or you could be a *Insert popular programming language here* guru! If the code you are reverse engineering is written in a proceedural manner then you may struggle trying to get it to work in CI, which a is more object orientated collection of classes, if you do not understand PHPs OOP model. Frameworks are designed to make writing PHP applications easier so there is no reason why you cannot look at it, have a play and see if its for you. I would personally suggest that you get familiar with the basics and then when you can read the documentation for CI and it kinda makes sense, then progress onto code igniter. Having said that you may very well decide that you don't want or need CI once you have grasped the language or even that you prefer another framework. Good luck
  5. http://www.phpclasses.org/browse/file/11220.html Try that.
  6. You don't HAVE to use the MVC design pattern but it would appear to be the most popular with existing frameworks*. There are a number of others such as the factory pattern and the singleton pattern (see here for other examples). I don't know enough about the common frameworks to comment on which is best but if a framework is the way you want to go there are a number of reviews on the most common ones so I guess it would be like anything else. You choose one that best suits your needs. Personally I use a tiered(?) approach. I use ADODB to manage database access and the actual code for the content is placed in one of two folders. Depending on if it is part of the core application or an optional addon. I then have a basic theme option that uses a single html template and a css file to manage the layout. Personally I'd say it was a 2 tier system but it works quickly, doesn't take up alot of space and whilst not perfect, it is easy to maintain and I try to keep it as loose as possible. Which I believe is the overall goal. Re-useable and adaptable code. * not researched this so it is just my perspective. Feel free to correct me on this or indeed any other points I may have got wrong.
  7. Not sure I get you. Code examples of what you've already got and/or a better idea of what you are trying to accomplish would be useful. Because it looks to me that you have an issue with how your database table is setup?!?
  8. I like the family name idea, just prefix the class & filenames and call them when needed. Not perfect, but better than my current solution. I could beat the sys admin to death with his keyboard then do the update myself.... Cheers Mchl I think I'll go with that.
  9. I am aware it doesn't do what autoload does, I was after a better method that would work in a more efficient way than the example I provided. As for why, a number of business processes prevent me from being able to upgrade to the latest version.
  10. I have been thinking about a method of simulating the __autoload() function that will work in PHP4. Currently I'm using something like this: foreach(glob($path . '*.php') as $class_name) { if( ! preg_match("/index.php/i", $class_name)) { require_once($class_name); } } As expected this will included all files with with .php extension excluding index.php from the specified file path. Now with a small set of classes I can't really see this as a problem especially if almost all of them are core classes required for the application to work. However, in time I imagine there will be more and more classes that will not be used on a regular basis such as excel exports or generating word documents that really do not need to be loaded on each and every page. Would it be better to perhaps use the above method with a folder path that only contains the core classes and then keep the others in a seperate location and manually include them when needed or is there another way to only load those that are needed?
  11. Is it possible that its a cache issue with IE? Had a similar(ish) issue with a machine at work that despite logging in to the intranet cookie was present and correct but it kept presenting the page as though no one was logged in. cleared the cache and it was okay again.
  12. I reckon you'd be better off sticking your SQL result in an array you could then use sizeof() to get the total number of pages and calculate what to show next rather than replying on an id field in the database. You can however, as someone else mentioned in another post, run an sql update query that subtracts 1 from all the id's higher than the one you've just deleted.
  13. Not being funny, but that method doesn't make much sense to me. I'd do it like this: <html> <head><title>Capitals</title></head> <body> <?php $capitals_of_countries = array("England", "France", "Russia", "Portugal", "Spain", "Sweden", "Denmark", "USA", "Canada", "Australia", "Japan", "Italy", "Mexico", "Czech Republic", "Germany", "Ireland"); $country_capital = array("London", "Paris", "Moscow", "Lisbon", "Madrid", "Stockholm", "Copenhagen", "Washington", "Montreal", "Brisbane", "Tokyo", "Rome", "Mexico City", "Prague", "Berlin", "Dublin"); if (isset($_POST['posted'])) { echo "The capital of " . $capitals_of_countries[$_POST['country']] . " is <b>" . $country_capital[$_POST['country']] . "</b><hr />"; } ?> <form action="test.php" method="POST" /> <input name="posted" type="hidden" value="true" /> What Country do you want to know the capital of? <select name="country"> <?php $tot = sizeof($capitals_of_countries); for ($counter = 0; $counter < $tot; $counter++) { echo '<option value="' . $counter . '">' . $capitals_of_countries[$counter] . '</option>'; } ?> </select><br /><br /> <input type="submit" value="Find Capital" /> </form> </body> </html>
  14. I like PSPad in Windows but use Quanta in Linux. I use to use dreamweaver but I found it became quite bloated over the years so wnet for a lightweight editor instead.
  15. well done martin , i can tell you all the fuss is about zend_framework and high tech javascript frameworks like extjs but you can build your own php oop mvc and js framework from jquery looked at the zend framework among many others and decided against them. I use a basic framework I wrote myself as I don't see the point on having a vast library full of classes I'm never going to use. Plus I know it inside out so its much easier for me to maintain. I'm not saying its better because I betting it really isn't. But it suits my needs and works as I intended it to so I suppose thats sufficent. I've never really been a fan of javascript but I do see the advantages of AJAX so its on my list of things to improve my knowledge of. I have to say though, I like some of the best practices zend use so I have adopted them in my own work.
  16. Gnome and KDE have nothing to do with Ubuntu or Mandriva. They will both work on either and/or any distro. Some distros favour one over the other but you can swap and change or have both. I tend to favour fedora but thats mainly because where I work use redhat/fedora so made sense. I am looking forward to giving unbuntu a go when I get a new laptop
  17. if you want full access you'd need to set the group to have read write execute on that folder too. chmod -R 77x /var/www (where x is the level of access you want for others)
  18. Nice tutorial and something I never considered. I use access levels on most of my projects but this is much simpler
  19. Just found this bit. It pays to look My name is Martin and I'm an addict. I'm 30 and live/work in West Yorkshire. I have only recently signed up but have visited this site/forum many times looking for info whilst going through the learning process I have about 5 years(ish) experience with php. Took an interest after spending many years building servers to run it so thought I may as well see what all the fuss is about. Don't really consider myself an expert but I know enough to get by and enjoy learning new things. I mainly joined to try help others as I find you can learn an awful lot trying to help others solve their issues and also to bounce ideas off other people who know what they are doing. I could babble on all day about random rubbish but I'll leave it there!
  20. No worries for the record, you can get some more info about this class using this link: http://code.google.com/p/php-excel-reader/wiki/Documentation
  21. I use this class a fair bit, it has some really nice touches. This is an idea of how I would do it. You could make a html form with a text box then use the variable provided for the search. You could also use a select input so you could search each colummn in the spreadsheet. Hope this helps. <html> <head> <style type="text/css"> table { border-collapse: collapse; } td { border: 1px solid black; padding: 0 0.5em; } </style> </head> <body> <table> <?php // include class file include 'Excel/reader.php'; // This could be post or get data from a form if you need to make it look for something other than id 65. $search_var = 65; // initialize reader object // Use the construct to read the file FALSE means php will not get the cell format data such as font color etc.. $excel = new Spreadsheet_Excel_Reader('book1.xls', FALSE); // get total number of rows in spreadsheet $tot = $excel -> rowcount($sheet_index = 0); // don't really need this bit but it makes it easier to follow in big scripts $cells = $excel -> sheets[0]['cells']; // Start the loop on the first row for ($row = 1; $row <= $tot; $row++) { // the number 1 in $cells[$row][1] relates to the colummn as this is a multi dimentional array. // You could make this a variable so you have more adaptable search options if($cells[$row][1] == $search_var) { echo "\t<tr>\n"; echo "\t\t<td>" . $cells[$row][1] . "</td><td>" . $cells[$row][2] . "</td>/n"; // etc... echo "\t</tr>\n"; } } ?> </table> </body> </html>
  22. Where do u work at? MicrosofT? No, Fujitsu. Sweat shop telemarketer? PMSL no, I design and maintain trend analysis and reporting tools for a service desk.
×
×
  • 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.