Jump to content

Recommended Posts

I have a page that allows users to input data into a field and click submit. The page then refreshes and is supposed to display the new data above the input field. Pic 1 is what the page should look like after one entry(east cost sheet metal). Pic 2 is what the page should look like after several entries(east cost sheet metal). Pic 3 is what the page actually looks like after one entry(east cost sheet metal). Notice that the date doesn't even show up. Pic 4 is what the page looks like after several entries(east cost sheet metal). Notice the date entered for east code sheet metal shows up for all the rows, and the the last date entered(05/28/2007) doesn't show up at all.

 

<?
include('include/user_check.php');
include('include/db_con.php');
error_reporting(0);
?>

<html>
<head>
<title>Whiteboard</title>
<script language="javascript">
   function openNewWindow(url) {
    window.open(url,'newPage','scrollbars=no,resizable=no,width=400,height=250');
   }
  </script>
</head>
	<body bgcolor="white">
	<script type='text/JavaScript' src='scw.js'></script>
	<font face="Verdana, Arial, Helvetica, sans-serif">
	<div align="center">
		<table width="600" border="0" cellspacing="2" cellpadding="1" bgcolor="white">
			<tr>
				<td colspan="10" width="1343">

				<div id="popup"></div>
							<center>Whiteboard for<br>
							<?php
							$query="SELECT rest_name FROM abc_tables WHERE table_id=$table_id";
							$result=mysql_query($query);
							while ($row = mysql_fetch_assoc($result))
							{
							$rest_name = $row['rest_name'];
							}

							echo"$rest_name";
							?><br>
						<img src="thin_horiz_line.png" width="250" height="1"></center>
				</td>
			</tr>
			<tr>
				<td align="center" valign="bottom" width="60"><font size="-2">Advertiser</font></td>
				<td align="center" valign="bottom" width="20"><font size="-2">Ad Size</font></td>
				<td align="center" valign="bottom" width="75"><font size="-2">Contract Rec</font></td>
				<td align="center" valign="bottom" width="35"><font size="-2">Ad Copy Rec</font></td>
				<td align="center" valign="bottom" width="30"><font size="-2">Pict</font></td>
				<td align="center" valign="bottom" width="30"><font size="-2">Copy Sent Out</font></td>
				<td align="center" valign="bottom" width="60"><font size="-2">Approved</font></td>
			</tr>
			<tr>
				<td colspan="10" width="1343">
					<div align="center">
						<img src="thin_horiz_line.png"></div>
				</td>
			</tr>


<?php
$query_table="SELECT table_id FROM abc_tables WHERE table_id=$table_id";
$result_table=mysql_query($query_table);
while ($row_table = mysql_fetch_assoc($result_table))
{
$table_id = $row_table['table_id'];
}

$query_ads_rec_dates="SELECT ad_copy_rec FROM whiteboard_dates WHERE rest_id=$table_id";
$result_ads_rec_dates=mysql_query($query_ads_rec_dates);
while ($row_ads_rec_dates = mysql_fetch_assoc($result_ads_rec_dates))
{
$ad_copy_rec_old = $row_ads_rec_dates['ad_copy_rec'];
}

