Jump to content

Update Multiple Rows - USING PHP!!


MichaelGallagher

Recommended Posts

Does anyone have any idea why i cant update multiple records with this: ??

 


<?php




$update=$_GET['update'];

if ($update=='yes') {


				// set database access parameters
				$strServer="localhost"; // Server IP Address 'or' Name
				$strDatabase="test"; // Database Name
				$strUser="root"; // User ID
				$strPwd="tshop"; // Password


				// connect to database using above parameters
				$strDB=mysql_connect($strServer,$strUser,$strPwd)or die 
								('Error connecting to mysql..');
				$database=mysql_select_db("$strDatabase",$strDB);



//creating array & update loop
foreach($_POST['id'] as $id){ 
	$name=$_POST['name['.$id.']'];
	$lastname=$_POST['lastname['.$id.']'];
	$email=$_POST['email['.$id.']'];


	$sql=mysql_query("SELECT id FROM test_mysql WHERE id='$id'");
	$num_results=mysql_num_rows($sql);
	echo '<p>number of rows: '.$num_results.'</p>';

		if ($num_results == 1) {

			$sql2=mysql_query("SELECT * FROM test_mysql WHERE id='$id'");
			$row=mysql_fetch_array($sql2);

			$name=$row['name'];
			$lastname=$row['lastname'];
			$email=$row['email'];

			$update=mysql_query("UPDATE test_mysql SET name='$name', lastname='$lastname', email='$email' WHERE id='$id'");

			print "$update";

			if(!$update) { die("Could not save the record! Player ID: id "); }

		}
}


}

else {



// set database access parameters
$strServer="localhost"; // Server IP Address 'or' Name
$strDatabase="test"; // Database Name
$strUser="root"; // User ID
$strPwd="tshop"; // Password


// connect to database using above parameters
$strDB=mysql_connect($strServer,$strUser,$strPwd)or die 
			('Error connecting to mysql..');
$database=mysql_select_db("$strDatabase",$strDB);


$sql="SELECT * FROM test_mysql;";
$result = mysql_db_query($strDatabase, $sql) or die
("A MySQL error has occurred.<br />Your Query: " . $sql . "<br /> Error: (" . mysql_errno() . ") " . mysql_error());


$count=mysql_num_rows($result);

//table top
echo '<table width="500" border="0">';
echo '<form method="post" action="updatemultiple.php?update=yes"><tr>';

echo '<td width="250" class="style3">id</td>';
echo '<td width="50" class="style3">name</td>';
echo '<td width="50" class="style3">lastname</td>';
echo '<td width="50" class="style3">email</td>';
echo '</tr>';
//form loop
$sql = mysql_query("SELECT * FROM test_mysql") or die (mysql_error());

while($row = mysql_fetch_array($sql)){
$id=$row['id'];
$name=$row['name'];
$lastname=$row['lastname'];
$email=$row['email'];

echo '<tr>';
echo '<td><input type="hidden" name="id['.$id.']" value="'.$id.'">'.$name.'</td>';
echo '<td><div align="center">';
echo '<input name="name['.$id.']" type="text" id="name['.$id.']" size="5" value="'.$name.'">';
echo '</div></td>';
echo '<td><div align="center">';
echo '<input name="lastname['.$id.']" type="text" id="lastname['.$id.']" size="5" value="'.$lastname.'">';
echo '</div></td>';
echo '<td><div align="center">';
echo '<input name="email['.$id.']" type="text" id="email['.$id.']" size="5" value="'.$email.'">';
echo '</div></td>';
echo '</tr>';
}
echo '<tr>';
echo '<td colspan="4"><div align="center">';
echo '<input type="hidden" name="req" value="update_stats">';
echo '<input type="submit" name="Submit" value="Update Player Statistics">';
echo '</div></td>';
echo '</tr></form>';
echo '</table>';

}


?>

Link to comment
Share on other sites

My first guess would be that you're using the wrong syntax for your multidimensional arrays here:

<?php
	$name=$_POST['name['.$id.']'];
	$lastname=$_POST['lastname['.$id.']'];
	$email=$_POST['email['.$id.']'];
?>

 

This would be the correct way:

<?php
	$name=$_POST['name'][$id];
	$lastname=$_POST['lastname'][$id];
	$email=$_POST['email'][$id];
?>

Link to comment
Share on other sites

what is it doing instead

 

Well, it doesn't display any errors..

 

Let me go straight to the point.. I posted this previous, however it was moved because it was classified as "HTML Help", which I really don't think describes it at this point. This solution is for FIREFOX only and is INTERNAL, so no IE or NS at all! :)

 

My page displays portfolio information for customers and has so much info that i have integrated a scrolling solution; fixed header and left column (as well as hover info) to support the staff using it...

 

Basically I have this page as following:

 


<!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>
    <title>Fixed Headers</title>
    
    <link type="text/css" href="../scripts/scrolltable/Style.css" rel="stylesheet" />
    <script type="text/javascript" src="../scripts/scrolltable/Script.js"></script>
    
    <script type="text/javascript" src="../scripts/overlib/overlib.js"></script>
<script type="text/javascript" src="../scripts/overlib/overlib_shadow.js"></script>
<script type="text/javascript" src="../scripts/overlib/overlib_hideform.js"></script>
<SCRIPT TYPE="text/javascript">
<!--
overlib_pagedefaults(FGCOLOR, '#ffffff', CLOSECOLOR, '#ffffff', BGCOLOR, '#B6A29B', TEXTCOLOR, '#666666', WRAP,VAUTO);
-->
</SCRIPT>
    
    
</head>
<body>
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>

