Jump to content

[SOLVED] can only update one record


matthewst

Recommended Posts

I can only update one advertiser. It dosen't matter which one I choose I can then only update that one. I have to go into the database and delete the updated record to be able to update again.

 

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)

Link to comment
Share on other sites

I gave the  script a major overhaul, still no luck.

 

here is the entire thing if that helps

<? 
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">
	<!--Timothy Matthews really did write me!! -->
        <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>            
            <tr> 
            <td colspan="10" width="1343"><div align="center"><IMG SRC="thin_horiz_line.png"></div></TD> 
            </TR> 
            <tr> 
            <?
		$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);

		echo "<td align='center' valign='top' width='80'><font size='-2'>$company</font></td>";
		echo "<td align='center' valign='top' width='60'><font size='-2'>$ad_size</font></td>";
		echo "<td align='center' valign='top' width='60'><font size='-2'>$contract_rec<br></font></td>";
			$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 "<td align='center' valign='top' width='60'><font size='-2'>$ad_copy_rec_old</font>";
		$ad_copy_rec_old = "";
		echo "<form method='post' action='table_layout_info_handler.php' enctype='multipart/form-data' name='FormName'>
			<input type='hidden' name='table_id' value='$table_id'>
			<input type='hidden' name='ad_id' value='$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></td>";            
		echo "<td align='center' valign='top' width='60'><font size='-2'><br></font></td>";
			$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)) 
			{ 
			$action = $row_ads_dates['action']; 
			$upload = $row_ads_dates['time']; 
			$upload_date = date('m/d/y',$upload); 
			} 
            	if ($action == "999" || $action == "208"){ 
            echo "<td align='center' valign='top' width='60'><font size='-2'>$upload_date<br></font></td>"; 
            	} 
            	else 
			{ 
		echo "<td align='center' valign='top' width='60'><font size='-2'><br></font></td>";
			}	
			$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)) 
			{ 
			$approve = $row_ads['date_approved'];
			} 
            echo "<td align='center' valign='top' width='60'><font size='-2'>$approve<br></font></td></tr>";
			} 
            ?>             
              
<TR> 
<td colspan="10" width="1343"><div align="center"><IMG SRC="thin_horiz_line.png"></div></TD> 
</TR> 
</TABLE> 
</body> 
</html>

 

and here is the handler

<?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>

Link to comment
Share on other sites

I tried echoing everything and it was all coming out fine. I was about to past the query into phpmyadmin, just for s and g's when obyno (phpbuilder) told me the main problem was the primary key in my table, rest_id. It was only allowing unique entries. Once I changed it to allow duplicates everything worked.

 

thanks everyone for your help

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.