Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. Good riddance to bad rubish. Let that other site have you, cause we do not want you as you obviously just disregard the rules and have no respect for anyone here who donates their time on this website. Thanks for coming, but please do not come again unless you change that attitude of yours and adhere to the rules! EDIT: As far as the title I thought it was shifty as well =\ Weird how computer screens can mess with your eyes, gd refresh rates!
  2. array_unique should be the answer to your question.
  3. You will have to create your own hack to the forum you choose to allow for that. There is no forum software that I am aware of that you can just plugin to your current user account system and it will work. So any type of forum software will work, but you probably wanna go with a simpler forum than a more advanced forum as it would be easier to incorporate your current system into, but you will still have to modify it to get it to work.
  4. The real question is what is the goal of displaying these items...is there an order to them that they have to be displayed in a certain way? If so, one option of doing so is putting the display order in an array of it's own then loop through the original array putting those items into that created array to display them: $display_options = array($shortname."_colourscheme" => array(), $shortname . "_definition_list" => array()); foreach ($options as $option) { if (in_array($option['id'], $display_options)) { $display_options[$option['id']] = $option; } } foreach ($option as $opt) { echo '<div id="' . $opt['id'] . '">' . $opt['name'] . '</div>'; } Now that is a rough example, but it would probably be easier than the nested if's. You can set the display_options different for other pages etc. There is probably a better way to do it than that, such as storing that information in a database and being able to query and only pull the data you want/need so there will only be one loop to do.
  5. According to what you posted, it is already an array....so the question is, did you word your question wrong? Can you provide a small of example of what you would like...
  6. My bet would be utilizing imap. Depending on your setup you may have to enable the extension in PHP (read the installation at the link if you do for more info).
  7. I do not think space is the issue. With a database most of the database is contained in a handful of files (Each table as a separate file if I am not mistaken for MySQL). So it would definitely cut down on cycles as it is always accessing those few files vs having to locate 1 file among 7 million files and it will also be less fragmented as the same reasoning, a few files is a lot easier to handle the deleting/editing/creating files stored on the server etc which can tend to fragment files...especially with 7 million files. Where as the MySQL database would just grow in size depending on the text (which really is not much for size so that is not an issue) I doubt you would go over a few hundred mb's either way with files or MySQL. Now the other issue is searching, if you wanted to incorporate a search a database will do this so much faster than searching through flat files, as databases have indexes that you can set etc, which make that take an insanely less amount of time. But I would bet it would be much easier on your harddrive storing it all in a database vs storing it in separate files just because it is accessing a few files vs million's of files. As far as proof, no clue if anyone setup a test, I think it is just more or less common sense?
  8. Moved to Javascript as this is not a PHP question.
  9. Ok, here is an example: Say on my website I want categories with sub-categories and I want them in a multi-dimm array so I can display them with a simple loop so the array would be setup something like this: <?php $categories = array("Top Level1" => array("Sub Level1-1", "Sub Level1-2"), "Top Level2" => array("Sub Level 2-1"), "Top Level3"); foreach ($categories as $category => $subCat) { if (is_array($subCat)) { echo $category . "<br />"; foreach ($subCat as $sub) { echo " " . $sub . "<br />"; } }else { echo $subCat . "<br />"; } echo "<br />"; } ?> The above is a very rough and simple example, hopefully it helps you understand what you may want to use a multi-dimm array for.
  10. Maybe they will use their own gangster encryption method that requires a secure hashed key so the cops cannot find the location.... Now note an example encrypted string in gangster terminology is "met at teh prk ner 4ty forth and wash" and a "hashed" key is a pipe that just got smoked.
  11. Ok, lets say you host a blogging website and have 2,000 users who post at least twice a day on the website, so that is 4,000 new posts a day. Each post is stored in a database and you want to cache the html created from the post, either in the DB or on the Harddrive, we will say the harddrive just for this purpose. Each time a post is created a create a new cached entry on the harddrive, in a months time your harddrive will have 120,000 files, in a years time your harddrive will have 7,120,000 new files on it. Now if you want comments on these posts everytime a comment is added you have to re-cache the post or if the user edits their post. So eventually your harddrive has a ton of files on it, that is really unnecessary and can make access times of the harddrive slow down a bit, and not to mention constantly replacing cached pages etc will fragment the harddrive pretty bad. Now let's say you are upgrading to a new server, well copying all those files will be a pain in the butt. So you decide to re-create them on the new server, well that will take some time as well. It just really is not practical for that type of scenario. Now if you are just running your own blog site, when there is maybe 2 posts a day and you rarely edit them, then caching would probably be a good idea, but instead of storing the post in a database why not just create the html file and set the <meta> tags to cache. Why would you need PHP to do that? But if you would rather have it in a database, well you can create the html file then just update it but that kind of defeats the purpose of the database (kind of). But yea, you can debate it all you want, the real and true answer is, do what you think is best. I can give you my opinion on it, but in the end it is what you want to do that matters.
  12. Caching is definitely faster, if you have static content. However, as stated above, most content is dynamic and for the benefits it is not worth it to cache every single dynamic page. Now, aside from caching you can send the pages compressed to the browser, such as gzipped which sizes the page down considerably. But yea, if the code is done efficiently and there are not many images on the page you should not notice too much of a difference between a cached page and a non-cached page as most connections (and computers) are way above par for displaying webpages.
  13. I do not use any. If I refer someone to one it is usually AVG Free, as it does decent work or I have them install Spybot. But yea, I know what to download/not to (At least I hope so) and if I do slip up and install something I shouldn't have, well then I must have needed to format my computer and I do so. I tend to keep all of my stuff on a separate drive so formatting is easy as just doing it. On that note I really need to make an image so all of the software is installed for me after a format. Maybe next format I will. (lol I always say that) .
  14. Can you provide example data that you want to go through and what you would like done with it?
  15. In the first one you are just concatenating two values into $value, the other one you are accessing a single value inside a multi-dimensional array. As far as speed goes, arrays will be quicker. I do not know the technical parts behind it, but I do know that you can access data in an array element faster. It is probably something to do with an array has a pre determined size (not sure in PHP but I know in like VB/C++ etc you have to pre-define the array size). So I am sure PHP buffers this size and allows for additional items to be added. Where as a variable being created creates a new spot in memory. EDIT: Well doing some reading it looks like I was wrong in my head. Anyhow there are times to use an array vs variables and using them properly will give your script the best performance. Like I said I do not understand the technical part of it (I never really liked all that mumbo jumbo although I should have learned it better). But an array will access data quicker than creating a new variable. However, as mike stated, you should use the proper item for what you need, if you need to increment a variable then assigning a variable to a number is better vs holding a collection of data such as database connection info. But $value = $oldvalue . $newvalue; is not the same as $value['old']['new'] Example is here: <?php $oldvalue = "test "; $newvalue = " test 2"; $value = $oldvalue . $newvalue; echo "The new value of value is: {$value}<br />"; $value = array("old" => array("new" => array("test"))); echo "The value stored in array at index of old and index of new inside old is: {$value['old']['new']}"; ?> Hopefully that clears it up a bit more.
  16. http://snippets.dzone.com/posts/show/3044 Found googling the terms: "php time since".
  17. for is a loop that will basically loop and increment a variable for you: $images = 5; for ($i=1;$i<=$images;$i++) {echo "<img src=>";} There is a corrected version of the code. Basically it sets $i equal to 1 at the beginning and while $i <= $images (5) execute the code in the brackets, after executing increment $i by one and go back through the check....Hopefully I explained that process right lol. The correction to the original code as putting $ before the i++
  18. Empty did not work on that array because technically the array is not empty. Doing a print_r on the array for the code you posted yielded this: Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => ) As you can see there are indexes in that array, which means it is not empty. So empty works as expected, you just did not realize that the indexes were being created just not populated. The code I used to generate the above item: <?php if (isset($_POST['submit'])) { print_r($_POST['name']); } ?> <form action = <?php echo $_SERVER['PHP_SELF']; ?> method = 'post' > <?php for($i=1; $i<=10; $i++){ ?> <input type = 'text' name = 'name[]' size ='25' maxlength = '50' /> <input type = 'text' name = 'age[]' size ='25' maxlength = '50' /> <?php } ?> <input type="submit" name="submit" value="submit" /> </form> If you would prefer to see for yourself
  19. Not to mention the $ instead of S here: $_SESSION['username'] = S_POST['username']; Should be: $_SESSION['username'] = $_POST['username'];
  20. http://www.phpfreaks.com/forums/index.php/topic,278874.msg1320290.html#msg1320290 This topic was posted about an hour before yours (only 5 or 6 posts down). Please try and look through at least the first page of responses before posting, as your issue may have been addressed already. As you may have been able to start your script with that information and then had more of a in-depth question to ask instead of a generic one
  21. <?php $result = mysql_query("SELECT * FROM matches, leagues WHERE matches.type = leagues.nameshort AND result='Win' GROUP BY result"); $row = mysql_fetch_row($result); // this fetches the data as an array ordered by a numbered index. $rowCount = mysql_num_rows($result); // this will give us the number of rows returned if ($rowCount>0) { echo $rowCount; }else { echo "0"; } ?> Put my remarks in the comments of the code.
  22. <?php include 'config.php'; require_once 'Spreadsheet/Excel/Writer.php'; if ($QuitDate===false) { // Active employees $sql =" ( `QuitDate` is null or trim(`QuitDate`) = '' ) "; }else { // Terminated employees $sql =" ( `QuitDate` is not null and trim(`QuitDate`) <> '' ) "; } $query = "SELECT GevityNo, employee_name, Sex, nextel, ssNumber, BirthDate, Hire_Date, QuitDate, PayRate, street_address, City, state, zip_code, home_phone, cellphonenum FROM employees WHERE $sql ORDER BY `employee_name` "; $result = mysql_query($query) or die('Error, query failed'); $num_rows = mysql_num_rows($result); if($num_rows > 0) { $row_count = 1; while($row = mysql_fetch_array($result)){ if($row_count == 1) { // Creating a workbook $workbook = new Spreadsheet_Excel_Writer(); $format_bold =& $workbook->addFormat(); $format_bold->setBold(); // sending HTTP headers $workbook_name = $row['employees'] . 'phone_list.xls'; $workbook->send($workbook_name); // Creating a worksheet $worksheet =& $workbook->addWorksheet('phone_list'); // The actual data $worksheet->setColumn(0,0,30); $worksheet->setColumn(0,1,14); $worksheet->setColumn(0,2,14); $worksheet->setColumn(0,3,14); $worksheet->write(0, 0, 'Name', $format_bold); $worksheet->write(0, 1, 'Nextel', $format_bold, $format_left); $worksheet->write(0, 2, 'Home', $format_bold, $format_left); $worksheet->write(0, 3, 'Cell', $format_bold, $format_left); } $worksheet->write($row_count, 0, $row['employee_name']); $worksheet->write($row_count, 1, $row['nextel']); $worksheet->write($row_count, 2, $row['home_phone']); $worksheet->write($row_count, 3, $row['cellphonenum']); $row_count++; } } // Let's send the file $workbook->close(); // ?>
  23. I posted the correct code there...try that and see if it helps you out. Cause your SQL would still have been throwing an error due to the double quotes after result="win" it should be result='Win' (as shown correctly above).
  24. You need to encapsulate string variables inside a sql in Single quotes, not double. $result = mysql_query("SELECT * FROM matches, leagues WHERE matches.type = leagues.nameshort AND result='Win' GROUP BY result"); As well if you would of had this for testing you would have known the error: $result = mysql_query("SELECT * FROM matches, leagues WHERE matches.type = leagues.nameshort AND result='Win' GROUP BY result") or die(mysql_error()); EDIT: As a note the or DIE() should be loosely used and perhaps you should change your script to incorporate error handling via this debugging tutorial look into the "trigger_error" portion.
  25. I see where you have the $sql inside the while loop, but the SQL statement has already run and you are not re-using that $sql anywhere... That will need to be applied to the initial query for it to work like you want to or you need to add logic inside the while loop that states if quitdate is_null or trim is equaled to empty string then continue; else add it to the spreadsheet....
×
×
  • 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.