$query_ads="SELECT id, company, size, date_ordered, date_approved FROM ad_order WHERE cust_id=$table_id";
$result_ads=mysql_query($query_ads);
while ($row_ads = mysql_fetch_assoc($result_ads))
{
$id = $row_ads['id'];
$company = $row_ads['company'];
$ad_size = $row_ads['size'];
$contract_rec = $row_ads['date_ordered'];
$approve = $row_ads['date_approved'];
$approved_date = date('m/d/y',$approve);


$query_ads_dates="SELECT ad_id, action, time FROM job_log WHERE ad_id=$id";
$result_ads_dates=mysql_query($query_ads_dates);
while ($row_ads_dates = mysql_fetch_assoc($result_ads_dates))
{
$ad_id = $row_ads_dates['ad_id'];
$action = $row_ads_dates['action'];
$upload = $row_ads_dates['time'];
$upload_date = date('m/d/y',$upload);
}	
?>
		<tr>
		<td colspan="10" width="1343"><div align="center"><IMG SRC="thin_horiz_line.png"></div></TD>
		</TR>
		<tr>
		<td align="center" valign="top" width="60"><font size="-2"><?	
		echo "$company";
		?></font></td>

		<td align="center" valign="top" width="60"><font size="-2"><?
		echo "$ad_size";
		?></font></td>

		<td align="center" valign="top" width="60"><font size="-2"><?
		echo "$contract_rec";
		?></font></td>

		<td align="center" valign="top" width="60"><font size="-2"><?
		echo "$ad_copy_rec_old";
		?></p>
		<form method="post" action="" enctype="multipart/form-data" name="FormName">
		<input type="text" class="formTextbox" name="ad_copy_rec_new" size="24"/>
		<input type="submit" class="formTextbox" name="submit" value="Submit Ad Copy Rec Date">
		</form></font></td>

		<?php
		if($submit && $ad_copy_rec_old == ""){
		$sql = "INSERT INTO whiteboard_dates (rest_id, ad_copy_rec) VALUES ('$table_id', '$ad_copy_rec_new')";
		$result = mysql_query($sql);
		} 
		else 
		{
		$new = $ad_copy_rec_old.",".$ad_copy_rec_new;
		$sql = "UPDATE whiteboard_dates SET ad_copy_rec = '$new' WHERE rest_id='$table_id'";
		$result = mysql_query($sql);
		}			
		?>

		<td align="center" valign="top" width="60"><font size="-2"><?
		echo "";
		?></font></td>

		<td align="center" width="60"><font size="-2"><?php
		if ($action == "999" || $action == "208"){
		echo "$upload_date<br>";
		}
		else
		{
		echo "";
		}
		?></font></td>

		<td align="center" width="60"><font size="-2"><?php
		echo "$approved_date<br>";
		?></font></td>			

<?php
}
?>
<TR>
<td colspan="10" width="1343"><div align="center"><IMG SRC="thin_horiz_line.png"></div></TD>
</TR>
</TABLE>
</body>
</html>

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/57760-solved-multiple-posts-in-wrong-location/
Share on other sites

change order of your script

 

1st update database after that echo data table and form

try

<?
include('include/user_check.php');
include('include/db_con.php');
error_reporting(0);
?>

<html>
<head>
<title>Whiteboard</title>
<script language="javascript">
   function openNewWindow(url) {
    window.open(url,'newPage','scrollbars=no,resizable=no,width=400,height=250');
   }
  </script>
</head>
<body bgcolor="white">
<script type='text/JavaScript' src='scw.js'></script>
<font face="Verdana, Arial, Helvetica, sans-serif">
<div align="center">
<table width="600" border="0" cellspacing="2" cellpadding="1" bgcolor="white">
<tr>
<td colspan="10" width="1343">
<div id="popup"></div>
<center>Whiteboard for<br>
<?php
$submit = $_POST['submit'];
$table_id =$_POST['table_id'];
$ad_copy_rec_new = $_POST['ad_copy_rec_new'];
if ($submit){
$sql = "SELET ad_copy_rec FROM whiteboard_dates WHERE rest_id 0 '$table_id'";
$result = mysql_query($sql);
$ad_copy_rec_old = mysql_result($result,0,0);
if($ad_copy_rec_old == ""){
	$sql = "INSERT INTO whiteboard_dates (rest_id, ad_copy_rec) VALUES ('$table_id', '$ad_copy_rec_new')";
	$result = mysql_query($sql);
} 
else{
	$new = $ad_copy_rec_old.",".$ad_copy_rec_new;
	$sql = "UPDATE whiteboard_dates SET ad_copy_rec = '$new' WHERE rest_id='$table_id'";
	$result = mysql_query($sql);
}
}