<table class="scrollTable" id="scrollTable" cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td>
			<div class="corner">
				<table cellpadding="0" cellspacing="0" border="0">
					<tr>
						<th><div><a href='portfolio.php?sort=CompanyName&order=asc'><img src='../images/ascend.gif' height='12' width='11'border='0'></a><br />Company Name<br /><a href='portfolio.php?sort=CompanyName&order=desc'><img src='../images/descend.gif' height='12' width='11'border='0'></a></div></th>
					</tr>
				</table>
			</div>
		</td>
		<td>
			<div class="headerRow">
				<table cellpadding="0" cellspacing="0" border="0">
					<tr>
						<th><div><a href='portfolio.php?sort=LastCallDate&order=asc'><img src='../images/ascend.gif' height='12' width='11'border='0'></a><br />Last<br />Call Date<br /><a href='portfolio.php?sort=LastCallDate&order=desc'><img src='../images/descend.gif' height='12' width='11'border='0'></a></div></th>
						<th><div>Telstra<br />Monthly<br />Spend</div></th>
						<th><div>Other<br />Telco<br />Spend</div></th>
						<th><div>Telstra<br />Fixed<br />Lines</div></th>
						<th><div>Other Carrier<br />Fixed Lines</div></th>
						<th><div>Phone<br />System</div></th>
						<th><div>Installing<br />Dealer</div></th>
						<th><div><a href='portfolio.php?sort=EstPhoneSysPurchase&order=asc'><img src='../images/ascend.gif' height='12' width='11'border='0'></a><br />Est. Phone<br />Sys. Purchase<br /><a href='portfolio.php?sort=EstPhoneSysPurchase&order=desc'><img src='../images/descend.gif' height='12' width='11'border='0'></a></div></th>
						<th><div>Fixed<br />Contract<br />Type</div></th>
						<th><div><a href='portfolio.php?sort=FixedContractStartDate&order=asc'><img src='../images/ascend.gif' height='12' width='11'border='0'></a><br />Fixed<br />Contract<br />Start Date<br /><a href='portfolio.php?sort=FixedContractStartDate&order=desc'><img src='../images/descend.gif' height='12' width='11'border='0'></a></div></th>
						<th><div><a href='portfolio.php?sort=FixedContractEndDate&order=asc'><img src='../images/ascend.gif' height='12' width='11'border='0'></a><br />Fixed<br />Contract<br />End Date<br /><a href='portfolio.php?sort=FixedContractEndDate&order=desc'><img src='../images/descend.gif' height='12' width='11'border='0'></a></div></th>
						<th><div>Single<br />Bill</div></th>
						<th><div>Telstra<br />Mobile</div></th>
						<th><div><a href='portfolio.php?sort=FirstMobileContractEndDate&order=asc'><img src='../images/ascend.gif' height='12' width='11'border='0'></a><br />First Mobile<br />Contract<br />End Date<br /><a href='portfolio.php?sort=FirstMobileContractEndDate&order=desc'><img src='../images/descend.gif' height='12' width='11'border='0'></a></div></th>
						<th><div>Dealer<br />Code</div></th>
						<th><div>Other<br />Carriers'<br />Mobiles</div></th>
						<th><div>Other<br />Carrier</div></th>
						<th><div><a href='portfolio.php?sort=FirstContractEndDate&order=asc'><img src='../images/ascend.gif' height='12' width='11'height='12' width='11'border='0'></a><br />First Contract<br />End Date<br /><a href='portfolio.php?sort=FirstContractEndDate&order=desc'><img src='../images/descend.gif' height='12' width='11'border='0'></a></div></th>
						<th><div>Wireless<br />BB</div></th>
						<th><div>Industry<br />Type</div></th>
						<th><div>Employees</div></th>
						<th><div>Sites</div></th>
						<th><div><a href='portfolio.php?sort=LastMAECallDate&order=asc'><img src='../images/ascend.gif' height='12' width='11'border='0'></a><br />Last MAE Call Date<br /><a href='portfolio.php?sort=LastMAECallDate&order=desc'><img src='../images/descend.gif' height='12' width='11'border='0'></a></div></th>
					</tr>
				</table>
			</div>
		</td>
	</tr>
<?php

// set database access parameters
$strServer="localhost"; // Server IP Address 'or' Name
$strDatabase="telstrabus"; // Database Name
$strUser="root"; // User ID
$strPwd="tshop"; // Password

$strDB=mysql_connect($strServer,$strUser,$strPwd)or die
('Error connecting to mysql');

$database=mysql_select_db("$strDatabase",$strDB);

$update=$_GET['update'];
$cpid=$_GET['ClickPosID'];

//begin update statement
if ($update=='yes'){

////// UPDATE DTATEMENT HERE //// 
////// UPDATE DTATEMENT HERE //// 

   
       ///// has been removed... 
       /////
       ///// THIS IS THE PART I CANT GET!!!


////// UPDATE DTATEMENT HERE //// 
////// UPDATE DTATEMENT HERE //// 

} // end update statement

else {

// GET URL SORT VARIABLES

$index=$_GET['index']; //the index choice, 0-9 or a-z or blank

$sortval= $_GET['sort']; // sort by value from url
$sortord= $_GET['order']; // sort order value from url

?>



	<tr>
		<td valign='top'>
			<div class='headerColumn'>
				<table cellpadding='0' cellspacing='0' border='0'>

<?php

			// set database access parameters
		        $strServer="localhost"; // Server IP Address 'or' Name
		        $strDatabase="telstrabus"; // Database Name
		        $strUser="root"; // User ID
		        $strPwd="tshop"; // Password

			        
			// connect to database using above parameters
		        $strDB=mysql_connect($strServer,$strUser,$strPwd)or die 
		                     ('Error connecting to mysql..');
		        $database=mysql_select_db("$strDatabase",$strDB);

				$sql="SELECT * FROM portfolios p inner join customers c on p.ClickPosID = c.ClickPosID WHERE c.SalesRep='1384';";

				$result = mysql_db_query($strDatabase, $sql) or die
				("A MySQL error has occurred.<br />Your Query: " . $sql . "<br /> Error: (" . mysql_errno() . ") " . mysql_error());

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

				// Companies table fields
				$CompanyName=$r["CompanyName"];
				$ClickPosID=$r["ClickPosID"];
				$CustClass = $r["CustClass"];
				$TelstraExec = $r["TelstraExec"];
				$ContactTitle = $r["ContactTitle"];
				$ContactFName = $r["ContactFName"];
				$ContactLName = $r["ContactLName"];
				$ContactJobTitle = $r["ContactJobTitle"];
				$ContactPhone = $r["ContactPhone"];
				$ContactFax = $r["ContactFax"];
				$ContactMobile = $r["ContactMobile"];
				$ContactEmail = $r["ContactEmail"];
				$SiteAddress = $r["SiteAddress"];
				$SiteSuburb = $r["SiteSuburb"];
				$SiteState = $r["SiteState"];
				$SitePC = $r["SitePC"];
				$PostalAddress = $r["PostalAddress"];
				$PostalSuburb = $r["PostalSuburb"];
				$PostalState = $r["PostalState"];
				$PostalPC = $r["PostalPC"];
				$CIDN = $r["CIDN"];


				////// START FIELD CHECK - TO MAKE SURE THEY ARE PRESENT OTHERWISE INSERT -missing- TEXT ////////

					 //// this part checks for existing field, and displays --missing-- if not found ... been removed - not necessary
				     //// thats why some fields in the OVERLIB are not in the variables above... they have been set after..

				////// END FIELD CHECK ////////


				echo "<tr><th><div><a href='#$ClickPosID' id='$ClickPosID'></a><a href=\"javascript:;\" onMouseOver=\"return overlib('Contact:  $contact<br><br>Phone:  $ContactPhone<br>Fax:  $ContactFax<br>Mobile:  $ContactMobile<br>E-mail:  $ContactEmail<br><br>Site Address:  $fullSiteAddress<br><br>Postal Address:  $fullPostalAddress<br><br>Customer Class:  $CustClass<br>Telstra Exec:  $TelstraExec<br>CIDN:  $CIDN<br><br>', CAPTION, '-- Customer Information --',CAPTION,'-- Customer Information --',OFFSETY,-15,WRAP,WIDTH,300,SHADOW);\" onMouseOut=\"nd();\"><img src='info.gif'><img src='info.gif'><img src='info.gif'><img src='info.gif'></a>$CompanyName</div></th></tr>

				";	

				}
?>
				</table>
			</div>
		</td>
		<td>
			<div class='body'>
				<table cellpadding='0' cellspacing='0' border='0'>

