Update certain column of recordset from textbox value

Athirah Hazira

room.php

enter image description here

<input name = "room" type = "text" size="70"/>    

<a href="updateroom.php?roomid=<?=$row_Recordsetroomid['roomid'] ?>">Update</a>

updateroom.php

<?php
  mysql_connect('localhost','athirahhazira','1234');
  mysql_select_db("dbcollege");
  session_start();

  $sql = "UPDATE studentsroom set room='$strroom' WHERE roomid='$_GET[roomid]'";
  mysql_query($sql) or die('Error updating room status');

  header('Location:staff/room-staff.php');
?>

i can update if there is a default value such as :

  $sql = "UPDATE studentsroom set room='A206' WHERE roomid='$_GET[roomid]'";

but not the value from a textbox. could u help me with what i am missing here?

Satish Sharma

try this

$sql = "UPDATE studentsroom set room='A206' WHERE roomid='".$_REQUEST['roomid']."'";

Note: your code can be sql injection. also mysql_* is deprecated use mysqli_* or PDO

Update2:

add a form and submit button instead of hyperlink

<form method="post" action="updateroom.php" >
<input name = "room" type = "text" size="70"/>    
<input type="hidden" name="roomid" value="<?php echo $row_Recordsetroomid['roomid'];?>" />
<input type="submit" name="submit" value="Update" />
</form>

AND update.php

<?php
  mysql_connect('localhost','athirahhazira','1234');
  mysql_select_db("dbcollege");
  session_start();

  $room = $_REQUEST['room']; 
  $roomid = $_REQUEST['roomid']; 

  $room = mysql_real_escape_string($room);
  $roomid = mysql_real_escape_string($roomid);

  $sql = "UPDATE studentsroom set room='$room' WHERE roomid='$roomid'";
  mysql_query($sql) or die('Error updating room status');

  header('Location:staff/room-staff.php');
?>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

update a certain column with a set value

From Dev

Laravel, return recordset where certain column is unique

From Dev

Update column with certain value to a column value with same id

From Dev

Only Update a certain column in MySQL Query if it has a certain value set

From Dev

Get value from a certain row in a column

From Dev

Get value from a certain row in a column

From Dev

Update the value from table in textbox BUT not updated the value in db?

From Dev

Update column from another table column value

From Dev

update a column of numbers from value to (value * 1.3)

From Dev

Update textbox value $on event

From Java

Replacing values in column with values from different column if they are a certain value

From Dev

Update table if certain fields are null with related values from a different column

From Dev

How to display a textbox in SSRS based on not null value in a column from dataset

From Dev

MySQL update column value with max value from another column

From Dev

UPDATE sql column with value from another column based on a date column

From Dev

vba get value from sql server recordset

From Dev

Extract Value from Column A and then get the count for certain values from Column B for the value in Column A

From Dev

Update column for random value from different table

From Dev

Update column with value from two potential columns

From Dev

mysql update column value from another table

From Dev

Update TextBox Value on history back

From Dev

Along runs of certain values, fill with first value from a second column

From Dev

Pass all rows from grid that have certain value in a specific column

From Dev

SQL query exclude a certain value from same column same table?

From Dev

Can I check Value in DAO Recordset field during update process?

From Dev

update a column with derived value from another column in mysql

From Dev

Update multiple column value from one column of the same table

From Dev

Update a column by selecting random value from a different column

From Dev

update a column with derived value from another column in mysql

Related Related

  1. 1

    update a certain column with a set value

  2. 2

    Laravel, return recordset where certain column is unique

  3. 3

    Update column with certain value to a column value with same id

  4. 4

    Only Update a certain column in MySQL Query if it has a certain value set

  5. 5

    Get value from a certain row in a column

  6. 6

    Get value from a certain row in a column

  7. 7

    Update the value from table in textbox BUT not updated the value in db?

  8. 8

    Update column from another table column value

  9. 9

    update a column of numbers from value to (value * 1.3)

  10. 10

    Update textbox value $on event

  11. 11

    Replacing values in column with values from different column if they are a certain value

  12. 12

    Update table if certain fields are null with related values from a different column

  13. 13

    How to display a textbox in SSRS based on not null value in a column from dataset

  14. 14

    MySQL update column value with max value from another column

  15. 15

    UPDATE sql column with value from another column based on a date column

  16. 16

    vba get value from sql server recordset

  17. 17

    Extract Value from Column A and then get the count for certain values from Column B for the value in Column A

  18. 18

    Update column for random value from different table

  19. 19

    Update column with value from two potential columns

  20. 20

    mysql update column value from another table

  21. 21

    Update TextBox Value on history back

  22. 22

    Along runs of certain values, fill with first value from a second column

  23. 23

    Pass all rows from grid that have certain value in a specific column

  24. 24

    SQL query exclude a certain value from same column same table?

  25. 25

    Can I check Value in DAO Recordset field during update process?

  26. 26

    update a column with derived value from another column in mysql

  27. 27

    Update multiple column value from one column of the same table

  28. 28

    Update a column by selecting random value from a different column

  29. 29

    update a column with derived value from another column in mysql

HotTag

Archive