$query="SELECT rest_name FROM abc_tables WHERE table_id=$table_id";
$result=mysql_query($query);
while ($row = mysql_fetch_assoc($result)){
$rest_name = $row['rest_name'];
}
echo"$rest_name";
?><br>
<img src="thin_horiz_line.png" width="250" height="1"></center>
</td>
</tr>
<tr>
<td align="center" valign="bottom" width="60"><font size="-2">Advertiser</font></td>
<td align="center" valign="bottom" width="20"><font size="-2">Ad Size</font></td>
<td align="center" valign="bottom" width="75"><font size="-2">Contract Rec</font></td>
<td align="center" valign="bottom" width="35"><font size="-2">Ad Copy Rec</font></td>
<td align="center" valign="bottom" width="30"><font size="-2">Pict</font></td>
<td align="center" valign="bottom" width="30"><font size="-2">Copy Sent Out</font></td>
<td align="center" valign="bottom" width="60"><font size="-2">Approved</font></td>
</tr>
<tr>
<td colspan="10" width="1343">
<div align="center">
<img src="thin_horiz_line.png"></div>
</td>
</tr>
<?php
$query_table="SELECT table_id FROM abc_tables WHERE table_id=$table_id";
$result_table=mysql_query($query_table);
while ($row_table = mysql_fetch_assoc($result_table)){
$table_id = $row_table['table_id'];
}

$query_ads_rec_dates="SELECT ad_copy_rec FROM whiteboard_dates WHERE rest_id=$table_id";
$result_ads_rec_dates=mysql_query($query_ads_rec_dates);
while ($row_ads_rec_dates = mysql_fetch_assoc($result_ads_rec_dates)){
$ad_copy_rec_old = $row_ads_rec_dates['ad_copy_rec'];
}

$query_ads="SELECT id, company, size, date_ordered, date_approved FROM ad_order WHERE cust_id=$table_id";
$result_ads=mysql_query($query_ads);
while ($row_ads = mysql_fetch_assoc($result_ads)){
$id = $row_ads['id'];
$company = $row_ads['company'];
$ad_size = $row_ads['size'];
$contract_rec = $row_ads['date_ordered'];
$approve = $row_ads['date_approved'];
$approved_date = date('m/d/y',$approve);
$query_ads_dates="SELECT ad_id, action, time FROM job_log WHERE ad_id=$id";
$result_ads_dates=mysql_query($query_ads_dates);
while ($row_ads_dates = mysql_fetch_assoc($result_ads_dates)){
	$ad_id = $row_ads_dates['ad_id'];
	$action = $row_ads_dates['action'];
	$upload = $row_ads_dates['time'];
	$upload_date = date('m/d/y',$upload);
}
?>
<tr>
<td colspan="10" width="1343"><div align="center"><IMG SRC="thin_horiz_line.png"></div></TD>
</TR>
<tr>
<td align="center" valign="top" width="60"><font size="-2"><?
echo "$company";
?></font></td>
<td align="center" valign="top" width="60"><font size="-2"><?
echo "$ad_size";
?></font></td>
<td align="center" valign="top" width="60"><font size="-2"><?
echo "$contract_rec";
?></font></td>
<td align="center" valign="top" width="60"><font size="-2"><?
echo "$ad_copy_rec_old";
?></p>
<form method="post" action="" enctype="multipart/form-data" name="FormName">
<input type="hidden" name="table_id" value="
<?php echo $table_id; ?>
">
<input type="text" class="formTextbox" name="ad_copy_rec_new" size="24"/>
<input type="submit" class="formTextbox" name="submit" value="Submit Ad Copy Rec Date">
</form></font></td>
<?php
/*	if($submit && $ad_copy_rec_old == ""){
	$sql = "INSERT INTO whiteboard_dates (rest_id, ad_copy_rec) VALUES ('$table_id', '$ad_copy_rec_new')";
	$result = mysql_query($sql);
} 
else{
	$new = $ad_copy_rec_old.",".$ad_copy_rec_new;
	$sql = "UPDATE whiteboard_dates SET ad_copy_rec = '$new' WHERE rest_id='$table_id'";
	$result = mysql_query($sql);
}
*/	?>
<td align="center" valign="top" width="60"><font size="-2"><?
echo "";
?></font></td>
<td align="center" width="60"><font size="-2"><?php
if ($action == "999" || $action == "208"){
	echo "$upload_date<br>";
}
else{
	echo "";
}
?></font></td>
<td align="center" width="60"><font size="-2"><?php
echo "$approved_date<br>";
?></font></td>
<?php
}
?>
<TR>
<td colspan="10" width="1343"><div align="center"><IMG SRC="thin_horiz_line.png"></div></TD>
</TR>
</TABLE>
</body>
</html>

