
mbb87
Members-
Posts
12 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
mbb87's Achievements

Newbie (1/5)
0
Reputation
-
Having an issue with UPDATING SQL Database via PHP Table
mbb87 replied to mbb87's topic in PHP Coding Help
Adding the WHERE actually worked fine. Without it, all the rows got updated to 0 if not checked even the ones that i original didn't call (GET) Example: Mikes Team: Karlsson Chara (Checked) Spezza (NOT SHOWING UP ON THE QUERY (GET)) Paul's Team: Ovechkin (CHECKED) Brodeur Well running it without the WHERE would make Chara on the block but would removed all other players that are on other teams from the block by changing the block value to 0 But i thank you so much since without you i would still be scratching my head. -
Having an issue with UPDATING SQL Database via PHP Table
mbb87 replied to mbb87's topic in PHP Coding Help
So here is the final product for everyone that helped me and if anyone wants a suggestions. Thanks Again!! // Get all the data from the "example" table $result = mysql_query("SELECT * FROM `players` WHERE `own` =$user ORDER BY `players`.`l_name` ASC LIMIT 0 , 30") or die(mysql_error()); ?> <form name="myblock" action="_myblock.php?user=<?php echo $user; ?>" method="POST"> <?php echo "<table border='1'>"; echo "<tr><th>NAME</th><th>POS</th><th>BLOCK</th></tr>"; while($row = mysql_fetch_array( $result )) { $checked = ($row['block'] == '1') ? ' checked="checked"' : ''; echo "<tr>\n"; echo " <td>{$row['f_name']} {$row['l_name']}</td>\n"; echo " <td>{$row['pos']}</td>\n"; echo " <td><input type='checkbox' name='pl_id[{$row['pl_id']}]' value='{$row['pl_id']}'{$checked}></td>\n"; echo "</tr>"; } echo "</table>"; mysql_select_db("mbbcom1_fantrax") or die(mysql_error()); //Verify the values are valid integers and put in comma separated string $checked_players_list = implode(', ', array_map('intval', $_POST['pl_id'])); //Run update to set blocked status based on whether the player ID was in the submitted list $query = "UPDATE `players` SET `block` = `players`.`pl_id` IN ({$checked_players_list}) WHERE `own` = $user"; $result = mysql_query($query); -
Having an issue with UPDATING SQL Database via PHP Table
mbb87 replied to mbb87's topic in PHP Coding Help
Alright so it changes all players that are not in the get query as well, At this point what it does is: Even though the players are not on that users team it changes them back to 0 and removes other users trade block players. Ill try to figure it out. maybe add and other WHERE criteria. -
Having an issue with UPDATING SQL Database via PHP Table
mbb87 replied to mbb87's topic in PHP Coding Help
WOW!!! YOU GUYS ARE AMAZING!!! ITs working. I would love to know why though. But i bugged you guys enough, ill try to google it. Thanks again everyone. -
Having an issue with UPDATING SQL Database via PHP Table
mbb87 replied to mbb87's topic in PHP Coding Help
Shouldn't it be something like this? //Run update to set blocked status based on whether the player ID was in the submitted list $query = "UPDATE 'players' SET `block` = '1' WHERE `players`.`pl_id` IN ({$checked_players_list})"; $result = mysql_query($query); Also in the error codes is says '$checked_players_list' is empty no? -
Having an issue with UPDATING SQL Database via PHP Table
mbb87 replied to mbb87's topic in PHP Coding Help
echo "<table border='1'>"; echo "<tr><th>NAME</th><th>POS</th><th>BLOCK</th></tr>"; while($row = mysql_fetch_array( $result )) { $checked = ($row['block'] == '1') ? ' checked="checked"' : ''; echo "<tr>\n"; echo " <td>{$row['f_name']} {$row['l_name']}</td>\n"; echo " <td>{$row['pos']}</td>\n"; echo " <td><input type='checkbox' name='pl_id[{$row['pl_id']}]' value='{$row['pl_id']}'{$checked}></td>\n"; echo "</tr>"; } echo "</table>"; RUNNING IT: mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("mbbcom1_fantrax") or die(mysql_error()); //Verify the values are valid integers and put in comma separated string $checked_players_list = implode(', ', array_map('int', $_POST['pl_id'])); //Run update to set blocked status based on whether the player ID was in the submitted list $query = "UPDATE 'players' SET `block` = `players`.`pl_id` IN ({$checked_players_list})"; $result = mysql_query($query); echo "Debugging info:<br>\n"; echo "POST Data:<pre>" . print_r($_POST, 1) . "</pre>\n"; echo "Checked Players list: {$checked_players_list}<br>\n"; echo "Update Query: {$query}<br>\n"; if($result) { echo "Query executed with " . mysql_affected_rows($result) . " affected rows"; } else { echo "Query Failed. Error " . mysql_error(); } where are you guys getting $block ? Im trying to understand what you guys are doing, but not sure how it will update all the players without a loop. you lost me there. (I keep searching online for the solution, not trying to be lazy here and just cut and paste) I REALLY APPRECIATE ALL THE HELP and just trying to understand and get this to work. -
Having an issue with UPDATING SQL Database via PHP Table
mbb87 replied to mbb87's topic in PHP Coding Help
Debugging info: POST Data: Array ( [pl_id] => Array ( [36] => 36 [31] => 31 [75] => 75 [17] => 17 [187] => 187 [121] => 121 [89] => 89 [42] => 42 [30] => 30 [116] => 116 ) [submit] => submit ) Checked Players list: Update Query: UPDATE 'players' SET `block` = `players`.`pl_id` IN () Query Failed. Error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''players' SET `block` = `players`.`pl_id` IN ()' at line 1 -
Having an issue with UPDATING SQL Database via PHP Table
mbb87 replied to mbb87's topic in PHP Coding Help
Where are you getting "$checked_players_list"? EDIT: Never mind, I see it now but still nothing gets updated. Didnt think it was that confusion, but no one seems to be able to figure it out. I really hope to hearing from you some more. If you have any questions please fire them away. I REALLY WANT TO FIX/GET IT TO WORK THANKS AGAIN FOR YOUR TIME. -
Having an issue with UPDATING SQL Database via PHP Table
mbb87 replied to mbb87's topic in PHP Coding Help
Here is the page if that help you understand what I want to do. http://www.mbb87.com/fantrax/myblock.php?user=92&inblock=1 -
Having an issue with UPDATING SQL Database via PHP Table
mbb87 replied to mbb87's topic in PHP Coding Help
Theirs 26 players on each team. -
Having an issue with UPDATING SQL Database via PHP Table
mbb87 replied to mbb87's topic in PHP Coding Help
Nope still doesn't work. No error messages just like before, just doesn't update anything as of now. -
Trying to Update the MySQL Tables but nothing is being Updated, I'm sure I'm just not seeing the tiny issue, would love some help. Thanks So its a trade block for a hockey pool, if you want the player on the trade block then you just check the CHECKBOX in the form and submit and it should change the value in the database to value of "1". FORM: echo "<table border='1'>"; echo "<tr><th>NAME</th> <th>POS</th> <th>BLOCK</th></tr>"; $counter = 1; while($row = mysql_fetch_array( $result )) { echo "<tr><td>"; echo "{$row['f_name']}" . " " . "{$row['l_name']}"; echo "</td><td><input name='pl_id[$counter]' type='hidden' value='{$row['pl_id']}'>"; echo "{$row['pos']}"; echo "</td><td><input name='pos[$counter]' type='hidden' value='{$row['pos']}'>"; echo "<input type='checkbox' name='block[$counter]' size='1' value='1'"; if($row['block'] == '1') { echo "checked='checked'"; } echo "></td></tr>"; $counter++; } echo "</table>"; SUBMIT PHP PAGE: mysql_connect("localhost", "user", "pass") or die(mysql_error()); mysql_select_db("mbbcom1_fantrax") or die(mysql_error()); $i = 1; while ($i < 26) { $block = $_POST['block'][$i]; $pl_id = $_POST['pl_id'][$i]; $query = mysql_query("UPDATE 'players' SET `block` = '$block' WHERE `players`.`pl_id` = '$pl_id'"); mysql_query($query); $i++; } echo mysql_close(); Thank you in advance for any help you can provide me.