stylin Posted January 16, 2007 Share Posted January 16, 2007 I am trying to add all cells vertically to tally up in a total cell down the bottom. I am trying to create an array that identifys each cell for starters. The only problem is it only names the identifys the first cell and does not loop for each consecutive cell entered into from the user. The code is as follows:[code]<?php require_once('Connections/example.php'); ?><?phpfunction GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}$editFormAction = $_SERVER['PHP_SELF'];if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);}if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "order_form")) { $insertSQL = sprintf("INSERT INTO daily (submitted_by, day_name, franchisee_code, mail_drops, phone_cavas, emails_sent, appointments_made, presentations, bills_analysed, orders, deliveries, referrals, weekending_date, md_total, pc_total, es_total, a_total, p_total, ba_total, o_total, d_tatal, r_total) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['submitted_by'], "text"), GetSQLValueString($_POST['day'], "text"), GetSQLValueString($_POST['franchisee_code'], "text"), GetSQLValueString($_POST['mail_drop'], "text"), GetSQLValueString($_POST['phone_canvas'], "int"), GetSQLValueString($_POST['emails_sent'], "int"), GetSQLValueString($_POST['appointments_made'], "text"), GetSQLValueString($_POST['presentations'], "text"), GetSQLValueString($_POST['bills_analysed'], "text"), GetSQLValueString($_POST['orders'], "text"), GetSQLValueString($_POST['deliveries'], "text"), GetSQLValueString($_POST['referrals'], "text"), GetSQLValueString($_POST['weekending_date'], "date"), GetSQLValueString($_POST['md_total'], "text"), GetSQLValueString($_POST['pc_total'], "text"), GetSQLValueString($_POST['es_total'], "text"), GetSQLValueString($_POST['a_total'], "text"), GetSQLValueString($_POST['p_total'], "text"), GetSQLValueString($_POST['ba_total'], "text"), GetSQLValueString($_POST['o_total'], "text"), GetSQLValueString($_POST['d_total'], "text"), GetSQLValueString($_POST['r_total'], "text")); mysql_select_db($database_voip, $voip); $Result1 = mysql_query($insertSQL, $voip) or die(mysql_error()); $insertGoTo = "view_activity.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo));}$colname_franchisee = "1";if (isset($_GET['franchisee_id'])) { $colname_franchisee = (get_magic_quotes_gpc()) ? $_GET['franchisee_id'] : addslashes($_GET['franchisee_id']);}mysql_select_db($database_voip, $voip);$query_franchisee = sprintf("SELECT * FROM franchisee WHERE franchisee_id = %s", $colname_franchisee);$franchisee = mysql_query($query_franchisee, $voip) or die(mysql_error());$row_franchisee = mysql_fetch_assoc($franchisee);$totalRows_franchisee = mysql_num_rows($franchisee);mysql_select_db($database_voip, $voip);$query_days = "SELECT * FROM days";$days = mysql_query($query_days, $voip) or die(mysql_error());$row_days = mysql_fetch_assoc($days);$totalRows_days = mysql_num_rows($days);mysql_select_db($database_voip, $voip);$query_daily = "SELECT * FROM daily";$daily = mysql_query($query_daily, $voip) or die(mysql_error());$row_daily = mysql_fetch_assoc($daily);$totalRows_daily = mysql_num_rows($daily);mysql_select_db($database_voip, $voip);$query_weekending = "SELECT * FROM weekending";$weekending = mysql_query($query_weekending, $voip) or die(mysql_error());$row_weekending = mysql_fetch_assoc($weekending);$totalRows_weekending = mysql_num_rows($weekending);?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head> <title>Order Form</title> <meta name="Description" content="Daily Sales Report"><link href="ring.css" rel="stylesheet" type="text/css" /><style type="text/css"><!--body { background-color: #1B1718;}--></style><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title> </head><body> <table width="748" align="center" cellpadding="5" cellspacing="1" class="tablecontent"><tr><td colspan="2"><h1 class="yellow">daily Activity Report </h1><p align="center">This must be completed every day by allfranchisees and those who work for them in sales</p><p></p></td></tr> <form action="<?php echo $editFormAction; ?>" method="POST" name="order_form"><tr><td width="154"> Franchisee code:<td width="569"><input name="franchisee_code" type="text" id="franchisee_code" value="<?php echo $row_franchisee['franchisee_code']; ?>"></td></tr><tr><td>Form Completed by:</td><td><input name="submitted_by" type="text" value="<?php echo $row_franchisee['franchisee_name']; ?>"></td></tr><tr><td>Weekending Sunday:</td><td><input name="weekending_date" type="text" value=""> </td></tr><tr><td colspan="2"><hr></td></tr> </td></tr> <tr><td height="119" colspan="2"><table width="100%" border="1" bordercolor="#FFFF33" class="tablecontent"> <tr> <td width="10%">Days</td> <td width="11%">Mail Drops</td> <Td width="11%">Phone Canvas</td> <Td width="11%">Prospect Emails Sent</td> <Td width="11%">Appointments Made</td> <Td width="11%">Presentations</td> <Td width="11%">Bills Analysed</td> <Td width="11%">Orders</td> <Td width="11%">Deliveries</td> <Td width="11%">Referrals</td> </tr> <?php$sql = "SELECT id FROM daily";$result = mysql_query($sql);$cnt = 1;while ($row = mysql_fetch_array ($result)) { if (!isset($cnt)) { $cnt =0;} $cnt++;} ?> <?php do { ?> <tr> <td> <input name="day<?php echo $cnt; ?>" value="<?php echo $row_days['day_name']; ?>"> </td> <td> <input name="mail_drop<?php echo $cnt; ?>" type="text" id="mail_drop" value="" size="10"></td> <td><input name="phone_canvas<?php echo $cnt; ?>" type="text" id="phone_canvas" size="10" value=""> </td> <td><input name="emails_sent<?php echo $cnt; ?>" type="text" id="emails_sent" size="10" value=""></td> <td><input name="appointments_made<?php echo $cnt; ?>" type="text" id="appointments_made" size="10" value=""></td> <td><input name="presentations<?php echo $cnt; ?>" type="text" id="presentations" size="10" value=""></td> <td><input name="bills_analysed<?php echo $cnt; ?>" type="text" id="bills_analysed" size="10" value=""></td> <td><input name="orders<?php echo $cnt; ?>" type="text" id="orders" size="10" value=""></td> <td><input name="deliveries<?php echo $cnt; ?>" type="text" id="deliveries" size="10" value=""></td> <td><input name="referrals<?php echo $cnt; ?>" type="text" id="referrals" size="10" value=""></td> </tr> <?php } while ($row_days = mysql_fetch_assoc($days)); ?> <tr><td class="colourhead">Weeks Total:</td><td><span class="order"> <input name="md_total" type="text" value="" size="10"></span></td><td><input name="pc_total" type="text" value="" size="10"></td><td><input name="es_total" type="text" size="10"></td><td><input name="a_total" type="text" size="10"></td><td><input name="p_total" type="text" size="10"></td><td><input name="ba_total" type="text" size="10"></td><td><input name="o_total" type="text" size="10"></td><td><input name="d_total" type="text" size="10"></td><td><input name="r_total" type="text" size="10"></td></tr> </table></td></tr><tr><td><input name="Submit" type="submit"><input type="hidden" name="MM_insert" value="order_form"></form> </td></tr></table></body></html><?phpmysql_free_result($franchisee);mysql_free_result($days);mysql_free_result($daily);mysql_free_result($weekending);?>[/code] Link to comment https://forums.phpfreaks.com/topic/34391-adding-cells-inputed-by-user/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.