thanks sasa

 

When I try your code the page only displays the name of the restaurant and my table headings (pic 5)

If I mark out the $_POST[''];'s it will then display the page properly on the first load but still posts like

it does in pic 4 except it will only post once. If I enter more info and click submit it just refreshes and

displays the first post.

 

 

<?
include('include/user_check.php');
include('include/db_con.php');
error_reporting(0);
?>

<html>
<head>
<title>Whiteboard</title>
<script language="javascript">
   function openNewWindow(url) {
    window.open(url,'newPage','scrollbars=no,resizable=no,width=400,height=250');
   }
  </script>
</head>
<body bgcolor="white">
<script type='text/JavaScript' src='scw.js'></script>
<font face="Verdana, Arial, Helvetica, sans-serif">
<div align="center">
<table width="600" border="0" cellspacing="2" cellpadding="1" bgcolor="white">
<tr>
<td colspan="10" width="1343">
<div id="popup"></div>
<center>Online Books For<br>

<?php
$query="SELECT rest_name FROM abc_tables WHERE table_id=$table_id";
$result=mysql_query($query);
while ($row = mysql_fetch_assoc($result)){
$rest_name = $row['rest_name'];
}
echo"$rest_name";

//$submit = $_POST['submit'];
//$table_id =$_POST['table_id'];
//$ad_copy_rec_new = $_POST['ad_copy_rec_new'];
if ($submit){
$sql = "SELET ad_copy_rec FROM whiteboard_dates WHERE rest_id 0 '$table_id'";
$result = mysql_query($sql);
$ad_copy_rec_old = mysql_result($result,0,0);
if($ad_copy_rec_old == ""){
	$sql = "INSERT INTO whiteboard_dates (rest_id, ad_copy_rec) VALUES ('$table_id', '$ad_copy_rec_new')";
	$result = mysql_query($sql);
} 
else{
	$new = $ad_copy_rec_old.",".$ad_copy_rec_new;
	$sql = "UPDATE whiteboard_dates SET ad_copy_rec = '$new' WHERE rest_id='$table_id'";
	$result = mysql_query($sql);
}
}
?>

<br>
<img src="thin_horiz_line.png" width="250" height="1"></center>
</td>
</tr>
<tr>
<td align="center" valign="bottom" width="60"><font size="-2">Advertiser</font></td>
<td align="center" valign="bottom" width="20"><font size="-2">Ad Size</font></td>
<td align="center" valign="bottom" width="75"><font size="-2">Contract Rec</font></td>
<td align="center" valign="bottom" width="35"><font size="-2">Ad Copy Rec</font></td>
<td align="center" valign="bottom" width="30"><font size="-2">Pict</font></td>
<td align="center" valign="bottom" width="30"><font size="-2">Copy Sent Out</font></td>
<td align="center" valign="bottom" width="60"><font size="-2">Approved</font></td>
</tr>
<tr>
<td colspan="10" width="1343">
<div align="center">
<img src="thin_horiz_line.png"></div>
</td>
</tr>
<?php
$query_table="SELECT table_id FROM abc_tables WHERE table_id=$table_id";
$result_table=mysql_query($query_table);
while ($row_table = mysql_fetch_assoc($result_table)){
$table_id = $row_table['table_id'];
}

