Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. and btw i think your problem is what array you are trying to loop through. preg_match_all returns a multi-dimensonal array, based on whether you have things being captured in your pattern (which you do). I suggest after your preg_match_all, you do this: echo "<pre>";print_r($posts); to get an idea of the structure of the array being returned.
  2. http://www.phpfreaks.com/tutorial/php-loops
  3. well as cags pointed out, mine is broken, so don't use it.
  4. well damn...didn't figure on that. =\
  5. This is my take. I'm pretty sure I can merge a lot of it together; ran out of time. $aLine = array('Item01', 'Item02', 'Item03', 'Item04', 'Item05', 'Item06', 'Item07', 'Item08', 'Item09', 'Item10', 'Item11', 'Item12', 'Item13', 'Item14', 'Item15', 'Item16', 'Item17', 'Item18', 'Item19'); $numCols = 4; $numRows = ceil(count($aLine) / $numCols); $aLine = array_chunk($aLine,$numRows); foreach ($aLine as $key => $val) { foreach ($val as $k => $v) { $taLine[$k][] = $v; } } $aLine = array(); foreach ($taLine as $key => $val) { $aLine = array_merge($aLine, $val); } echo "<table><tr>"; foreach($aLine as $key => $val) { echo ($key % $numCols == 0)? "</tr><tr>" : ""; echo "<td>$val</td>"; } echo "</tr></table>"; ?>
  6. ah I missed that.... actually I vaguely recall solving this a long time ago in some previous post. will have to search.
  7. well then as I mentioned before, script querying your db != bandwidth consumption. However, requesting the page itself (user refreshing), will consume bandwidth.
  8. assuming your rows have a unique ID, you will need to modify your pagination to first select all IDs order by rand and then keep track of that list. Store it in a temp table or temp file or as a session array. Then, you're going to have to keep track of which "page" you are on (the offset and limit) through that list, and then for your actual mysql query, select the specific rows (..where id IN (a,b,c,...n) ) based on the ids.
  9. what do you mean down instead of across? How many rows you end up with will depend on how many elements are in your array. Are you saying you want to be able to set how many rows there will be, but have a variant number of columns? First off, I have to ask why would you possibly want to do that?
  10. $_GET is a global array that contains whatever variables are passed in the query string of a request to your script. For example: http://www.somesite.com/somepage.php?p=123 when somepage.php is requested and run, $_GET['p'] will be set to '123' as far as your error, that line of code is trying to make a new object from class 'pager'. Unless you have that class in your script (in the file or included from another file), that class don't exist.
  11. you have the general principle but I think you're over-complicating it. $aLine = array('Item01', 'Item02', 'Item03', 'Item04', 'Item05', 'Item06', 'Item07', 'Item08', 'Item09', 'Item10', 'Item11', 'Item12', 'Item13', 'Item14', 'Item15', 'Item16', 'Item17', 'Item18', 'Item19'); $numCols = 5; echo "<table><tr>"; foreach($aLine as $key => $val) { echo ($key % $numCols == 0)? "</tr><tr>" : ""; echo "<td>$val</td>"; } echo "</tr></table>";
  12. querying the db does not suck up bandwidth when your db is on your server. Are you connecting to a remote db?
  13. Also, since we probably won't be jumping in individually welcoming every single person comes by, here's your generic welcome message: Greetings, ___________ ! Thank you for joining the board! Feel free to ask any question, but please don't be stupid about it. Make an effort to pick the right forum, make an effort to be detailed about your question, make an effort to read relevant stickies/rules, and we'll make an effort to help you. .CV
  14. okay well you can clearly (hopefully) count that there are more numbers than there are in that string...if you use chr() instead of ord() or if you rightclick > view source you will see that your string contains &#39; instead of ' so at some point in time in your script, it's being encoded.
  15. what about in your editor? in your code, do you have an actual ' in your str_replace or did your editor make one of those funky single quotes?
  16. so...you're cheating on a mock exam? I think you're missing the point? I don't know for sure but if I had to guess I'd say A and D or maybe B and D
  17. well I think you are talking about the cursor/caret but can you please explain in more detail what you are trying to do?
  18. .josh

    Sup folks

    i used to go to the irc channel a couple years ago but lack of activity did me in. Me and a couple others used to fuck around making bots for it though
  19. 2 ways you can do this: 1) put everything completely in the address bar. You would basically need to wrap your code in the following: javascript:(function(){<code here>})() You may also need to urlencode your code (for instance, your spaces at least need to be changed to %20, other special chars may or may not work, depending on the browser) This would be okay for really short pieces of javascript. 2) do the same thing as #1, except the js to be put in the url would build and append a script tag with a src of your real javascript. This would obviously mean your real js would have to be hosted somewhere. But basically it would look something like this: javascript:(function(){var%20x=document.createElement(%22script%22);x.src='http://www.somesite.com/file.js';document.body.appendChild(x);})() you may need to add in other attribs to be cross-browser compatible, (like the script tag type), but you should be able to figure that stuff on your own.
  20. my approach $string = "head:body,head:body[0,1,2],head:body[x,y,z],head:body"; $string = preg_split('~(?<=\]),~',$string); edit: hmm i obviously didn't consider no brackets...
  21. i was gonna go for format <drive> does that even work anymore?
  22. omg now I wanna learn it too let's start a study group??!?!?!?!
  23. "And I would have gotten away with it too, if it weren't for you meddling kids!"
  24. Well some people in the other thread thought there were 4 buttons to choose from, despite nrg mentioning rollover states. But as you can see for yourself, it isn't mentioned until after 140 chars, and since 140 chars is the current de facto tl;dr threshold, it's nrg's fault.
×
×
  • 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.