Array Trouble

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I e-mailed this before, but the attachments didnt go through.  I am
designing something that my tech team can use to track the maintenancing
of our school district computers.  I have a table of data (formitems)
that contains tasks that must be completed for that computer depending
on the platform.  I loaded the results from the apple.php form into an
array ($item).  I need to make a row ($makerow) then, assuming all of
the proper columns are there, load each value in the array into its
corresponding column in the database.  For some reason, PHP is not
returning the current value of the array, it is handing MySQL the whole
array.
Any help would be appreciated.

-Tyler
Web and Database Administrator
East Valley School District
<?
include './include/dbconnect.php';
include 'accessConnect.php';
include './include/vars.php';
$sql = "select * from inventory where ID like $id and notNetworked IS NULL;";
$row = odbc_exec($db, $sql) or die ("Could not execute SQL query");
?>
<html>
<head>
<title><?= $title ?></title>
<script language="javascript">
function checkAll()
{
<?
$sql = "SELECT * FROM FORMITEMS WHERE PLATFORM LIKE '%mac%' ORDER BY ID;";
$result = mysql_query($sql);
while($list = mysql_fetch_array($result))
{
echo "if(document.form.item$list[id].value == \"1\")\n{\ndocument.$list[id].value = \"2\";\n}\n";
}
?>
}
</script>
</head>
<body bgcolor="#CBe5Db" link="#405266" vlink="#3F593E" alink="#3F593E">
<div align="center">
  <center>
  <table border="0" cellspacing="0" cellpadding="0" width="780">
    <tr>
      <td width="15" height="15"><img border="0" src="images/corner_tl.gif" width="15" height="15"></td>
      <td bgcolor="#FFFFFF" height="15"><img border="0" src="images/clear.gif" width="1" height="1"></td>
      <td width="15" height="15"><img border="0" src="images/corner_tr.gif" width="15" height="15"></td>
    </tr>
    <tr>
      <td bgcolor="#FFFFFF" width="15"><img border="0" src="images/clear.gif" width="1" height="1"></td>
      <td bgcolor="#FFFFFF">
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
		</tr>
          <tr>
            <td valign="top" rowspan="3" bgcolor="#C0C0C0" background="images/main_bg.gif"><img border="0" src="images/clear.gif" width="18" height="1">
            </td>
            <td valign="top"><img border="0" src="./images/logo.png" hspace="2" alt="Computer Maintenance" align="top">
            </td>
<!------------------------------WebAdmin Info--------------------------------------->
            <td valign="top" align="right"><img src="./images/macos.gif" align="left"><table cellpadding=0 cellspacing=0 border=0><tr><td>Apple - 
			<?
			echo "ID <b></td><td><b>";
			echo $id;
			echo "</b></td></tr><tr><td>Location: </td><td><b>";
			echo odbc_result($row, "location");
			echo " - ";
			echo odbc_result($row, "roomNo");
			echo "</b></td></tr><tr><td>Teacher: </td><td><b>";
			echo odbc_result($row, "teacher");
			echo "</b></td></tr><tr><td>Model: </td><td><b>";
			echo odbc_result($row, "modelNo");
			echo "</b></td></tr><tr><td>Serial: </td><td><b>";
			echo odbc_result($row, "serialNo");
			echo "</b></td></tr><tr><td>Mac Address: &nbsp;</td><td><b>";
			echo odbc_result($row, "macAddress");
			echo "</b></td></tr><tr><td>Drop: </td><td><b>";
			echo odbc_result($row, "dropID");
			echo "</b></td></tr><tr><td>OS: </td><td><b>";
			echo odbc_result($row, "OS");
			echo "</b></td></tr><tr><td>Processor: </td><td><b>";
			echo odbc_result($row, "processor");
			echo "</b></td></tr>";
			echo "<tr><td><a href='http://support.evsd.org/webadmin/edit_entry.asp?database=newDB&found=single&deviceNum=1&autoNo="; . odbc_result($row, "autoNo") . "'>Edit This Info</a></td></tr>";
			?>
			</table>