$query_ads_rec_dates="SELECT ad_copy_rec FROM whiteboard_dates WHERE rest_id=$table_id";
$result_ads_rec_dates=mysql_query($query_ads_rec_dates);
while ($row_ads_rec_dates = mysql_fetch_assoc($result_ads_rec_dates)){
$ad_copy_rec_old = $row_ads_rec_dates['ad_copy_rec'];
}

$query_ads="SELECT id, company, size, date_ordered, date_approved FROM ad_order WHERE cust_id=$table_id";
$result_ads=mysql_query($query_ads);
while ($row_ads = mysql_fetch_assoc($result_ads)){
$id = $row_ads['id'];
$company = $row_ads['company'];
$ad_size = $row_ads['size'];
$contract_rec = $row_ads['date_ordered'];
$approve = $row_ads['date_approved'];
$approved_date = date('m/d/y',$approve);
$query_ads_dates="SELECT ad_id, action, time FROM job_log WHERE ad_id=$id";
$result_ads_dates=mysql_query($query_ads_dates);
while ($row_ads_dates = mysql_fetch_assoc($result_ads_dates)){
	$ad_id = $row_ads_dates['ad_id'];
	$action = $row_ads_dates['action'];
	$upload = $row_ads_dates['time'];
	$upload_date = date('m/d/y',$upload);
}
?>
<tr>
<td colspan="10" width="1343"><div align="center"><IMG SRC="thin_horiz_line.png"></div></TD>
</TR>
<tr>
<td align="center" valign="top" width="60"><font size="-2"><?
echo "$company";
?></font></td>
<td align="center" valign="top" width="60"><font size="-2"><?
echo "$ad_size";
?></font></td>
<td align="center" valign="top" width="60"><font size="-2"><?
echo "$contract_rec";
?></font></td>
<td align="center" valign="top" width="60"><font size="-2"><?
echo "$ad_copy_rec_old";
?></p>
<form method="post" action="" enctype="multipart/form-data" name="FormName">
<input type="hidden" name="table_id" value="<?php echo $table_id; ?>">
<input type="text" class="formTextbox" name="ad_copy_rec_new" size="24"/>
<input type="submit" class="formTextbox" name="submit" value="Submit Ad Copy Rec Date">
</form></font></td>

<td align="center" valign="top" width="60"><font size="-2"><?
echo "";
?></font></td>
<td align="center" width="60"><font size="-2"><?php
if ($action == "999" || $action == "208"){
	echo "$upload_date<br>";
}
else{
	echo "";
}
?></font></td>

<td align="center" width="60"><font size="-2"><?php
echo "$approved_date<br>";
?></font></td>

<?php
}
?>

<TR>
<td colspan="10" width="1343"><div align="center"><IMG SRC="thin_horiz_line.png"></div></TD>
</TR>
</TABLE>
</body>
</html>

 

[attachment deleted by admin]

With the following code I was able to get it to post once instead of to all. But it doesn't display anything the first time I enter data and click submit(pic 6). After I enter data the second time and click submit it will then display the original data I entered(pic 7). It also doesn't care where I enter data it displays it at the top of the table.

 

<?
include('include/user_check.php');
include('include/db_con.php');
error_reporting(0);
?>

<html>
<head>
<title>Whiteboard</title>
<script language="javascript">
   function openNewWindow(url) {
    window.open(url,'newPage','scrollbars=no,resizable=no,width=400,height=250');
   }
  </script>
</head>
<body bgcolor="white">
<script type='text/JavaScript' src='scw.js'></script>
<font face="Verdana, Arial, Helvetica, sans-serif">
<div align="center">
<table width="600" border="0" cellspacing="2" cellpadding="1" bgcolor="white">
<tr>
<td colspan="10" width="1343">
<div id="popup"></div>
<center>Online Books For<br>

<?php
$query="SELECT rest_name FROM abc_tables WHERE table_id=$table_id";
$result=mysql_query($query);
while ($row = mysql_fetch_assoc($result)){
$rest_name = $row['rest_name'];
}
echo"$rest_name";

$submit = $_POST['submit'];

?>

