Darkmatter5 Posted May 27, 2008 Share Posted May 27, 2008 Here's the code for my page. <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style1 { font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; } body { background-color: #006699; } .style3 { font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; } .style7 {font-family: Verdana, Arial, Helvetica, sans-serif} .style4 { font-family: Geneva, Arial, Helvetica, sans-serif; font-weight: bold; } .style2 { background-color: #ECD34A; font-family: Arial, Helvetica, sans-serif; font-weight: bold; font-size: 11px; } --> </style> <script src="library/selectClient.js"></script> </head> <body> <form method="post"> <table width="770" border="0"> <tr> <td colspan="4"><span class="style4">Edit a client record - </span><span class="style3">Search by selecting from the list below</span></td> </tr> <tr> <td colspan="4"><div align="left"><span class="style7"> <?php include 'library/dbconfig.php'; include 'library/opendb.php'; $query="SELECT ClientID, FirstName, LastName, CompanyName FROM byrnjobdb.clients ORDER BY LastName ASC , FirstName ASC, CompanyName ASC"; $result=mysql_query($query); echo "<select name='Client' method='get' onChange='showClientLST(this.value)'>"; echo "<option>---Select---</option>"; while ($row=mysql_fetch_array($result)) { $r1=$row['ClientID']; if(empty($row['CompanyName'])) { $r2=$row['LastName']. ", " .$row['FirstName']; } else { $r2=$row['LastName']. ", " .$row['FirstName']. " of " .$row['CompanyName']; } echo "<option value='$r1'>$r2</option>"; } echo "</select>"; include 'library/closedb.php'; ?> </span></div></td> </tr> <tr> <td width="119"> </td> <td width="149"><div align="center">Data to update</div></td> <td width="484" colspan="2"><div align="center">Current data in the database record</div></td> </tr> <tr> <td>ClientID:</td> <td> </td> <td colspan="2" rowspan="14"><div id="results"> <div align="center">Record results will appear here</div> </div></td> </tr> <tr> <td>First name:</td> <td><div align='center'><input name="FirstName" type='text' id="FirstName" /></div></td> </tr> <tr> <td>Last name:</td> <td><div align='center'><input name="LastName" type='text' id="LastName" /></div></td> </tr> <tr> <td>Company name:</td> <td><div align='center'><input name="CompanyName" type='text' id="CompanyName" /></div></td> </tr> <tr> <td>Contact title:</td> <td><div align='center'><input name="ContactTitle" type='text' id="ContactTitle" /></div></td> </tr> <tr> <td>Address:</td> <td><div align='center'><input name="Address" type='text' id="Address" /></div></td> </tr> <tr> <td>City:</td> <td><div align='center'><input name="City" type='text' id="City" /></div></td> </tr> <tr> <td>State:</td> <td><div align='center'><input name="State" type='text' id="State" /></div></td> </tr> <tr> <td>Zip code:</td> <td><div align='center'><input name="ZipCode" type='text' id="ZipCode" /></div></td> </tr> <tr> <td>Home phone:</td> <td><div align='center'><input name="HomePhone" type='text' id="HomePhone" /></div></td> </tr> <tr> <td>Work phone:</td> <td><div align='center'><input name="WorkPhone" type='text' id="WorkPhone" /></div></td> </tr> <tr> <td>Work phone ext.:</td> <td><div align='center'><input name="WorkPhoneExtension" type='text' id="WorkPhoneExtension" /></div></td> </tr> <tr> <td>Fax phone:</td> <td><div align='center'><input name="FaxPhone" type='text' id="FaxPhone" /></div></td> </tr> <tr> <td>Email:</td> <td><div align='center'><input name="Email" type='text' id="Email" /></div></td> </tr> <tr> <td><input name='editclient' type='submit' id='editclient' value='Store new client data' /></td> <td><div align="right">Function Status =></div></td> <td colspan="2"><span class="style2"> <?php if(isset($_POST['editclient'])) { include 'library/dbconfig.php'; include 'library/opendb.php'; $result=mysql_query("SELECT FirstName,LastName,CompanyName FROM byrnjobdb.clients WHERE ClientID = " .$_POST['Client']); $row=mysql_fetch_array($result); $fields=array("ClientID","FirstName","LastName","CompanyName","ContactTitle","Address","City","State","ZipCode","HomePhone","WorkPhone","WorkPhoneExtension","FaxPhone","Email"); for($i=0; $i<=13; $i++) { /* if(isset($_POST['$fields[$i]'])) mysql_query("UPDATE INTO byrnjobdb.clients SET $fields[$i]=$_POST['$fields[$i]'] WHERE $fields[0]=$_POST['$fields[0]']");*/ } if(isset($_POST["$fields[1]"])) $row['FirstName']=$_POST["$fields[1]"]; if(isset($_POST["$fields[2]"])) $row['LastName']=$_POST["$fields[2]"]; if(isset($_POST["$fields[3]"])) $row['CompanyName']=$_POST["$fields[3]"]; /* if(empty($_POST["$fields[3]"]) && empty($row['CompanyName'])) { echo "Client " .$_POST["Client"]. "(" .$_POST["$fields[2]"]. ", " .$_POST["$fields[1]"]. ") updated!"; }else { echo "Client " .$_POST["Client"]. "(" .$_POST["$fields[2]"]. ", " .$_POST["$fields[1]"]. " of " .$_POST["$fields[3]"]. ") updated!"; }*/ echo "Client " .$_POST["Client"]. "(" .$row['LastName']. ", " .$row['FirstName']. " of " .$row['CompanyName']. ") updated!"; include 'library/closedb.php'; } ?> </span></td> </tr> </table> </form> </body> </html> If I comment out the following lines I get the output of the record selected from the drop-down list, but if the lines ar not commented out, it'll set the specific $row variable to null and it'll output blank space for the variable in the echo. What's going on? Here are the lines in question. if(isset($_POST["$fields[1]"])) $row['FirstName']=$_POST["$fields[1]"]; if(isset($_POST["$fields[2]"])) $row['LastName']=$_POST["$fields[2]"]; if(isset($_POST["$fields[3]"])) $row['CompanyName']=$_POST["$fields[3]"]; Link to comment https://forums.phpfreaks.com/topic/107464-unexplained-output-please-help/ Share on other sites More sharing options...
wildteen88 Posted May 27, 2008 Share Posted May 27, 2008 Remove the quotes perhaps? if(isset($_POST[$fields[1]])) $row['FirstName']=$_POST[$fields[1]]; if(isset($_POST[$fields[2]])) $row['LastName']=$_POST[$fields[2]]; if(isset($_POST[$fields[3]])) $row['CompanyName']=$_POST[$fields[3]]; Link to comment https://forums.phpfreaks.com/topic/107464-unexplained-output-please-help/#findComment-550883 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.