<?php

$sqlPortfolio="SELECT * FROM portfolios p inner join customers c on p.ClickPosID = c.ClickPosID WHERE c.SalesRep='1384'";

$resultPortfolio = mysql_db_query($strDatabase, $sqlPortfolio) or die
("A MySQL error has occurred.<br />Your Query: " . $sqlPortfolio . "<br /> Error: (" . mysql_errno() . ") " . mysql_error());

// DISPLAY RECORDS IN THE MAIN BODY

while ($rPortfolio = mysql_fetch_array($resultPortfolio))
{

	$ClickPosID=$rPortfolio['ClickPosID'];

	// Portfolios table fields
	$LastCallDate=$rPortfolio["LastCallDate"];
	$TelstraMonthlySpend=$rPortfolio["TelstraMonthlySpend"];
	$OtherTelcoSpend=$rPortfolio["OtherTelcoSpend"];
	$TelstraFixed=$rPortfolio["TelstraFixed"];
	$OtherCarrierFixed=$rPortfolio["OtherCarrierFixed"];
	$PhoneSystem=$rPortfolio["PhoneSystem"];
	$InstallingDealer=$rPortfolio["InstallingDealer"];
	$EstPhoneSysPurchase=$rPortfolio["EstPhoneSysPurchase"];
	$FixedContractType=$rPortfolio["FixedContractType"];
	$FixedContractStartDate=$rPortfolio["FixedContractStartDate"];
	$FixedContractEndDate=$rPortfolio["FixedContractEndDate"];
	$SingleBill=$rPortfolio["SingleBill"];
	$TelstraMobile=$rPortfolio["TelstraMobile"];
	$FirstMobileContractEndDate=$rPortfolio["FirstMobileContractEndDate"];
	$DealerCode=$rPortfolio["DealerCode"];
	$OtherCarriersMobiles=$rPortfolio["OtherCarriersMobiles"];
	$OtherCarrier=$rPortfolio["OtherCarrier"];
	$FirstContractEndDate=$rPortfolio["FirstContractEndDate"];
	$WirelessBB=$rPortfolio["WirelessBB"];
	$IndustryType=$rPortfolio["IndustryType"];
	$Employees=$rPortfolio["Employees"];
	$Sites=$rPortfolio["Sites"];
	$LastMAECallDate=$rPortfolio["LastMAECallDate"];



	//// WHOLE LOT OF CHECKING STUFF AGAIN ... been removed - not necessary



	echo "
					<tr>
							<td><div><input size='10' type='text' name='LastCallDate' value='$LastCallDate'><br />yyyy-mm-dd</div></td>
							<td><div><input size='8' type='text' id='TelstraMonthlySpend' name='TelstraMonthlySpend' value='$TelstraMonthlySpend'></div></td>
							<td><div><input size='8' type='text' id='OtherTelcoSpend' name='OtherTelcoSpend' value='$OtherTelcoSpend'></div></td>
							<td><div><input size='8' type='text' id='TelstraFixed' name='TelstraFixed' value='$TelstraFixed'></div></td>
							<td><div><input size='8' type='text' id='OtherCarrierFixed' name='OtherCarrierFixed' value='$OtherCarrierFixed'></div></td>
							<td><div><input size='15' type='text' id='PhoneSystem' name='PhoneSystem' value='$PhoneSystem'></div></td>
							<td><div><input size='15' type='text' id='InstallingDealer' name='InstallingDealer' value='$InstallingDealer'></div></td>
							<td><div><input size='10' type='text' id='EstPhoneSysPurchase' name='EstPhoneSysPurchase' value='$EstPhoneSysPurchase'><br />yyyy-mm-dd</div></td>
							<td><div><input size='15' type='text' id='FixedContractType' name='FixedContractType' value='$FixedContractType'></div></td>
							<td><div><input size='10' type='text' id='FixedContractStartDate' name='FixedContractStartDate' value='$FixedContractStartDate'><br />yyyy-mm-dd</div></td>
							<td><div><input size='10' type='text' id='FixedContractEndDate' name='FixedContractEndDate' value='$FixedContractEndDate'><br />yyyy-mm-dd</div></td>
							<td><div><select size='1' class='width_320' id='SingleBill' name='SingleBill'><option value=''>Select</option><option value='yes'>Yes</option><option value='no'>No</option> </select></div></td>
						  
							<td><div><input size='10' type='text' id='TelstraMobile' name='TelstraMobile' value='$TelstraMobile'></div></td>
							<td><div><input size='15' type='text' id='FirstMobileContractEndDate' name='FirstMobileContractEndDate' value='$FirstMobileContractEndDate'><br />yyyy-mm-dd</div></td>
							<td><div><input size='10' type='text' id='DealerCode' name='DealerCode' value='$DealerCode'></div></td>
							<td><div><input size='8' type='text' id='OtherCarriersMobiles' name='OtherCarriersMobiles' value='$OtherCarriersMobiles'></div></td>
							<td><div><input size='20' type='text' id='OtherCarrier' name='OtherCarrier' value='$OtherCarrier'></div></td>
							<td><div><input size='15' type='text' id='FirstContractEndDate' name='FirstContractEndDate' value='$FirstContractEndDate'><br />yyyy-mm-dd</div></td>
							<td><div><select size='1' id='WirelessBB' name='WirelessBB'><option value=''>Select</option><option value='yes'>Yes</option><option value='no'>No</option> </select></div></td>

							<td><div><input size='20' type='text' id='IndustryType' name='IndustryType' value='$IndustryType'></div></td>
							<td><div><input size='8' type='text' id='Employees' name='Employees' value='$Employees'></div></td>
							<td><div><input size='8' type='text' id='Sites' name='Sites' value='$Sites'></div></td>
							<td><div><input size='7' type='text' id='LastMAECallDate' name='LastMAECallDate' value='$LastMAECallDate'><br />yyyy-mm-dd</div></td>
				<td><div><input type='submit' name='Save Changes' onclick=\"if(confirm('Are you sure you want to save changes?')){return true}else{return false}\" value='Save' style='background:#00CC66; color:#FFFFFF; font-weight:bold'></div</td>
					</tr>
					";
}

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

}
mysql_close($strDB);

echo "	

	</table>
	</div><span style='align: left;'><a href='index.php'><input type='button' name='Back' value='Back to All Customers' style='background:#bbbbbb; color:#FFFFFF; font-weight:bold;' /></a>    <a href='portfolio.php'>ALL Customers</a>  <a href='?index=0'>'0-9'</a> <a href='?index=A'>A</a> - <a href='?index=B'>B</a> - <a href='?index=C'>C</a> - <a href='?index=D'>D</a> - <a href='?index=E'>E</a> - <a href='?index=F'>F</a> - <a href='?index=G'>G</a> - <a href='?index=H'>H</a> - <a href='?index=I'>I</a> - <a href='?index=J'>J</a> - <a href='?index=K'>K</a> - <a href='?index=L'>L</a> - <a href='?index=M'>M</a> - <a href='?index=N'>N</a> - <a href='?index=O'>O</a> - <a href='?index=P'>P</a> - <a href='?index=Q'>Q</a> - <a href='?index=R'>R</a> - <a href='?index=S'>S</a> - <a href='?index=T'>T</a> - <a href='?index=U'>U</a> - <a href='?index=V'>V</a> - <a href='?index=W'>W</a> - <a href='?index=X'>X</a> - <a href='?index=Y'>Y</a> - <a href='?index=Z'>Z</a> -- <a href='?index=blank'>'Blanks'</a>    </span><a target='_blank' href='http://www.clickpos.net/login/'>Navigate to Click Pos login!</a>