<br>
<img src="thin_horiz_line.png" width="250" height="1"></center>
</td>
</tr>
<tr>
<td align="center" valign="bottom" width="60"><font size="-2">Advertiser</font></td>
<td align="center" valign="bottom" width="20"><font size="-2">Ad Size</font></td>
<td align="center" valign="bottom" width="75"><font size="-2">Contract Rec</font></td>
<td align="center" valign="bottom" width="35"><font size="-2">Ad Copy Rec</font></td>
<td align="center" valign="bottom" width="30"><font size="-2">Pict</font></td>
<td align="center" valign="bottom" width="30"><font size="-2">Copy Sent Out</font></td>
<td align="center" valign="bottom" width="60"><font size="-2">Approved</font></td>
</tr>
<tr>
<td colspan="10" width="1343">
<div align="center">
<img src="thin_horiz_line.png"></div>
</td>
</tr>
<?php
$query_table="SELECT table_id FROM abc_tables WHERE table_id=$table_id";
$result_table=mysql_query($query_table);
while ($row_table = mysql_fetch_assoc($result_table)){
$table_id = $row_table['table_id'];
}

$query_ads_rec_dates="SELECT ad_copy_rec FROM whiteboard_dates WHERE rest_id=$table_id";
$result_ads_rec_dates=mysql_query($query_ads_rec_dates);
while ($row_ads_rec_dates = mysql_fetch_assoc($result_ads_rec_dates)){
$ad_copy_rec_old = $row_ads_rec_dates['ad_copy_rec'];
}

$query_ads="SELECT id, company, size, date_ordered, date_approved FROM ad_order WHERE cust_id=$table_id";
$result_ads=mysql_query($query_ads);
while ($row_ads = mysql_fetch_assoc($result_ads)){
$id = $row_ads['id'];
$company = $row_ads['company'];
$ad_size = $row_ads['size'];
$contract_rec = $row_ads['date_ordered'];
$approve = $row_ads['date_approved'];
$approved_date = date('m/d/y',$approve);
$query_ads_dates="SELECT ad_id, action, time FROM job_log WHERE ad_id=$id";
$result_ads_dates=mysql_query($query_ads_dates);
while ($row_ads_dates = mysql_fetch_assoc($result_ads_dates)){
	$ad_id = $row_ads_dates['ad_id'];
	$action = $row_ads_dates['action'];
	$upload = $row_ads_dates['time'];
	$upload_date = date('m/d/y',$upload);
}
?>
<tr>
<td colspan="10" width="1343"><div align="center"><IMG SRC="thin_horiz_line.png"></div></TD>
</TR>
<tr>
<td align="center" valign="top" width="60"><font size="-2"><?
echo "$company";
?></font></td>
<td align="center" valign="top" width="60"><font size="-2"><?
echo "$ad_size";
?></font></td>
<td align="center" valign="top" width="60"><font size="-2"><?
echo "$contract_rec";
?></font></td>
<td align="center" valign="top" width="60"><font size="-2"><?
echo "$ad_copy_rec_old";
?></p>
<form method="post" action="" enctype="multipart/form-data" name="FormName">
<input type="hidden" name="table_id" value="<?php echo $table_id; ?>">
<input type="text" class="formTextbox" name="ad_copy_rec_new" size="24"/>
<input type="submit" class="formTextbox" name="submit" value="Submit Ad Copy Rec Date">
</form></font></td>

<?php
if ($submit){
$sql = "SELET ad_copy_rec FROM whiteboard_dates WHERE id = '$id'";
$result = mysql_query($sql);
$ad_copy_rec_old = mysql_result($result);
if($ad_copy_rec_old == ""){
	$sql = "INSERT INTO whiteboard_dates (rest_id, ad_copy_rec, ad_id) VALUES ('$table_id', '$ad_copy_rec_new', '$id')";
	$result = mysql_query($sql);
} 
else{
	$new = $ad_copy_rec_old.",".$ad_copy_rec_new;
	$sql = "UPDATE whiteboard_dates SET ad_copy_rec = '$new' WHERE id='$id'";
	$result = mysql_query($sql);
}
}
?>

<td align="center" valign="top" width="60"><font size="-2"><?
echo "";
?></font></td>
<td align="center" width="60"><font size="-2"><?php
if ($action == "999" || $action == "208"){
	echo "$upload_date<br>";
}
else{
	echo "";
}
?></font></td>

<td align="center" width="60"><font size="-2"><?php
echo "$approved_date<br>";
?></font></td>

<?php
}
?>