<!------------------------------End WebAdmin Info----------------------------------->
            </td>
          </tr>
		<tr>
			<td valign="bottom" colspan=2>
				<img border="0" src="images/clear.gif" width=5 height=5>
				
			</td>
		</tr>
		<tr>
			<td valign="top" colspan="2">	
	<!---------------------Empty Cell--------------------------->
		<table border="0" cellpadding="5" cellspacing="7">
		  <tr>
		    <td valign="top">
<!-----------------------------Maintenance Form--------------------------------------->
<form method="post" action="data.php" name="form">
<table>
<tr><td align=bottom>Not<br>Done &nbsp;&nbsp;</td><td>N/A &nbsp;&nbsp;</td><td>Done</tr></tr>
<?
$sql = "SELECT * FROM FORMITEMS WHERE PLATFORM LIKE '%mac%' ORDER BY ID;";
$result = mysql_query($sql);
while($list = mysql_fetch_array($result))
{
echo "<tr><td><input type=radio name=item$list[id] value=\"1\" checked></td><td><input type=radio name=item$list[id] value=\"2\"></td><td><input type=radio name=item$list[id] value=\"3\"></td><td>$list[item]</td></tr>\n";
}
?>
<td></td><td></td><td><input type="checkbox" name="done" value="DONE" onclick="checkAll()"></td><td>This computer is complete.</td>
</table>
<center>Comments:<br><textarea name="comments" cols="60" rows="4"></textarea></center>
<p>
<!-----------------------------------Hidden Form Elements-------------------------->
<input type="hidden" name="id" value="<?= $id ?>">
<!----------------------------------End Hidden Form Elements----------------------->
<center><input type="submit" name="submit" value="Submit"> <input type="reset" name="reset" value="Reset"</center>
</form>
<!--------------------------End Maintenance Form------------------------------------->
		        </td>
			<td>

			</td>

			<td valign="top">
			<!--Empty Cell-->
			</td>
		  </tr>
		</table>
		<img src="images/clear.gif" height=1 width=735 border=0>
		</td>
          </tr>
          <tr>
            <td valign="top" bgcolor="#C0C0C0">&nbsp;
            </td>
            <td valign="top" bgcolor="#C0C0C0" colspan="2">
	    </td>
          </tr>
        </table>
      </td>
      <td bgcolor="#FFFFFF" width="15"><img border="0" src="images/clear.GIF" width="1" height="1"></td>
    </tr>
    <tr>
      <td valign="top" align="right" width="15" height="15"><img border="0" src="images/corner_bl.gif" width="15" height="15"></td>
      <td bgcolor="#FFFFFF" height="15"><img border="0" src="images/clear.GIF" width="1" height="1"></td>
      <td valign="top" align="left" width="15" height="15"><img border="0" src="images/corner_br.gif" width="15" height="15"></td>
    </tr>
  </table>
</div>

</body>

</html>
<?
include './include/dbconnect.php';
include 'accessConnect.php';
include './include/vars.php';
$sql = "select * from inventory where ID like $id AND notNetworked IS NULL;";
$row = odbc_exec($db, $sql) or die ("You did not enter a valid Service Tag Number.");
// If device is not a computer, yell at user.
echo "nim!!!<p>";

if(odbc_result($row,"deviceType") != "1")
{
echo "This device is not a computer.<br>";
}
else
{
  //Make the row
  $makeRow = mysql_query("insert into maintenanceditems (id,comments,complete,user) values ('$id','$comments','$done','$LOGON_USER');") or die(mysql_error());
	//If the computer was completed, insert the date.
	if($complete == "DONE")
	  {
	    mysql_query("update maintenanceditems set date = \"$today\"");
	  }
	else
	  {
	    // echo "<script language=\"javascript\">history.back(1);</script>";
	  }
	//Update the row with the data from the radio buttons
	for(end($item);$item >= 0;prev($item))
	  {
	    $current = current($item);
	    mysql_query("update maintenanceditems set \"$current\"  = \"$current\" where id = \"$id\";") or die(mysql_error());
	  }
	  
}
echo "<center><font color=green size=4>Computer Successfully Maintenanced</font></center>";
include 'index.php';
?>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux