Email record

DebbieS

DaDaBIK Guru
Can you send me your exported DB so I can try and do some testing here?
Without actual data to test against, I don't know what else to try or what to change.

BTW, assuming you have phpMyAdmin (if you don't, I recommend it - great tool for MySQL), have you tried the various SQL statements in there to ensure they return results?
 

DebbieS

DaDaBIK Guru
Figured it out ... should have used a while instead of a foreach ...

[pre]
$artist_email = execute_db($artsql, $conn);
while ($artemail = fetch_row_db($artist_email)){
$to_artists .= $artemail['Act_Email'].', ';
} // end while
$to_artists = substr($to_artists, 0, -2);
[/pre]


And I echoed to the screen ...

email@email1.co.uk, email@email2.co.uk, email@email3.co.uk, email@email4.co.uk, email@email5.co.uk, email@email6.co.uk
 

meanster99

Well-known member
That's brilliant, thanks Debbie!

I feel really bad (and cheeky) for asking anything more, but I've tried to do it myself and can't get it to work - I just want to have some sort of OK/Cancel confirmation pop-up box appear once any of the 3 email links are clicked, just so the user can confirm they actually want to send each of the emails.

I had succesfully added a popup alert box to each email, using echoed javascript, but using similar doesn't work for what I'm after (obviously I need a confirm type messagebox, not a simple alert one). I tried adding a javascript confirm to the links themselves, but that didn't work either. I think I've read that the php will run first anyway, so will need a server side confirmation, which isn't as easy in php as in javascript. Any ideas?

Also, and hopefully, lastly (I am sorry for asking so much of you!), I need to somehow show the updated record to the user once they have clicked one of the links. As you may remember, you helped me add an update function in business_logic that updates an emailstatus field. I don't have that field in the edit form, so thats not a problem. However, I copied that update function to do a similar thing for these artist emails, which updates another field to say the artists have had the details sent to them. This field, ideally, needs to stay on the edit form, but obviously doesn't update on the screen once the user clicks the send artist email link.

So how would I do this? Requery the record after the update function is called? Not entirely sure of the syntax for this though. Have tried using a Select * FROM tablename WHERE ID=currentIDvalue, but couldn't get it to work. Any ideas?

I am so grateful for all your help to date and can't thank you enough, regardless of whether you still continue to help me. You are an absolute star...

Regards,

Matt
 

DebbieS

DaDaBIK Guru
A popup confirmation box is client-side and needs to be javascript. Have a look at this tutorial on the Javascript Confirm Box. To implement, I'd put the JS Function in the head (header.php) and then reference it via URL using the existing links you already have in your code (for the OK/Yes "true" value, use the URL text already there and make the additional paramaters (receipt/latepmt/etc) pass through the function:

[pre]
<script><script type="text/javascript">

</script>
[/pre]

Your URLs will then change to:
<a href="javascript:confirmation('receipt');"..... (using the &... name in the brackets to pass to the funciton.

For the showing of the record to the user, assuming you want to move to the details view, add a header line after the update_sent call in the if/elseif/else portion above the links. If you use the header line from near the end of the case "update" section and change the function to details (from edit), it should work. If it does not work quite right, have a look at how the url is formed when you select a record to view the details and modify from that.
[pre]
update_sent('emailstatus', $table_name, $table_internal_name, $where_field, $where_value, 'receipt');
header("Location: Put URL of details view here");
[/pre]

Hope this works.
 

meanster99

Well-known member
Hi Debbie,

Sorry, been on holiday/vacation for the last few days. No, not actually implemented this yet - I actually used my very limited knowledge of php (largely thanks to you) to make the links conditional, based on various factors, so they only appear when necessary, essentially removing the immediate need for the confirmation. However, I do want to add it in now just to make it 'idiot proof' (as is necessary when dealing with the 'average' user!). I will let you know how I get on.

The second part of what you provided me was not exactly what I needed - I wanted the 'edit' page to refresh/reload, but although I can see the URL for that I haven't yet worked out how to construct it. Again, I've sort of worked around that with making the links conditional, but would prefer the exisiting page to refresh to show the updated field values. Not sure if this requires a different solution to the one you provided...

I am also now working on a new email problem - this whole dadabik project is for my brother's small business and the more I am able to offer him, the more he then wants. Even though he told me this was the last thing he needed! I am sure to need your help again, but am trying my best to work it out myself before asking for anymore help! I will create a new post for my new problems though...

Thanks again for everything Debbie, I am beginning to realise the power of php but also realise my limitations...
 
Top