</body>
</html>



<script language=\"javascript\">
paddingLeft = 0;
paddingRight = 0;
paddingTop = 1;
paddingBottom = 1;

ScrollTableRelativeSize(
	document.getElementById(\"scrollTable\"), 
	50, 
	60);

/*ScrollTableAbsoluteSize(
	document.getElementById(\"scrollTable\"), 
	500, 
	550);*/
</script>";



?>

 

......CONTINUED>>>>

 

Link to comment
Share on other sites

 

<<<<<CONTINUED.........

 

As you can probably tell, i have removed as much code that is not needed, lots of error checking, etc.

 

The basic function is a dynamically populated table that has FIXED header and FIXED left column. It works fine, i just CANNOT for the life of me work out how to update the records that may appear on the screen.

 

The complete code is here, although it is probably not necessary, and i've been told by my mate (who is a lot better than me) that it MADE HIS BRAIN SCREAM... lol :-[

 

<?php
include('conn.php');

// check for valid user
if ( verify() )
{
?>

<!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>
    <title>Fixed Headers</title>
    
    <link type="text/css" href="../scripts/scrolltable/Style.css" rel="stylesheet" />
    <script type="text/javascript" src="../scripts/scrolltable/Script.js"></script>
    
    <script type="text/javascript" src="../scripts/overlib/overlib.js"></script>
<script type="text/javascript" src="../scripts/overlib/overlib_shadow.js"></script>
<script type="text/javascript" src="../scripts/overlib/overlib_hideform.js"></script>
<SCRIPT TYPE="text/javascript">
<!--
overlib_pagedefaults(FGCOLOR, '#ffffff', CLOSECOLOR, '#ffffff', BGCOLOR, '#B6A29B', TEXTCOLOR, '#666666', WRAP,VAUTO);
-->
</SCRIPT>
    
    
</head>
<body>
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>

<table class="scrollTable" id="scrollTable" cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td>
			<div class="corner">
				<table cellpadding="0" cellspacing="0" border="0">
					<tr>
						<th><div><a href='portfolio.php?sort=CompanyName&order=asc'><img src='../images/ascend.gif' height='12' width='11'border='0'></a><br />Company Name<br /><a href='portfolio.php?sort=CompanyName&order=desc'><img src='../images/descend.gif' height='12' width='11'border='0'></a></div></th>
					</tr>
				</table>
			</div>
		</td>
		<td>
			<div class="headerRow">
				<table cellpadding="0" cellspacing="0" border="0">
					<tr>
						<th><div><a href='portfolio.php?sort=LastCallDate&order=asc'><img src='../images/ascend.gif' height='12' width='11'border='0'></a><br />Last<br />Call Date<br /><a href='portfolio.php?sort=LastCallDate&order=desc'><img src='../images/descend.gif' height='12' width='11'border='0'></a></div></th>
						<th><div>Telstra<br />Monthly<br />Spend</div></th>
						<th><div>Other<br />Telco<br />Spend</div></th>
						<th><div>Telstra<br />Fixed<br />Lines</div></th>
						<th><div>Other Carrier<br />Fixed Lines</div></th>
						<th><div>Phone<br />System</div></th>
						<th><div>Installing<br />Dealer</div></th>
						<th><div><a href='portfolio.php?sort=EstPhoneSysPurchase&order=asc'><img src='../images/ascend.gif' height='12' width='11'border='0'></a><br />Est. Phone<br />Sys. Purchase<br /><a href='portfolio.php?sort=EstPhoneSysPurchase&order=desc'><img src='../images/descend.gif' height='12' width='11'border='0'></a></div></th>
						<th><div>Fixed<br />Contract<br />Type</div></th>
						<th><div><a href='portfolio.php?sort=FixedContractStartDate&order=asc'><img src='../images/ascend.gif' height='12' width='11'border='0'></a><br />Fixed<br />Contract<br />Start Date<br /><a href='portfolio.php?sort=FixedContractStartDate&order=desc'><img src='../images/descend.gif' height='12' width='11'border='0'></a></div></th>
						<th><div><a href='portfolio.php?sort=FixedContractEndDate&order=asc'><img src='../images/ascend.gif' height='12' width='11'border='0'></a><br />Fixed<br />Contract<br />End Date<br /><a href='portfolio.php?sort=FixedContractEndDate&order=desc'><img src='../images/descend.gif' height='12' width='11'border='0'></a></div></th>
						<th><div>Single<br />Bill</div></th>
						<th><div>Telstra<br />Mobile</div></th>
						<th><div><a href='portfolio.php?sort=FirstMobileContractEndDate&order=asc'><img src='../images/ascend.gif' height='12' width='11'border='0'></a><br />First Mobile<br />Contract<br />End Date<br /><a href='portfolio.php?sort=FirstMobileContractEndDate&order=desc'><img src='../images/descend.gif' height='12' width='11'border='0'></a></div></th>
						<th><div>Dealer<br />Code</div></th>
						<th><div>Other<br />Carriers'<br />Mobiles</div></th>
						<th><div>Other<br />Carrier</div></th>
						<th><div><a href='portfolio.php?sort=FirstContractEndDate&order=asc'><img src='../images/ascend.gif' height='12' width='11'height='12' width='11'border='0'></a><br />First Contract<br />End Date<br /><a href='portfolio.php?sort=FirstContractEndDate&order=desc'><img src='../images/descend.gif' height='12' width='11'border='0'></a></div></th>
						<th><div>Wireless<br />BB</div></th>
						<th><div>Industry<br />Type</div></th>
						<th><div>Employees</div></th>
						<th><div>Sites</div></th>
						<th><div><a href='portfolio.php?sort=LastMAECallDate&order=asc'><img src='../images/ascend.gif' height='12' width='11'border='0'></a><br />Last MAE Call Date<br /><a href='portfolio.php?sort=LastMAECallDate&order=desc'><img src='../images/descend.gif' height='12' width='11'border='0'></a></div></th>
					</tr>
				</table>
			</div>
		</td>
	</tr>
<?php

$strDB=mysql_connect($strServer,$strUser,$strPwd)or die
('Error connecting to mysql');

$database=mysql_select_db("$strDatabase",$strDB);

$update=$_GET['update'];
$cpid=$_GET['ClickPosID'];

//begin update statement
if ($update=='yes'){

if ($LastCallDate=='') {
	$LastCallDate=('0000-00-00');
}
else {
	$LastCallDate=$_POST["LastCallDate"];
}

$ClickPosID=$_POST['ClickPosID'];
$TelstraMonthlySpend=$_POST["TelstraMonthlySpend"];
$OtherTelcoSpend=$_POST["OtherTelcoSpend"];
$TelstraFixed=$_POST["TelstraFixed"];
$OtherCarrierFixed=$_POST["OtherCarrierFixed"];
$PhoneSystem=$_POST["PhoneSystem"];
$InstallingDealer=$_POST["InstallingDealer"];
$EstPhoneSysPurchase=$_POST["EstPhoneSysPurchase"];
$FixedContractType=$_POST["FixedContractType"];
$FixedContractStartDate=$_POST["FixedContractStartDate"];
$FixedContractEndDate=$_POST["FixedContractEndDate"];
$SingleBill=$_POST["SingleBill"];
$TelstraMobile=$_POST["TelstraMobile"];
$FirstMobileContractEndDate=$_POST["FirstMobileContractEndDate"];
$DealerCode=$_POST["DealerCode"];
$OtherCarriersMobiles=$_POST["OtherCarriersMobiles"];
$OtherCarrier=$_POST["OtherCarrier"];
$FirstContractEndDate=$_POST["FirstContractEndDate"];
$WirelessBB=$_POST["WirelessBB"];
$IndustryType=$_POST["IndustryType"];
$Employees=$_POST["Employees"];
$Sites=$_POST["Sites"];
$LastMAECallDate=$_POST["LastMAECallDate"];


$sql="UPDATE portfolios SET LastCallDate='$LastCallDate', TelstraMonthlySpend=$TelstraMonthlySpend, OtherTelcoSpend=$OtherTelcoSpend, TelstraFixed=$TelstraFixed, OtherCarrierFixed=$OtherCarrierFixed, PhoneSystem='$PhoneSystem', InstallingDealer='$InstallingDealer', EstPhoneSysPurchase='$EstPhoneSysPurchase', FixedContractType='$FixedContractType', FixedContractStartDate='$FixedContractStartDate', FixedContractEndDate='$FixedContractEndDate', SingleBill='$SingleBill', TelstraMobile=$TelstraMobile, FirstMobileContractEndDate='$FirstMobileContractEndDate', DealerCode='$DealerCode', OtherCarriersMobiles=$OtherCarriersMobiles, OtherCarrier='$OtherCarrier', FirstContractEndDate='$FirstContractEndDate', WirelessBB='$WirelessBB', IndustryType='$IndustryType', Employees=$Employees, Sites=$Sites, LastMAECallDate='$LastMAECallDate' WHERE portfolios.ClickPosID = $cpid;";

$result = mysql_db_query($strDatabase, $sql) or die
("A MySQL error has occurred.<br />Your Query: " . $sql . "<br /> Error: (" . mysql_errno() . ") " . mysql_error());


} // end update statement

else {

// GET URL SORT VARIABLES

$index=$_GET['index']; //the index choice, 0-9 or a-z or blank
$sortval= $_GET['sort'];
$sortord= $_GET['order'];


if ($index=='blank') {
	$indexquery=(' c.CompanyName =\' \' AND ');
}

else {
	$indexquery=(' c.CompanyName LIKE \''.$index.'%\' AND ');
}

if ($index=='0'){
	$indexquery=(' c.CompanyName LIKE \'0%\' OR c.CompanyName LIKE \'1%\' OR c.CompanyName LIKE \'2%\' OR c.CompanyName LIKE \'3%\' OR c.CompanyName LIKE \'4%\' OR c.CompanyName LIKE \'5%\' OR c.CompanyName LIKE \'6%\' OR c.CompanyName LIKE \'7%\' OR c.CompanyName LIKE \'8%\' OR c.CompanyName LIKE \'9%\' AND ');
}

if ($index=='all'){
	$indexquery=('');
}



if (!$sortval)	{
	$sortquery=(' ORDER BY CompanyName Asc');
}

else {

	// Colour the sort by column grey

	if ($sortval=='CompanyName') {
		$sortCompanyName= ('bgcolor=#dddddd');
	}


	if (!$sortval=='') {
		$sortquery= (' ORDER BY '. $sortval . ' ' . $sortord);
	}
	else {
		$sortquery= ('');
	}

}
?>



	<tr>
		<td valign='top'>
			<div class='headerColumn'>
				<table cellpadding='0' cellspacing='0' border='0'>

<?php

				// set database access parameters
			        $strServer="localhost"; // Server IP Address 'or' Name
			        $strDatabase="telstrabus"; // Database Name
			        $strUser="root"; // User ID
			        $strPwd="tshop"; // Password

			        
				// connect to database using above parameters
			        $strDB=mysql_connect($strServer,$strUser,$strPwd)or die 
			                     ('Error connecting to mysql..');
			        $database=mysql_select_db("$strDatabase",$strDB);

				$sql="SELECT * FROM portfolios p inner join customers c on p.ClickPosID = c.ClickPosID WHERE$indexquery c.SalesRep=$who$sortquery;";

				$result = mysql_db_query($strDatabase, $sql) or die
				("A MySQL error has occurred.<br />Your Query: " . $sql . "<br /> Error: (" . mysql_errno() . ") " . mysql_error());

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

				// Companies table fields
				$CompanyName=$r["CompanyName"];
				$ClickPosID=$r["ClickPosID"];
				$CustClass = $r["CustClass"];
				$TelstraExec = $r["TelstraExec"];
				$ContactTitle = $r["ContactTitle"];
				$ContactFName = $r["ContactFName"];
				$ContactLName = $r["ContactLName"];
				$ContactJobTitle = $r["ContactJobTitle"];
				$ContactPhone = $r["ContactPhone"];
				$ContactFax = $r["ContactFax"];
				$ContactMobile = $r["ContactMobile"];
				$ContactEmail = $r["ContactEmail"];
				$SiteAddress = $r["SiteAddress"];
				$SiteSuburb = $r["SiteSuburb"];
				$SiteState = $r["SiteState"];
				$SitePC = $r["SitePC"];
				$PostalAddress = $r["PostalAddress"];
				$PostalSuburb = $r["PostalSuburb"];
				$PostalState = $r["PostalState"];
				$PostalPC = $r["PostalPC"];
				$CIDN = $r["CIDN"];


				////// START FIELD CHECK - TO MAKE SURE THEY ARE PRESENT OTHERWISE INSERT -missing- TEXT ////////

					if ($CustClass==''){
						$CustClass=('--missing--');
					}else {
						$CustClass=$CustClass;
					}

					if ($TelstraExec==''){
						$TelstraExec=('--missing--');
					}else {
						$TelstraExec=$TelstraExec;
					}

					if ($ContactTitle==''){
						if ($ContactFName==''){
							if ($ContactLName==''){
								$contact=('--missing--');
							}
						}
					}
					else {
						$contact=($ContactTitle.' '.$ContactFName.' '.$ContactLName);
					}

					if ($ContactJobTitle==''){
						$ContactJobTitle=('--missing--');
					}else {
						$ContactJobTitle=$ContactJobTitle;
					}

					if ($ContactPhone=='0'){
						$ContactPhone=('--missing--');
					}else {
						$ContactPhone=$ContactPhone;
					}

					if ($ContactFax=='0'){
						$ContactFax=('--missing--');
					}else {
						$ContactFax=$ContactFax;
					}

					if ($ContactMobile=='0'){
						$ContactMobile=('--missing--');
					}else {
						$ContactMobile=$ContactMobile;
					}

					if ($ContactEmail==''){
						$ContactEmail=('--missing--');
					}else {
						$ContactEmail=$ContactEmail;
					}

					if ($SiteAddress==''){
						if ($SiteSuburb==''){
							$fullSiteAddress=('--missing--');
						}
					}
					else {
						$fullSiteAddress=($SiteAddress.',<br>'.$SiteSuburb.'  '.$SiteState.' '.$SitePC);
					}


					if ($PostalAddress==''){
						if ($PostalSuburb==''){
							$fullPostalAddress=('--missing--');
						}
					}
					else {
						$fullPostalAddress=($PostalAddress.',<br>'.$PostalSuburb.'  '.$PostalState.' '.$PostalPC);
					}

					if ($CIDN=='0'){
						$CIDN=('--missing--');
					}else {
						$CIDN=$CIDN;
					}


				////// END FIELD CHECK ////////


				echo "<tr><th><div><a href='#$ClickPosID' id='$ClickPosID'></a><a href=\"javascript:;\" onMouseOver=\"return overlib('Contact:  $contact<br><br>Phone:  $ContactPhone<br>Fax:  $ContactFax<br>Mobile:  $ContactMobile<br>E-mail:  $ContactEmail<br><br>Site Address:  $fullSiteAddress<br><br>Postal Address:  $fullPostalAddress<br><br>Customer Class:  $CustClass<br>Telstra Exec:  $TelstraExec<br>CIDN:  $CIDN<br><br>', CAPTION, '-- Customer Information --',CAPTION,'-- Customer Information --',OFFSETY,-15,WRAP,WIDTH,300,SHADOW);\" onMouseOut=\"nd();\"><img src='info.gif'><img src='info.gif'><img src='info.gif'><img src='info.gif'></a>$CompanyName</div></th></tr>

				";	

				}
?>
				</table>
			</div>
		</td>
		<td>
			<div class='body'>
				<table cellpadding='0' cellspacing='0' border='0'>

<?php

$sqlPortfolio="SELECT * FROM portfolios p inner join customers c on p.ClickPosID = c.ClickPosID WHERE$indexquery c.SalesRep=$who$sortquery";

$resultPortfolio = mysql_db_query($strDatabase, $sqlPortfolio) or die
("A MySQL error has occurred.<br />Your Query: " . $sqlPortfolio . "<br /> Error: (" . mysql_errno() . ") " . mysql_error());

// Count records displayed for this SalesRep

while ($rPortfolio = mysql_fetch_array($resultPortfolio))
{

	$ClickPosID=$rPortfolio['ClickPosID'];


	$yesWirelessBB=('');
	$noWirelessBB=('');

	$yesSingleBill=('');
	$noSingleBill=('');

	// Portfolios table fields
	$LastCallDate=$rPortfolio["LastCallDate"];
	$TelstraMonthlySpend=$rPortfolio["TelstraMonthlySpend"];
	$OtherTelcoSpend=$rPortfolio["OtherTelcoSpend"];
	$TelstraFixed=$rPortfolio["TelstraFixed"];
	$OtherCarrierFixed=$rPortfolio["OtherCarrierFixed"];
	$PhoneSystem=$rPortfolio["PhoneSystem"];
	$InstallingDealer=$rPortfolio["InstallingDealer"];
	$EstPhoneSysPurchase=$rPortfolio["EstPhoneSysPurchase"];
	$FixedContractType=$rPortfolio["FixedContractType"];
	$FixedContractStartDate=$rPortfolio["FixedContractStartDate"];
	$FixedContractEndDate=$rPortfolio["FixedContractEndDate"];
	$SingleBill=$rPortfolio["SingleBill"];
	$TelstraMobile=$rPortfolio["TelstraMobile"];
	$FirstMobileContractEndDate=$rPortfolio["FirstMobileContractEndDate"];
	$DealerCode=$rPortfolio["DealerCode"];
	$OtherCarriersMobiles=$rPortfolio["OtherCarriersMobiles"];
	$OtherCarrier=$rPortfolio["OtherCarrier"];
	$FirstContractEndDate=$rPortfolio["FirstContractEndDate"];
	$WirelessBB=$rPortfolio["WirelessBB"];
	$IndustryType=$rPortfolio["IndustryType"];
	$Employees=$rPortfolio["Employees"];
	$Sites=$rPortfolio["Sites"];
	$LastMAECallDate=$rPortfolio["LastMAECallDate"];


	$color = ($i % 2) ? '#FFFFFF' : '#CCCCCC';



	$LastCallDate=strtotime($LastCallDate);


	// Get Todays Date and make UNIX Timestamp
	$today = strtotime(date('Y-m-d'));

	// Calculate 1 month ago from today
	$one_month = 31 * 24 * 60 * 60;
	$one_month_ago = ($today - $one_month);

	// Calculate 2 months ago from today
	$two_month = 2 * 31 * 24 * 60 * 60;
	$two_month_ago = ($today - $two_month);

	// Check if the LastCallDate is a 1, 2 or more months ago and if so colour Green, Yellow or Red respectively
	if (!$LastCallDate) {
		$LastCallDateinputcolour=(' style="background-color:#ccccff"');
	}
	else {
		if ($LastCallDate >= $one_month_ago) {
			$LastCallDateinputcolour=(' style="background-color:#ccffcc"');
		}

		if ($LastCallDate < $one_month_ago) {
			if ($LastCallDate >= $two_month_ago) {
				$LastCallDateinputcolour=(' style="background-color:#ffffcc"');
			}
		}

		if ($LastCallDate < $two_month_ago) {
			$LastCallDateinputcolour=(' style="background-color:red"');
		}
	}

	// Convert UNIX Timestamp back to yyyy-mm-dd date
	if (!$LastCallDate=='') {
		$LastCallDate=(date('Y-m-d', (int) $LastCallDate));
	}


	// Check if the LastMAECallDate is a 1, 2 or more months ago and if so colour Green, Yellow or Red respectively


	if ($LastMAECallDate=='0000-00-00'){
		$LastMAECallDate='';
	}
	else {
		$LastMAECallDate=strtotime($LastMAECallDate);
	}

	if (!$LastMAECallDate) {
		$LastMAECallDateinputcolour=(' style="background-color:#ccccff"');
	}
	else {
		if ($LastMAECallDate >= $one_month_ago) {
			$LastMAECallDateinputcolour=(' style="background-color:#ccffcc"');
		}

		if ($LastMAECallDate < $one_month_ago) {
			if ($LastMAECallDate >= $two_month_ago) {
				$LastMAECallDateinputcolour=(' style="background-color:#ffffcc"');
			}
		}

		if ($LastMAECallDate < $two_month_ago) {
			$LastMAECallDateinputcolour=(' style="background-color:red"');
		}
	}

	// Convert UNIX Timestamp back to yyyy-mm-dd date
	if (!$LastMAECallDate=='') {
		$LastMAECallDate=(date('Y-m-d', (int) $LastMAECallDate));
	}


	echo "
					<tr>
							<td><div><input$LastCallDateinputcolour size='10' type='text' name='LastCallDate' value='$LastCallDate'><br />yyyy-mm-dd</div></td>
							<td><div><input size='8' type='text' id='TelstraMonthlySpend' name='TelstraMonthlySpend' value='$TelstraMonthlySpend'></div></td>
							<td><div><input size='8' type='text' id='OtherTelcoSpend' name='OtherTelcoSpend' value='$OtherTelcoSpend'></div></td>
							<td><div><input size='8' type='text' id='TelstraFixed' name='TelstraFixed' value='$TelstraFixed'></div></td>
							<td><div><input size='8' type='text' id='OtherCarrierFixed' name='OtherCarrierFixed' value='$OtherCarrierFixed'></div></td>
							<td><div><input size='15' type='text' id='PhoneSystem' name='PhoneSystem' value='$PhoneSystem'></div></td>
							<td><div><input size='15' type='text' id='InstallingDealer' name='InstallingDealer' value='$InstallingDealer'></div></td>
							<td><div><input size='10' type='text' id='EstPhoneSysPurchase' name='EstPhoneSysPurchase' value='$EstPhoneSysPurchase'><br />yyyy-mm-dd</div></td>
							<td><div><input size='15' type='text' id='FixedContractType' name='FixedContractType' value='$FixedContractType'></div></td>
							<td><div><input size='10' type='text' id='FixedContractStartDate' name='FixedContractStartDate' value='$FixedContractStartDate'><br />yyyy-mm-dd</div></td>
							<td><div><input size='10' type='text' id='FixedContractEndDate' name='FixedContractEndDate' value='$FixedContractEndDate'><br />yyyy-mm-dd</div></td>
							";

						if ($SingleBill=='yes'){
							$yesSingleBill=('selected');
						}
						if ($SingleBill=='no'){
							$noSingleBill=('selected');
						}
						if ($SingleBill==''){
							$noselectSingleBill=('selected');
						}

					echo "	<td><div><select size='1' class='width_320' id='SingleBill' name='SingleBill'>
							<option value='' $noselectSingleBill>Select</option>
							<option value='yes' $yesSingleBill>Yes</option>
							<option value='no' $noSingleBill>No</option>
						  </select></div></td>
						  
							<td><div><input size='10' type='text' id='TelstraMobile' name='TelstraMobile' value='$TelstraMobile'></div></td>
							<td><div><input size='15' type='text' id='FirstMobileContractEndDate' name='FirstMobileContractEndDate' value='$FirstMobileContractEndDate'><br />yyyy-mm-dd</div></td>
							<td><div><input size='10' type='text' id='DealerCode' name='DealerCode' value='$DealerCode'></div></td>
							<td><div><input size='8' type='text' id='OtherCarriersMobiles' name='OtherCarriersMobiles' value='$OtherCarriersMobiles'></div></td>
							<td><div><input size='20' type='text' id='OtherCarrier' name='OtherCarrier' value='$OtherCarrier'></div></td>
							<td><div><input size='15' type='text' id='FirstContractEndDate' name='FirstContractEndDate' value='$FirstContractEndDate'><br />yyyy-mm-dd</div></td>
							";

						if ($WirelessBB=='yes'){
							$yesWirelessBB=('selected');
						}
						if ($WirelessBB=='no'){
							$noWirelessBB=('selected');
						}
						if ($WirelessBB==''){
							$noselectWirelessBB=('selected');
						}

					echo "	<td><div><select size='1' id='WirelessBB' name='WirelessBB'>
							<option value='' $noselectWirelessBB>Select</option>
							<option value='yes' $yesWirelessBB>Yes</option>
							<option value='no' $noWirelessBB>No</option>
						  </select></div></td>

							<td><div><input size='20' type='text' id='IndustryType' name='IndustryType' value='$IndustryType'></div></td>
							<td><div><input size='8' type='text' id='Employees' name='Employees' value='$Employees'></div></td>
							<td><div><input size='8' type='text' id='Sites' name='Sites' value='$Sites'></div></td>
							<td><div><input$LastMAECallDateinputcolour size='7' type='text' id='LastMAECallDate' name='LastMAECallDate' value='$LastMAECallDate'><br />yyyy-mm-dd</div></td>
				<td><div> </div></td>
					</tr>
					";
}

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

	$i++;
}
}
mysql_close($strDB);

