lightsguy Posted February 13, 2007 Share Posted February 13, 2007 Spent most of the day trying to figure this out. I need to determine the best way to update a single column in the data base. The page that loads would show all records WHERE complete = No. Then, the user could indicate that the request has been done. (I'm not really partial to a particular method. Seeing as how I can't get any of my ideas to work, I won't argue with anything thrown out there.) Once they say the request is done, the record is submitted. Currently, the page redirects back to itself (test_5.php) simply because I have no where else for it to go. For the record: I know my $query as written will update every record in the DB. I never could figure out how to isolate only the records I chose. Most of what you will find below is a result of searching the archives here and other sources. Obviously, I don't know something critical, which is hampering my progress. If you can point me in the right direction, it would be greatly appreciated. <?php if(isset($_POST['add'])) { include 'config.php'; include 'opendb.php'; $query = "UPDATE cable SET complete = 'Yes' WHERE complete = 'No'"; mysql_query($query) or die('Error, query failed'); unset ($_POST['add']); include 'closedb.php'; include("test_5.php") ; } else { include 'config.php'; include 'opendb.php'; $query = "SELECT date,emp_name, emp_email, emp_phone,server,location,switch,port FROM cable WHERE complete = 'No'"; $result = mysql_query($query); echo "<form method=\"post\"><table width=\"100%\"><tr><td>Date</td><td>Name</td><td>Email</td>" . "<td>Phone</td><td>Group</td><td>Server</td><td>Location</td><td>Switch</td><td>Port</td>" . "<td>Complete?</td></tr>" ; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<tr> <td>{$row['date']}</td>" . "<td>{$row['emp_name']}</td>" . "<td>{$row['emp_email']}</td>" . "<td>{$row['emp_phone']}</td>" . "<td>{$row['emp_group']}</td>" . "<td>{$row['server']}</td>" . "<td>{$row['location']}</td>" . "<td>{$row['switch']}</td>" . "<td>{$row['port']}</td>" . "<td><select name=\"done\"><option>Yes</option><option selected>No</option></td>" ; } echo"</tr></table><input name=\"add\" type=\"submit\" id=\"add\" value=\"Submit\"></body></html>"; include 'closedb.php'; } ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 13, 2007 Share Posted February 13, 2007 "I never could figure out how to isolate only the records I chose." WHERE id = '$id' What are you stuck on? Quote Link to comment Share on other sites More sharing options...
lightsguy Posted February 13, 2007 Author Share Posted February 13, 2007 "I never could figure out how to isolate only the records I chose." WHERE id = '$id' What are you stuck on? I know that I would have to set $id to match the rows that I want to update. Obviously, the only rows I want to update are the ones that are complete, and the user has indicated as so. If they chose "Yes" from the dropdown (as I have it written, which may I not work, I admit) how do I tie that to $id ? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 13, 2007 Share Posted February 13, 2007 make the name of the dropdown something like option_(id here). Then use substr() to remove the option_ part, and you have your ID in the processing part. Quote Link to comment Share on other sites More sharing options...
lightsguy Posted February 13, 2007 Author Share Posted February 13, 2007 Well, that pretty much confirms I'm in over my head here. That's what I get for taking on projects at work. This is a case where I'm fully aware I don't know enough to properly describe my next problem. Thanks for the help. I've got more research to do. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.