Jump to content

Changing value using dropdown


ampsman

Recommended Posts

Go easy on me, I'm new to this.

So I have a basic dropdown that lets a user select an option, from there the matching records for that option are diplayed in a table.

What I want to be able to do is have one of the fields for the results have a yes/no dropdown so the user can change the value for that record using the dropdown.

Is this possible?

 

Heres my current code:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">

 

<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8">

<title></title>

<link rel="stylesheet" href="style_sheet.css" type="text/css" media="screen">

 

</head>

<body>

 

 

<h2>

Client File Check-in/out

</h2>

 

 

<form method="post" action="">

<select name="clientName">

 

<?php

$con = mysql_connect("servername","admin","admin");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}

 

mysql_select_db("clients", $con);

 

$result = mysql_query("SELECT clientname

FROM clients

ORDER BY clientname");

 

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

print '<option value="' . $row['clientname'] . '">' . $row['clientname'] . '</option>';

}

 

mysql_close($con);

?>

 

</select>

<input type="submit" value="Submit"/>

</form>

 

<?php

$con = mysql_connect("servername","admin","admin");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}

 

mysql_select_db("clients", $con);

 

$clientName = $_POST['clientName'];

 

$res = mysql_query("SELECT clientname, matterno, checked_out, checked_out_by FROM matters  WHERE clientname = '$clientName' ORDER BY matterno");

 

echo "<table border=\"1\">";

echo "<tr><th>Client Name</th>";

echo "<th>Matter Number</th>";

echo "<th>Checked Out?</th>";

echo "<th>Checked Out By</th></tr>";

 

while($row = mysql_fetch_array($res))

{

echo "<tr><td>";

echo $row['clientname'];

 

echo "</td><td>";

echo $row['matterno'];

 

echo "</td><td>";

echo $row['checked_out'];

 

echo "</td><td>";

echo $row['checked_out_by'];

echo "</td></tr>";

 

}

echo "</table>";

mysql_close($con);

?>

 

 

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/154248-changing-value-using-dropdown/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.