Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Problem with editing a table entry.
Old 03-18-2008, 08:27 PM Problem with editing a table entry.
Junior Talker

Posts: 3
Location: Scotland
Trades: 0
Hey there!
I'm going to post both my scripts so you can hopefully help me further. Basically I have a bugs_main.php and a bugs_main_edit.php, bugs_main.php displays the bugs within tables and a "status" column at the end which by default shows "Not yet taken". Now when you click an "edit" button, you're taken to a password screen, enter the password if correct the bugs_main_edit.php page loads, now this page shows all the bugs and also shows an input field plus two buttons in the "status" column, the input field takes the person's name and they then press one of the two buttons "fixed" or "working on", bugs_main.php takes that information and depending on which button is pressed, the corresponding text will display ("fixed" or "working on") along with the inputted name or whatever was input to the text field.

I hope you can understand that!
Here are the two scripts; I hope someone can help me out!! I've tried a lot of different stuff, nothing's working yet . (I've obviously removed sensitive information from the following code!)

bugs_main.php:
Code:
<?php require("menu.php"); 
$ida = $id += 0;
//Connect to MYSQL server
mysql_connect("*removed*", "*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 "</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=5 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>


bugs_main_edit.php:
Code:
<?php require("menu.php"); 
if($_POST['password'] != "password")
 { echo "<center><font color='red'><h4>Incorrect password!</h4></font></center>"; }
 
 else 
                  
                       {
                                //Connect to MYSQL server
                                mysql_connect("*removed*", "*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'>Update</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'>".$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 "<form method='POST' action='bugs_main.php'> <input type='text' value='Your name' name='name'></form>";
                                 echo "<form method='POST' action='bugs_main.php'> <input type='submit' value='Fixed!' name='fixed'><br /></form>";
                                 echo "<form method='POST' action='bugs_main.php'> <input type='submit' value='Working on' name='working_on'></form>";
                                 echo "</td></tr>";
                          } 
                    echo "</TABLE>";
                    echo "<center><form method='POST' action='bugs_main.php'><input type='submit' value='Save' name='save'></center>";
                   
          }                    
?></font></center></body></html>

Thanks!
-Brave.
Braveheartt is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-19-2008, 03:41 AM Re: Problem with editing a table entry.
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
What is the problem exactly?
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 03-19-2008, 03:42 AM Re: Problem with editing a table entry.
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Remember one thing: nobody will read your scripts if you post more than 10 lines and obviously nobody will try to run them and moreover nobody will try to run them if they require database backend.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 03-19-2008, 08:08 AM Re: Problem with editing a table entry.
Junior Talker

Posts: 3
Location: Scotland
Trades: 0
Good question :P! Sorry, I forgot to say what the problem actually was.

Basically, the above paragraph is what I want to achieve. 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, here's some screenshots:

Bugs main page:



Bugs edit page:




Here's an example of what happens, I've put "test" into the box and I press the "fixed!" button:



This is the result:








As you can see, it should only say "Fixed!" in the first bug not them all, it also should have "Fixed by Test!".

Hope you can help :\.

Last edited by Braveheartt; 03-19-2008 at 10:36 AM..
Braveheartt is offline
Reply With Quote
View Public Profile
 
Old 03-20-2008, 03:46 AM Re: Problem with editing a table entry.
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Track down where in your code the "Test" string should be inserted into the table and find out why it is not. Maybe you refer to wrong $_POST variable, maybe you overwrite the variable value. If the value is inserted then the problem is in display step. Maybe you refer to wrong field of table row, maybe you overwrite it somewhere.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to Problem with editing a table entry.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16225 seconds with 12 queries