Jump to content

wantabe3

New Members
  • Posts

    6
  • Joined

  • Last visited

wantabe3's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. To you all...go get a life you bunch of weird geeks. Sit behind your desk in dark rooms & enjoy your life LOL! FREAKS!
  2. @Jessica I don't need your ignorant comments nor does anyone else. If you have nothing else better to do I'd suggest you get a life & leave such comments or suggestions to moderators in which I plan to report you to. Please do not reply or respond to any more of my post. You are useless to me & from what I've read from others about you, you useless to them as well. Good Riddance!
  3. This code works great except it is not resetting the active field back to 1 for all 10 fields once they are all randomly displayed. Can anyone else willing to help see where my problem is? <?php $mysqli = new mysqli('localhost', 'uname', 'pword', 'flow'); $sql = "SELECT names, active, clerk_id FROM clerk_names WHERE active = '1' ORDER BY RAND() LIMIT 1"; $res = $mysqli->query($sql); $row = $res->fetch_row(); $randomName = $row[0]; $res->free(); $sql = "UPDATE clerk_names SET active = 0 WHERE clerk_id = " . $row[2] . " " ; $res = $mysqli->query($sql); } else { $sql = "SELECT count(clerk_id) FROM clerk_names WHERE active = 0"; $res = $mysqli->query($sql); $row = $res->fetch_row(); $numzeros = $row[0]; $res->free(); if($numzeros == 10){ $sql = "UPDATE clerk_names SET active = 1" ; $res = $mysqli->query($sql); } } mysql_close(); // Close the database connection. ?>
  4. I'm a newbe at PHP so can you help me out I just googled the count function & it does not make sense to me... I only need the ACTIVE field in the DB to be set to a 1 only if all 10 entries are set to a 0. So basically, the IF/COUNT statement would say something like, "IF all the ACTIVE fields are 0, I'm going to set all 10 back to 1" It sounds simple but I can't get it to save my life!!! Thanks for any help you can give.
  5. The code below works great. It pulls data from a MySQL database & displays it in a form. The DB consist of a table named clerk_names & the fields are clerk_id, names, and active. There will always be only 10 entries in this DB. The code below pulls the name & marks the active field from a 1 to a 0 for the particular random name it pulls. Like I said this code works great except I need to add an IF or ELSE or ELSEIF statement so if all the active fields are set to 0, it will mark all 10 of them back to a 1. Basically, once the 10 active field is marked to a 0 with the code below I just need something to mark all of them back to a 1 in the active field.........is this possible? <?php $mysqli = new mysqli('localhost', 'uname', 'password', 'flow'); $sql = "SELECT names, active, clerk_id FROM clerk_names WHERE active = '1' ORDER BY RAND() LIMIT 1"; $res = $mysqli->query($sql); $row = $res->fetch_row(); $randomName = $row[0]; $res->free(); $sql = "UPDATE clerk_names SET active = 0 WHERE clerk_id = " . $row[2] . " " ; $res = $mysqli->query($sql); } mysql_close(); // Close the database connection. ?>
×
×
  • 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.