Jump to content

Jessica

Staff Alumni
  • Posts

    8,968
  • Joined

  • Last visited

  • Days Won

    41

Everything posted by Jessica

  1. Don't select all of them, just select the one the user selected. Also, = is assignment, == is comparison
  2. This topic has been moved to PHP Coding Help. http://forums.phpfreaks.com/index.php?topic=364963.0
  3. You're echo'ing $row, but using $_row.
  4. Do a query on the next page to get the info based on the chosen option.
  5. This topic has been moved to Ajax Help. http://forums.phpfreaks.com/index.php?topic=364960.0
  6. Wow, I read that like 4 times and didn't get that OP wanted AJAX. Moving to JS forum
  7. How would you do it with separate pages?
  8. I have a program which uses a deck of cards (not a standard deck of 52, more like the cards in a game like Dominion). Each card has a row in the DB, and a column for it's current deck_spot. When the card gets used, the deck_spot is set to 0. When the number of cards left in the deck (ie, have a spot > 0) is under a set point (4 for now), I need to shuffle the deck. I want to keep the remaining 3 cards in the "top" of the deck so they are used first, then the freshly shuffled deck is used, rather than the 3 being put in the shuffle. Here's what I have now. function shuffleDeck(){ //Get the cards which are still in the deck $sql = "SELECT user_sail_card_id FROM user_sail_cards WHERE deck_spot != 0 ORDER BY deck_spot ASC"; $rows = $this->getRows($sql); //This gets an array of all the rows //Build an update statement to put the remaining cards in order. $update = "UPDATE user_sail_cards SET deck_spot = ( CASE "; foreach($rows AS $k=>$row){ $update .= " WHEN user_sail_card_id = {$row['user_sail_card_id']} THEN ".($k+1); } $update .= " ELSE 0 END) WHERE deck_spot != 0"; $total_cards = $k+1; /*At this point update statement looks like: UPDATE user_sail_cards SET deck_spot = ( CASE WHEN user_sail_card = 3 THEN 1 WHEN user_sail_card = 2 THEN 2 ELSE 0) */ //Update those cards, then select the cards which will be shuffled. if(dbUp($update)){ $sql = "SELECT user_sail_card_id FROM user_sail_cards WHERE deck_spot = 0 ORDER BY deck_spot ASC"; $rows = $this->getRows($sql); //Shuffle the deck shuffle($rows); $update = "UPDATE user_sail_cards SET deck_spot = ( CASE "; foreach($rows AS $row){ //Put these cards AFTER the other cards $update .= " WHEN user_sail_card_id = {$row['user_sail_card_id']} THEN ".($total_cards++); } $update .= " ELSE 0 END) WHERE deck_spot = 0"; return dbUp($update); } } I'm using the ADODB library with a few custom wrapper functions. Is there a more efficient way to do this? Right now I'm making 4 queries to do it. I was hoping to do it in 1 or 2 if possible. Edit: fixed typos.
  9. Please tell me IPB has better search than we have now?
  10. Why do you have an array of calendar times that looks like that?
  11. Yes, he does. It's a rule. http://forums.phpfreaks.com/index.php?topic=364495.0
  12. You're missing a closing paren Friday: ".startAv($fetchAv->fri_start)." - ".finAv($fetchAv->fri_finish."<br>
  13. Maybe the user's expectations are wrong :-P
  14. I'm not saying that, I'm just surprised that you are getting results in another language - it makes me wonder what you are searching for. Anyway how would they know what languages you speak? Plus, if you're using Chrome it automatically translates. What makes a result "wrong" anyway?
  15. I've NEVER gotten a result in korean or chinese. I get japanese when I search for things like Bento and other japanese things.
  16. Did you look at the results? The reason is pretty obvious.
  17. I also use jQuery, but it sounds like this is something that helps you write the PHP page that responds to the request? I've never had a need for that.
  18. Whoops, didn't catch that good eye Barand
  19. Alright I'll give it a shot. I searched for stuff I've never before searched on this computer Los Angeles Angels of Anaheim elephants [my employer's name] Taco Bell Ted Cruz Google: 5 Bing: 0
  20. I don't know why you have a WHERE on it
×
×
  • 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.