Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. For page 2 you should subtract items per page from $c before the for loop. That seems like the simplest way to me. But I still recommend using array_slice() If your array is in reverse order, you can also use array_reverse() first. The end result will be simpler to understand.
  2. The problem is the part in bold: $badarray=explode(array("\r\n", "\r", "\n"),$bad); You can't put an array here - it has to be a string.
  3. That problem doesn't apply here. The problem is that "2" sorts above "12" using sort(), but the OP has added leading zeroes. Edit: Oops, the problem is that "a2" sorts above "a12". There must be some non-numeric stuff in the string to encounter the problem.
  4. That tells you there is a problem with your explode() then. Looking at the php manual, explode() does not take an array as the first argument.
  5. Well, that IS pagination Even if it's only two pages. Another way to do it is: $pageno = 2; # Show page #2 $files_per_page = 16; # Show 16 files on each page $page_files = array_slice($files, ($pageno - 1) * $files_per_page, $files_per_page); Then $page_files is an array containing just the files for the current page. The trickiest bit of pagination is generating the next/prev links, so if you are doing those manually then this should be all you need. Edit: Maybe you need to subtract one from the second argument to array_slice(). I don't remember.
  6. Are you familiar with using loops to go through results from mysql? Such as "while" and "foreach"?
  7. That's best done in php, I wouldn't try to express it in SQL. You can loop through the results from MySQL remembering the following values: 1. How long the current streak is 2. How long the longest streak was Remember to check at the end (after the loop has finished) to see if the last streak is the longest.
  8. readdir() doesn't guarantee to return the files in order. It probably worked in the past by luck only. You could read all the files in and sort them, or you could keep a list somewhere of the latest ones. As for pagination, it is always a bit messy, and there are many tutorials available.
  9. Hmm.. I would try adding this to the top: ini_set('display_errors', 1); Maybe it will tell you something useful.
  10. Try this: $badarray=explode(array("\r\n", "\r", "\n"),$bad); foreach($badarray as $value){ $value= str_replace(array("\r\n", "\r", "\n"),NULL,trim($value)); echo $value; $query="Update googlevacancies_junk SET exist='$no' WHERE email='$value' "; mysql_query($query) or die("Error in query:<br>$query<br>" . mysql_error()); } The only change is to check for errors from mysql_query()
  11. Oh I see the problem.. I had thought you said that mysql was returning multiple results for a quote, but it was the php loop calling multiple mysql statements. Sorry for misinterpreting your question.
  12. That code looks ok to me.. is the "@" getting converted in the body of the email? Or is it in the headers?
  13. btherl

    isset()

    Try this out. It's long and messy because of the unusual database design, but it may get you what you want. The key idea is rather than filtering rows by YES, which doesn't work because a single row can contain both YES and NO, it maps YES to 1 and NO to 0 and then adds up the total. $sql = "SELECT SUM(CASE WHEN rowBa = 'YES' THEN 1 ELSE 0 END) " . " + SUM(CASE WHEN rowBb = 'YES' THEN 1 ELSE 0 END) " . " + SUM(CASE WHEN rowBc = 'YES' THEN 1 ELSE 0 END) " . " + SUM(CASE WHEN rowBd = 'YES' THEN 1 ELSE 0 END) " . " + SUM(CASE WHEN rowBe = 'YES' THEN 1 ELSE 0 END) " . " AS cnt " . " FROM my_db2 "; But, like thorpe said, please consider redesigning the table
  14. Yes.. if I understand correctly about what you mean by "duplicate posts". It's normal that if you have the same quote with 3 labels that you would get 3 rows back for one quote, each with a different label. And what your code is doing to merge them into a single result looks right to me. I guess that I can't see any problem with your code, especially not a problem relating to matching more than one searched term. SQL will not duplicate results just because more than one "OR" is matched. But it will duplicate results if there are multiple rows matching for a join. Eg if a quote appears 3 times in the categories table, the quote will appear 3 times in the result of a join with that table.
  15. This function will give you the key: http://au2.php.net/manual/en/function.array-search.php array_filter() will let you use a callback to implement more complex filters on arrays.
  16. Based on your output, it looks as if it returns multiple rows because of the multiple labels, not because the rows were matched on more than one search condition. Otherwise you would get repeated labels in your labels array.
  17. Does the query succeed and return 0 results, or does it fail?
  18. I think it's fine to echo inside the class if the purpose of the class is to echo your page. The Smarty display method is an example of this. But within the class I would recommend that you generate the entire output in a string, and only echo it with a single statement at the end. IE your display method would be function display() { $output = $this->generate(); echo $output; } And no other method from this class (and all other classes) would echo anything.
  19. The oppposite of < is >=, and the opposite of > is <=. That's another way to invert the comparisons.
  20. Your original code would work if you add the missing "}" at the end. But I recommend doing as revraz suggested: if (...) { } elseif (...) { } else { } That makes the code more readable.
  21. Try these settings: // Constants define('BASE_URI', '/01_KnowledgeIsPower/'); define('BASE_URL', 'localhost'); define('MYSQL', '/includes/mysql.inc.php'); It's a bit tricky to know what they're expecting there, as those are not what I would normally consider a URI or URL. So instead I'm trying to go based on the example values.
  22. What do you type into the browser when you want to see the website?
  23. BASE_URL should probably look like the original one, ie a host name.
  24. How did you disable the cronjob email response?
×
×
  • 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.