<TR>
<td colspan="10" width="1343"><div align="center"><IMG SRC="thin_horiz_line.png"></div></TD>
</TR>
</TABLE>
</body>
</html>

 

I just noticed that no matter where (top, middle, or bottom of the table) or how many times i enter data only the original data is being entered into the database and it is always the first listed advertisier. if i enter data at the bottom if my table it still posts the id of the advertiser at the top of my table(pic 8) bella nails is #18009 the sheet metal company is #18474

 

[attachment deleted by admin]

in start of your script you have variable $table_id (where is it setup?)

 

general idea is that first update your database and after that show results

 

this part of code do nothing

$query_table="SELECT table_id FROM abc_tables WHERE table_id=$table_id";
$result_table=mysql_query($query_table);
while ($row_table = mysql_fetch_assoc($result_table)){
     $table_id = $row_table['table_id'];
}

this part is run only once

$query_ads_rec_dates="SELECT ad_copy_rec FROM whiteboard_dates WHERE rest_id=$table_id";
$result_ads_rec_dates=mysql_query($query_ads_rec_dates);
while ($row_ads_rec_dates = mysql_fetch_assoc($result_ads_rec_dates)){
$ad_copy_rec_old = $row_ads_rec_dates['ad_copy_rec'];
}

i think it must be executed for each row in your html table

 

in form you must pass value of primary key of table whiteboard_dates and just updated this table (not insert)

im sorry im not going to help you this time because you need to first shorten your scripts just remove the parts that you think we dont need and the parts that you have finished and bug free.... and you need to use the code tag its the little button that has a # in it next to the quote and printer looking thing it really wouldnt be bad but you double posted without putting either one of them in the code tag

My apologies bob, I thought it appropriate to use [\php] instead if [\code] because I was posting a php script.

I posted all 160 lines of code because I wasn't sure if my problem was just php or php and the way the page was layed out.

Again my apologies.

 

Any way here's the "short" of it.

 

sasa, your right that part of the code is now gone.

 

I believe this is the part of the code giving me the trouble.

<td align="center" valign="top" width="60"><font size="-2"><?
$query_ads_rec_dates="SELECT ad_copy_rec FROM whiteboard_dates WHERE id=$id";
$result_ads_rec_dates=mysql_query($query_ads_rec_dates);
while ($row_ads_rec_dates = mysql_fetch_assoc($result_ads_rec_dates))
{
$ad_copy_rec_old = $row_ads_rec_dates['ad_copy_rec'];
}
echo "$ad_copy_rec_old";

$id = $row_ads['id'];			

if ($submit){
if($ad_copy_rec_old == ""){
$sql = "INSERT INTO whiteboard_dates (rest_id, ad_copy_rec, ad_id) VALUES ('$table_id', '$ad_copy_rec_new', '$id')";
$result = mysql_query($sql);
} 
else{
$new = $ad_copy_rec_old.",".$ad_copy_rec_new;
$sql = "UPDATE whiteboard_dates SET ad_copy_rec = '$new' WHERE '$id' = id";
$result = mysql_query($sql);
}
}
?>

	</p>
	<form method="post" action="" enctype="multipart/form-data" name="FormName">
	<input type="hidden" name="table_id" value="<?php echo $table_id; ?>">
	<input type="hidden" name="ad_id" value="<?php echo $id; ?>">
	<input type="text" class="formTextbox" name="ad_copy_rec_new" size="24"/>
	<input type="submit" class="formTextbox" name="submit" value="Submit Ad Copy Rec Date">
	</form>

 

 

 

 

