Question : php dynamic drop down creation disrupting UPDATE, feature

Ok, where to begin, as I hope will be apparent from my original question the primary objective was to insert a dynamic drop down in an admin page purpose being to allow administrators to associate a client with a news item.

With a huge amount of help from Murfur (thank you thank you) we reach a point where the drop down was working but an unforseen side effect was that once the news item was saved in the "approve changes page" ( this is like a holding page for all site changes - enabling administrators to view, and edit further, accept or decline their changes) so once the news item was there, if I chose to view it and re-save irrelevant of whether I made a change or not, the item would duplicate in the list - so I then had the same item showing twice, more times if I repeated this. So whereas viewing an item from this page and resaving should just allow it to overwrite it is now registering the item again and again.

Since the approve changes code was never changed I can only assume that the error lies in the code for the news page which we changed to facilitate the dynamic drop down.

I'm guessing the problem lies with the sql and as Murfur suggested something to do with the Update but I can't see clearly whats going on...can anyone help out, it's so close to working.

I attach the original and new code for the news page and the unchanged code for the approve changes page - hopefully the three will help fill in any gaps.
 
news - original
 
 - the original news file
 
news - amended
 
 - the new version
 
approve changes - unaltered
 
- the approve changes file unchanged but helpful in understanding the relationship between pages

Answer : php dynamic drop down creation disrupting UPDATE, feature

mysql_num_rows($res) should return the number of rows in your result set.

$res is the result set from mysql_query
$rec is is the row fetched from the result $res

Since you did a print_r($rec) and saw an array of values there must be at least one row.

this statement:
if(mysql_num_rows($res) > 0){
    $updater = 1;
}

should replace This old statement:
          if ($rec['updatefor'] != null){
                  $updater = 1;


Once the $updater flag is set to 1, it should set the hidden form value updater to 1 also.  Then it will update your record instead of inserting it when you submit the form.
Random Solutions  
 
programming4us programming4us