Braveheartt Posted March 18, 2008 Share Posted March 18, 2008 I have a problem with editing my entries. I coded an edit page to edit the "status" of the bug (fixed or working on) default it would display "not yet taken". But there's a major problem, when I go to the editing page, click one button on one row EVERY entry will change on the main page. Also the name displaying will only work on them all and only if I edit every single box on the edit page to be the same. What have I done wrong!? main page (displaying): <?php require("menu.php"); $ida = $id += 0; //Connect to MYSQL server mysql_connect("Localhost", "*removed*", "*removed*") or die(mysql_error()); //echo "<center><font color='white'>Successfully connected to MySQL!</font></center><br />"; //Connect to MYSQL database mysql_select_db("*removed*") or die(mysql_error()); echo "<center><font color='white'><h4>Successfully connected to the Bugs Database!</h4></font></center>"; // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM bugs ORDER BY ID DESC") or die(mysql_error()); // store the record of table into $row echo "<CENTER><TABLE BORDER='2' BORDERCOLOR='#336699' CELLPADDING='2' BGCOLOR='#000000' CELLSPACING='2' WIDTH='100%'></CENTER>"; echo "<tr> <th><font color='#FFFFFF'>ID</font></th> <th><font color='#FFFFFF'>Priority</font></th> <th><font color='#FFFFFF'>Bug Type</font></th> <th><font color='#FFFFFF'>Poster</font></th> <th><font color='#FFFFFF'>Bug Description</font></th> <th><font color='#FFFFFF'>Screenshot 1</font></th> <th><font color='#FFFFFF'>Screenshot 2</font></th> <th><font color='#FFFFFF'>Screenshot 3</font></th><th><font color='#FFFFFF'>Status</font></th></tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "</td><td align='center'>"; echo "<font color='white'>".$ida++."</font>"; echo "</td><td align='center'>"; if($row['priority'] == Urgent) echo "<strong><font color='#FF0000'>Urgent</font></strong>"; elseif($row['priority'] == Medium) echo "<strong><font color='#FF6600'>Medium</font></strong>"; elseif($row['priority'] == Low) echo "<strong><font color='#FFCC00'>Low</font></strong>"; echo "</td><td align='center'>"; echo "<font color='#FFFFFF'>".$row['type']."</font>"; echo "</td><td align='center'>"; echo "<font color='#FFFFFF'>".$row['poster']."</font>"; echo "</td><td align='center'>"; echo "<TEXTAREA wrap='hard' name='des' rows=3 cols=60 COLOR='#FFFFFF' readonly='yes' MAXLENGTH=9999>".$row['description']."</TEXTAREA>"; echo "</td><td align='center'>"; if(empty($row['screen1'])) echo "<font color='#FFFFFF'>No Screenshot submitted</font>"; else echo "<A HREF=".$row['screen1']."><font color='#0099FF'>Screenshot1</font></A>"; echo "</td><td align='center'>"; if(empty($row['screen2'])) echo "<font color='#FFFFFF'>No Screenshot submitted</font>"; else echo "<A HREF=".$row['screen2']."><font color='#0099FF'>Screenshot2</font></A>"; echo "</td><td align='center'>"; if(empty($row['screen3'])) echo "<font color='#FFFFFF'>No Screenshot submitted</font>"; else echo "<A HREF=".$row['screen3']."><font color='#0099FF'>Screenshot3</A>"; echo "</td><td align='center'>"; if(isset($_POST['fixed'])) echo "<strong><font color='#009900'>Fixed by ".$_POST['name']."!</font></strong>"; elseif(isset($_POST['working_on'])) echo "<strong><font color='#0033FF'>".$_POST['name']." is working on it!</font></strong>"; else echo "<strong><font color='#FFCC00'>Not yet taken</font></strong>"; echo "</td></tr>"; } echo "</TABLE>"; ?></font></center></body></html> Edit page: <?php require("menu.php"); $ida = $id += 0; /*if(isset($_POST['login'])) if($_POST['password'] == "password") */ //Connect to MYSQL server mysql_connect("Localhost", "*removed*", "*removed*") or die(mysql_error()); //echo "<center><font color='white'>Successfully connected to MySQL!</font></center><br />"; //Connect to MYSQL database mysql_select_db("*removed*") or die(mysql_error()); echo "<center><font color='white'><h4>Successfully connected to the Bugs Database!</h4></font></center>"; //Retrieve all the data from the table $result = mysql_query("SELECT * FROM bugs ORDER BY ID DESC") or die(mysql_error()); //store the record of table into $row echo "<CENTER><TABLE BORDER='2' BORDERCOLOR='#336699' CELLPADDING='2' BGCOLOR='#000000' CELLSPACING='2' WIDTH='100%'></CENTER>"; echo "<tr> <th><font color='#FFFFFF'>ID</font></th> <th><font color='#FFFFFF'>Priority</font></th> <th><font color='#FFFFFF'>Bug Type</font></th> <th><font color='#FFFFFF'>Poster</font></th> <th><font color='#FFFFFF'>Bug Description</font></th> <th><font color='#FFFFFF'>Screenshot 1</font></th> <th><font color='#FFFFFF'>Screenshot 2</font></th> <th><font color='#FFFFFF'>Screenshot 3</font></th><th><font color='#FFFFFF'>Status</font></th></tr>"; //keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td align='center'>"; echo "<font color='white'>".$ida++."</font>"; echo "</td><td align='center'>"; if($row['priority'] == Urgent) echo "<strong><font color='#FF0000'>Urgent</font></strong>"; elseif($row['priority'] == Medium) echo "<strong><font color='#FF6600'>Medium</font></strong>"; elseif($row['priority'] == Low) echo "<strong><font color='#FFCC00'>Low</font></strong>"; echo "</td><td align='center'>"; echo "<font color='#FFFFFF'>".$row['type']."</font>"; echo "</td><td align='center'>"; echo "<font color='#FFFFFF'>".$row['poster']."</font>"; echo "</td><td align='center'>"; echo "<TEXTAREA wrap='hard' name='des' rows=3 cols=60 COLOR='#FFFFFF' readonly='yes' MAXLENGTH=9999>".$row['description']."</TEXTAREA>"; echo "</td><td align='center'>"; if(empty($row['screen1'])) echo "<font color='#FFFFFF'>No Screenshot submitted</font>"; else echo "<A HREF=".$row['screen1']."><font color='#0099FF'>Screenshot1</font></A>"; echo "</td><td align='center'>"; if(empty($row['screen2'])) echo "<font color='#FFFFFF'>No Screenshot submitted</font>"; else echo "<A HREF=".$row['screen2']."><font color='#0099FF'>Screenshot2</font></A>"; echo "</td><td align='center'>"; if(empty($row['screen3'])) echo "<font color='#FFFFFF'>No Screenshot submitted</font>"; else echo "<A HREF=".$row['screen3']."><font color='#0099FF'>Screenshot3</A>"; echo "</td><td align='center'>"; echo "<center><form method='POST' action='bugs_main.php'><input type='text' value='Your name' name='name'></center><br />"; echo "<center><form method='POST' action='bugs_main.php'><input type='submit' value='Fixed!' name='fixed'></center>"; echo "<center><form method='POST' action='bugs_main.php'><input type='submit' value='Working on' name='working_on'></center>"; echo "</td></tr>"; } echo "</TABLE>"; echo "<center><form method='POST' action='bugs_main.php'><input type='submit' value='Save' name='save'></center>" /*elseif($_POST['password'] != "password") header ( "redirect.php" ); */ ?></font></center></body></html> And an off topic question, how could I add a "delete" option to the editing page which would delete only the ONE entry you pressed the button in? | 1 | 1 | 1 | 1 | Delete | | 2 | 2 | 2 | 2 | Delete | So if I clicked the delete button in the second row, only that entire row will be deleted. I have tried everything I could think of, looked at a lot of tutorials etc but to no avail... Please help! Thanks, Brave. Link to comment https://forums.phpfreaks.com/topic/96713-whats-wrong-with-this-code/ Share on other sites More sharing options...
cooldude832 Posted March 18, 2008 Share Posted March 18, 2008 edit would imply a delete/update query and I don't see any. Link to comment https://forums.phpfreaks.com/topic/96713-whats-wrong-with-this-code/#findComment-494897 Share on other sites More sharing options...
Braveheartt Posted March 18, 2008 Author Share Posted March 18, 2008 edit would imply a delete/update query and I don't see any. I tried doing that, but it made things even worse. The field I'm trying to edit is not stored in the MYSQL DB. It's simply text that I wish to change! Link to comment https://forums.phpfreaks.com/topic/96713-whats-wrong-with-this-code/#findComment-494943 Share on other sites More sharing options...
cooldude832 Posted March 18, 2008 Share Posted March 18, 2008 text in a raw like .html, .php file? maybe you should look into a database to simplify things Link to comment https://forums.phpfreaks.com/topic/96713-whats-wrong-with-this-code/#findComment-494982 Share on other sites More sharing options...
Braveheartt Posted March 18, 2008 Author Share Posted March 18, 2008 text in a raw like .html, .php file? maybe you should look into a database to simplify things I am using MYSQL for everything else; it's just the end column which I want to have three possible pieces of text (with a variable for the inputted text included) which will be set depending on which button is pressed. Link to comment https://forums.phpfreaks.com/topic/96713-whats-wrong-with-this-code/#findComment-495048 Share on other sites More sharing options...
Braveheartt Posted March 19, 2008 Author Share Posted March 19, 2008 The scripts above show the bugs, and display the "Status" column with "Not yet taken" in yellow. All good, until you go to the edit page, it will change ALL the bug's "status" column even though you only click one button in one bug's column. It will also not display the text which is input into the text box. Hard to explain, I tried using radio buttons also. Maybe would be better since you could edit more than one bug at a time. Anyway here's some screenshots: Bugs main page: http://aycu08.webshots.com/image/47207/2001602790613666870_rs.jpg Bugs edit page: http://aycu05.webshots.com/image/47364/2001682221149629304_rs.jpg Here's an example of what happens, I've put "Test" into the box and I press the "fixed!" button: http://aycu14.webshots.com/image/49813/2001663726929095240_rs.jpg This is the result: http://aycu25.webshots.com/image/46984/2001669802930443896_rs.jpg As you can see, it should only say "Fixed by !" in the first bug not them all, it also should have "Fixed by Test!". I hope someone can help! I've tried a lot of different stuff, nothing's working . Should I store the status in the database? At the moment it's just changing the text and adding in the name field. Is that enough? Link to comment https://forums.phpfreaks.com/topic/96713-whats-wrong-with-this-code/#findComment-495803 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.