Jump to content

need help updating entries


I-R-Fool

Recommended Posts

Okay, heres my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link href="../style.css" rel="stylesheet" type="text/css"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title><script language="JavaScript"><!--function formCheck(formobj){	// Enter name of mandatory fields	var fieldRequired = Array("questionPopulate");	// Enter field description to appear in the dialog box	var fieldDescription = Array("Comment");	// dialog message	var alertMsg = "Please complete the following fields:\n";   	var l_Msg = alertMsg.length;   	for (var i = 0; i < fieldRequired.length; i++){		var obj = formobj.elements[fieldRequired[i]];		if (obj){			switch(obj.type){			case "select-one":				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){					alertMsg += " - " + fieldDescription[i] + "\n";				}				break;			case "select-multiple":				if (obj.selectedIndex == -1){					alertMsg += " - " + fieldDescription[i] + "\n";				}				break;			case "text":			case "textarea":				if (obj.value == "" || obj.value == null){					alertMsg += " - " + fieldDescription[i] + "\n";				}				break;			default:			}			if (obj.type == undefined){				var blnchecked = false;				for (var j = 0; j < obj.length; j++){					if (obj[j].checked){						blnchecked = true;					}				}				if (!blnchecked){					alertMsg += " - " + fieldDescription[i] + "\n";				}			}		}	}	if (alertMsg.length == l_Msg){		return true;	}else{		alert(alertMsg);		return false;	}}// --></script><script language="javascript">function populateTextField(){var selectedQuestion=document.getElementById("selectionPanel").value;if(selectedQuestion!="select"){document.getElementById("questionPopulate").value=selectedQuestion;}}</script></head><body><center><?php$con = mysql_connect("localhost","root","");if (!$con)  {  die('Could not connect: ' . mysql_error());  } mysql_select_db("a", $con);$query = " SELECT * FROM a " .		 "ORDER BY id DESC";$result = mysql_query($query) or die('Error, query failed');echo("<form method='post'  onsubmit='return formCheck(this);'><select name='selectionPanel' id='selectionPanel' onChange='populateTextField()')><option name='a' value='Select'>Select</option>");while($row = mysql_fetch_array($result)){$question = $row['question'];$rowid = $row['id'];$comment = $row['comment'];echo "<option name='a' value='".$comment."'>".$question."</option>";}echo("</select><br />");echo("<br /><input type='text' name='questionPopulate' id='questionPopulate'></input>	 <button type='submit' value='submit'>Submit</button>	 </form>");$uComment = $_POST['questionPopulate'];if (isset($_POST['submit'])){mysql_query("UPDATE a SET comment='".$uComment."' WHERE id='".$rowid."'");}mysql_close($con)?></center></body></html>

But when i press submit when I changed the input value, it won't update the entr

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...