Jump to content

wright0768

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

wright0768's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I was originally using a varchar field named username but seeing that the script you wrote was using user_id I changed mine to user_id but kept it as varchar. I changed the field name in my database instead of the field name in the script so everyone was dealing with the same script. I guess we had a bit of a miscommunication but user_id (int) in your script was username (varchar) in mine.
  2. $pickList = (isset($_POST["pick"])) ? implode('\', \'', $_POST["pick"]) : ''; This change seems to make everything work. I still have to do more testing but so far so good. mjdamato thank you again.
  3. $query = "UPDATE users SET offer = IF(user_id IN ('{$pickList}'), 1, 0)"; This does not give an error but only actually updates the database if 1 user total is selected. The only difference is single quotes around the {$pickList}. I think it might be something with implode in order to get the right sql syntax
  4. I know you said you didn't test it so don't worry I wasn't expecting it to necessarily work without some tinkering. I appreciate all the help. If 2 users are selected this gives me: People chosen: user1, user2 Query: UPDATE users SET offer = IF(user_id IN (user1, user2), 1, 0) Database query failed: Unknown column 'user1' in 'field list' I'll try tweaking it to see if i can get it to work, let me know what you think
  5. EDIT: People chosen: Array Database query failed: Unknown column '(whatever the first username checked is)' in 'field list'.
  6. It looks good however, it is giving me this output: People chosen: Array Database query failed: Unknown column '(whatever the first username checked is' in 'field list'. I substituted in my own values for my database and this is what it is giving me. My table name is users, the user_id is the column that holds usernames, and offer is also a column. I think something might just be reversed because it is looking for a specific username as a column instead of as a row.
  7. Thank you so much. I'll test it out now and let you know if I run into any problems. Thanks again!
  8. It is an int and the field name is offer. Do you need any information other than that?
  9. What I have so far is a page that produces a list of usernames with checkboxes next to them. From the usernames that I check, I want to update a field for each of those users. My problem is that the number of checkboxes I check is not going to be static so I am pretty sure I have to run a loop based on the number of checked checkboxes ("People chosen"). Here is what I have so far: <?php if (isset($_POST['submit1'])) { $pick = $_POST["pick"]; $how_many = count($pick); echo 'People chosen: '.$how_many.'<br><br>'; echo "<br><br>"; $count = 0; while ($count < $how_many) { //mysql code probably should go here but I am stuck $count++; } } else { $gender = mysql_real_escape_string($_POST['Gender']); $limit = mysql_real_escape_string($_POST['limit']); echo $gender; echo "<br />"; $count = 0; if ($gender == 'Male') { $result = mysql_query("SELECT * FROM users WHERE gender =\"1\" LIMIT 0, $limit", $connection); if (!$result) { die("Database query failed: " . mysql_error()); } ?> <form method="post"> <?php while ($row = mysql_fetch_array($result)) { ?> <input name="pick[]" type="checkbox" value="<?php echo $row['username'] ?>"><?php echo $row['username'];?> <br /> <?php } ?> <input type="submit" name="submit1" value="Make Offer" /> </form> <?php } ?> I hope this makes sense. Any help would be greatly appreciated.
  10. I already have an upload script for my website, but i wanted to know how to make the folder that the file uploads to change every x minutes. Like if i had a folder upload1, upload2, and upload3, i want the script to rotate the upload folder.
×
×
  • 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.