echo "	

	</table>
	</div><span style='align: left;'><a href='index.php'><input type='button' name='Back' value='Back to All Customers' style='background:#bbbbbb; color:#FFFFFF; font-weight:bold;' /></a>    <a href='portfolio.php'>ALL Customers</a>  <a href='?index=0'>'0-9'</a> <a href='?index=A'>A</a> - <a href='?index=B'>B</a> - <a href='?index=C'>C</a> - <a href='?index=D'>D</a> - <a href='?index=E'>E</a> - <a href='?index=F'>F</a> - <a href='?index=G'>G</a> - <a href='?index=H'>H</a> - <a href='?index=I'>I</a> - <a href='?index=J'>J</a> - <a href='?index=K'>K</a> - <a href='?index=L'>L</a> - <a href='?index=M'>M</a> - <a href='?index=N'>N</a> - <a href='?index=O'>O</a> - <a href='?index=P'>P</a> - <a href='?index=Q'>Q</a> - <a href='?index=R'>R</a> - <a href='?index=S'>S</a> - <a href='?index=T'>T</a> - <a href='?index=U'>U</a> - <a href='?index=V'>V</a> - <a href='?index=W'>W</a> - <a href='?index=X'>X</a> - <a href='?index=Y'>Y</a> - <a href='?index=Z'>Z</a> -- <a href='?index=blank'>'Blanks'</a>    </span><a target='_blank' href='http://www.clickpos.net/login/'>Navigate to Click Pos login!</a>
