php form buton who response on Id from mysql table - help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Lubaka
Forum Newbie
Posts: 1
Joined: Tue May 26, 2015 6:09 am

php form buton who response on Id from mysql table - help

Post by Lubaka »

Hi, on first time I want to sorry for my bad english!

On second time I want ask little help from who of you who will want to help me, and I will very tankful for this.

I am new in php programing and mysql, for this sorry if the my way is not right!

Now on the problem!
I want to make something so "notes" webpage - something very little for now!

I make little base in MySQL in four cells. (id, name, RQtext, Complate)

I make a connection in one file.
And begin with index who combine other two files who i created (inserform.php and getrequest.php)

The problem is in getrequest.php (for now)! I make a table and in this table I extract the data from my table rq1 in this code:

Code: Select all

while($row = mysql_fetch_array($query)){

 if($row['Complate'] == 0) {
  $id = $row['id'];
  $statusrq = "<td align=center> <input type=submit value=изпълни name=statusfalse id=$id> </td>";

  echo "<form action=index.php method=POST>";
  echo "<tr bgcolor=red>";
  echo "<td>";
  echo $id;
  echo "</td><td>";
  echo $row['name'];
  echo "</td><td>";
  echo $row['RQtext'];
  echo "</td>";
  echo $statusrq;
  echo "</tr>";
  echo "</form>";



    if(isset($_POST['statusfalse'])) {
     $sql = "UPDATE rq1 SET Complate=1 WHERE id=$id";
     $result = mysql_query($sql);
   }


 } else {
  $statusrq = "<td align=center bgcolor=lightblue> <b>завършена</b> </td>";
  echo "<tr bgcolor=lightblue>";
  echo "<td>";
  echo $row['id'];
  echo "</td><td>";
  echo $row['name'];
  echo "</td><td>";
  echo $row['RQtext'];
  echo "</td>";
  echo $statusrq;
  echo "</tr>"; 
 }



 
 }

echo "</table>";
In end of every row is generated submit button, but this button must be identified with only this row, that is the problem how to do this! When have click on submit button, the quest must completed, or in mysql in table rq1, the cell "Complete" must change value from 0 on 1 only for this row!

For look how must look
http://bg-media.net/learning/notes/
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: php form buton who response on Id from mysql table - hel

Post by requinix »

Code: Select all

<input type=submit value=изпълни name=statusfalse id=$id>
First, you should always use quotes with HTML attributes. Without quotes you have to be very careful about what kinds of values you insert in there. For example, if there is a space then anything after it will be lost.

To your problem: <input> is nice but <button> is nicer. It allows you to have a value separate from the caption on the button, so you could do

Code: Select all

<button type="submit" name="statusfalse" value="$id">изпълни</button>
That way $_POST["statusfalse"] will be the ID you need to change.

Are you interested in being able to mark more than one row at a time? Like using checkboxes for each and then one button to submit?
Post Reply