this should work...right?

 

echo $ad_copy_rec_old

_____________

|___________|

(submit new date)

 

users inputs new date and clicks submit then the script will check to see if there is already a date already in the database

 

if there is not it will input the date, and then echo it above the input box

 

if there is it will get the old date, 05/23/2007 for example, and APPEND the new data to the old

 

Example:

old data 05/23/2007

data after new update 05/23/2007, 05/24/2007

Almost there!!! I gave up on trying to process everything on one page.

Current code for layout_info.php

			<td align="center" valign="top" width="60"><font size="-2"><?
		$query_ads_rec_dates="SELECT ad_copy_rec FROM whiteboard_dates WHERE ad_id=$id"; 
		$result_ads_rec_dates=mysql_query($query_ads_rec_dates); 
		while ($row_ads_rec_dates = mysql_fetch_assoc($result_ads_rec_dates)) 
		{ 
		$ad_copy_rec_old = $row_ads_rec_dates['ad_copy_rec']; 
		}
            echo "$ad_copy_rec_old";?>
		<form method="post" action="table_layout_info_handler.php" enctype="multipart/form-data" name="FormName">
		<input type="hidden" name="table_id" value="<?php echo $table_id; ?>">
		<input type="hidden" name="ad_id" value="<?php echo $id; ?>">
		<input type="text" class="formTextbox" name="ad_copy_rec_new" size="24"/> 
            <input type="submit" class="formTextbox" name="submit" value="Submit Ad Copy Rec Date"> 
            </form></font></td>
		<?php
		$ad_copy_rec_old = "";
		?>

 

Current code for layout_info_handler.php

<?php
include('include/user_check.php'); 
include('include/db_con.php');
error_reporting(0); 
?>

<?php
$query_ads_rec_dates="SELECT ad_copy_rec FROM whiteboard_dates WHERE ad_id=$ad_id"; 
$result_ads_rec_dates=mysql_query($query_ads_rec_dates); 
while ($row_ads_rec_dates = mysql_fetch_assoc($result_ads_rec_dates)) 
{ 
$ad_copy_rec_old = $row_ads_rec_dates['ad_copy_rec']; 
}
    		if($ad_copy_rec_old == ""){ 
        	$sql = "INSERT INTO whiteboard_dates (rest_id, ad_copy_rec, ad_id) VALUES ('$table_id', '$ad_copy_rec_new', '$ad_id')"; 
        	$result = mysql_query($sql); 
    		} 
    		else{ 
        	$new = $ad_copy_rec_old.",".$ad_copy_rec_new; 
        	$sql = "UPDATE whiteboard_dates SET ad_copy_rec = '$new' WHERE ad_id='$ad_id'"; 
        	$result = mysql_query($sql); 
    		}
?> 
<script type="text/javascript">
location="table_layout_info.php?table_id=<?="$table_id"; ?>"
</script>

 

The only problem I have now is I can only update one advertiser.

Example:

 

advertiser 1 (no info)

advertiser 2 (no info)

advertiser 3 (no info)

 

I input info to advertiser 2

 

advertiser 1 (no info)

advertiser 2 blah blah

advertiser 3 (no info)

 

I input info to advertiser 2 again

 

advertiser 1 (no info)

advertiser 2 blah blah, more blah

advertiser 3 (no info)

 

I input info to advertiser 1 or 3

 

advertiser 1 (no info)

advertiser 2 blah blah, more blah

advertiser 3 (no info)

when I try it like that it only submits once

 

example:

 

advertiser 1 (no info)

advertiser 2 (no info)

advertiser 3 (no info)

 

I input info to advertiser 2

 

advertiser 1 (no info)

advertiser 2 blah blah

advertiser 3 (no info)

 

I input info to advertiser 2 again

 

advertiser 1 (no info)

advertiser 2 blah blah

advertiser 3 (no info)

 

I input info to advertiser 1 or 3

 

advertiser 1 (no info)

advertiser 2 blah blah

advertiser 3 (no info)

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.