</body>

<input type='submit' name='Save Changes' onclick=\"if(confirm('Are you sure you want to save changes?')){return true}else{return false}\" value='Save' style='background:#00CC66; color:#FFFFFF; font-weight:bold'>

</html>



<script language=\"javascript\">
paddingLeft = 0;
paddingRight = 0;
paddingTop = 1;
paddingBottom = 1;

ScrollTableRelativeSize(
	document.getElementById(\"scrollTable\"), 
	50, 
	60);

/*ScrollTableAbsoluteSize(
	document.getElementById(\"scrollTable\"), 
	500, 
	550);*/
</script>";



?>

 

 

I can't work out where i would put the FORM tags and be able to still pass the correct and necessary information to the UPDATE statement...

 

I don't often ask for this much help, except this is just melting my brain, and I just NEED to get past it... Please! ;D

 

Here is a demo of the actual FUNCTION of the scrolling table... http://www.cubido.at/Portals/7/docs/Blog/Karin/HTML%20and%20Javascript/ResizeColumns/Table.htm

 

You can download the java files there too if you like...

 

Thankyou anyone who can help, please, i will be checking every 5 mins.

 

Regards,

 

Michael Gallagher - not that incompetent, just stuck!

 

Link to comment
Share on other sites

<?php
		$sql2=mysql_query("SELECT * FROM test_mysql WHERE id='$id'");
			$row=mysql_fetch_array($sql2);

			$name=$row['name'];
			$lastname=$row['lastname'];
			$email=$row['email'];

 

Your code reads the record you want to update

reads the current values into vars with same names as you used for posted vars thus overwriting

writes back the current values to the record

result - it stays exctly the same.

Link to comment
Share on other sites

The output i have at the moment, after the server has parsed everything, and in the form of only HTML works fine structurally.

 

The most important part is the position of the <form .. > and </form> tags, and the data that is being passed from the <input..> tags and the naming conventions that pass the data through the form..

 

So, thus far I have a working fixed, scrolling table, outputting the data I want, with proper naming conventions.

 

I cannot move the <form..> tags because the table breaks; I have tried several locations, and being outside almost all the code is the only way it works without breaking the scrollable table.

 

And as for the update statement:

 

/* set database access parameters */
DEFINE ("DB_USER","root");
DEFINE ("DB_HOST","localhost");
DEFINE ("DB_PASSWORD","password");
DEFINE ("DB_NAME","database");

/* establish connection */
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

/* the query with placeholders */
$sql = "UPDATE portfolios SET LastCallDate=?, TelstraMonthlySpend=?, OtherTelcoSpend=?, TelstraFixed=?, OtherCarrierFixed=?, PhoneSystem=?, InstallingDealer=?, EstPhoneSysPurchase=?, FixedContractType=?, FixedContractStartDate=?, FixedContractEndDate=?, SingleBill=?, TelstraMobile=?, FirstMobileContractEndDate=?, DealerCode=?, OtherCarriersMobiles=?, OtherCarrier=?, FirstContractEndDate=?, WirelessBB=?, IndustryType=?, Employees=?, Sites=?, LastMAECallDate=? WHERE ClickPosID=?";

/* prepare the query */
if ($stmt=$mysqli->prepare($sql)) {
    
    /* bind variable names to placeholders */
    $stmt->bind_param('ssssssssssssssssssssssss',$LastCallDate,$TelstraMonthlySpend,$OtherTelcoSpend,$TelstraFi  xed,$OtherCarrierFixed,$PhoneSystem,$InstallingDealer,$EstPhoneSysPurchase,$FixedContractType,$Fixed  ContractStartDate,$FixedContractEndDate,$SingleBill,$TelstraMobile,$FirstMobileContractEndDate,$Deal  erCode,$OtherCarriersMobiles,$OtherCarrier,$FirstContractEndDate,$WirelessBB,$IndustryType,$Employee  s,$Sites,$LastMAECallDate,$ClickPosID);
    
    foreach ( $_POST['portfolio'] as $id => $details ) { 
    
        /* assign values to bound variables */
        $ClickPosID = $id;
        $LastCallDate=$details['LastCallDate'];
        $TelstraMonthlySpend=$details['TelstraMonthlySpend'];
        $OtherTelcoSpend=$details['OtherTelcoSpend'];
        $TelstraFixed=$details['TelstraFixed'];
        $OtherCarrierFixed=$details['OtherCarrierFixed'];
        $PhoneSystem=$details['PhoneSystem'];
        $InstallingDealer=$details['InstallingDealer'];
        $EstPhoneSysPurchase=$details['EstPhoneSysPurchase'];
        $FixedContractType=$details['FixedContractType'];
        $FixedContractStartDate=$details['FixedContractStartDate'];
        $FixedContractEndDate=$details['FixedContractEndDate'];
        $SingleBill=$details['SingleBill'];
        $TelstraMobile=$details['TelstraMobile'];
        $FirstMobileContractEndDate=$details['FirstMobileContractEndDate'];
        $DealerCode=$details['DealerCode'];
        $OtherCarriersMobiles=$details['OtherCarriersMobiles'];
        $OtherCarrier=$details['OtherCarrier'];
        $FirstContractEndDate=$details['FirstContractEndDate'];
        $WirelessBB=$details['WirelessBB'];
        $IndustryType=$details['IndustryType'];
        $Employees=$details['Employees'];
        $Sites=$details['Sites'];
        $LastMAECallDate=$details['LastMAECallDate'];

        
        /* execute query then loop around again to rinse and repeat */
        $stmt->execute();
    } 
    $stmt->close();
} 

 

 

Is this at all right? It executes, grabs ClickPosID ok, but no other fields.. they just aren't being taken from POST.

 

My <input..> fields look like :

 

<input size='10' type='text' id='LastCallDate'  name="portfolio[$ClickPosID]['LastCallDate']" value='$LastCallDate'> 

 

 

..and after drawing current value from the Database, and outputting in HTML, they look like:

 

<input size='10' type='text' id='LastCallDate' name="portfolio[5632]['LastCallDate']" value='2007-11-03'>

 

 

 

But when I run the query, and have

echo "SQL-$sql <br> ClickPosID-$ClickPosID <br> ID-$id<br><br><br>"; before the $stmt->execute();

i get:

 

SQL-UPDATE portfolios SET LastCallDate=?, TelstraMonthlySpend=?, OtherTelcoSpend=?, TelstraFixed=?, OtherCarrierFixed=?, PhoneSystem=?, InstallingDealer=?, EstPhoneSysPurchase=?, FixedContractType=?, FixedContractStartDate=?, FixedContractEndDate=?, SingleBill=?, TelstraMobile=?, FirstMobileContractEndDate=?, DealerCode=?, OtherCarriersMobiles=?, OtherCarrier=?, FirstContractEndDate=?, WirelessBB=?, IndustryType=?, Employees=?, Sites=?, LastMAECallDate=? WHERE ClickPosID=?

ClickPosID-5632

ID-5632

 

 

SQL-UPDATE portfolios SET LastCallDate=?, TelstraMonthlySpend=?, OtherTelcoSpend=?, TelstraFixed=?, OtherCarrierFixed=?, PhoneSystem=?, InstallingDealer=?, EstPhoneSysPurchase=?, FixedContractType=?, FixedContractStartDate=?, FixedContractEndDate=?, SingleBill=?, TelstraMobile=?, FirstMobileContractEndDate=?, DealerCode=?, OtherCarriersMobiles=?, OtherCarrier=?, FirstContractEndDate=?, WirelessBB=?, IndustryType=?, Employees=?, Sites=?, LastMAECallDate=? WHERE ClickPosID=?

ClickPosID-3651

ID-3651

 

 

etc etc..

 

I can't really see what is happening, could you please explain the update process?

 

I really appreciate your help on this.

 

Regards,

 

Mick

 

EDIT: fixed structure of post, was all wierd..

Link to comment
Share on other sites

So, there was no progress on this.

 

Still have no solution.

 

Looks like it was more of a challenge for people, as well as myself, than I thought.

 

I am currently looking at using a richer development tool, possibly something with flash so I can get this working..

 

Still, I would love to hear anyones solution to this problem, I didn't think updating multiple rows was this complex.

 

Cheers

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.