Hi everyone. I'm in the middle of writing a contribution.. but have recently hit a brick wall. I'm not totally sure how to grab some data from my own table in the database. I'll show you a section of the code first, then I'll explain a bit further..
Code:
</td>
</form>
</table>
<?php
global $db;
$subject1 = $db->Execute("SELECT email_templates.subject
FROM " . TABLE_EMAIL_TEMPLATES . "
WHERE email_templates.email_template_id=1");
$entry1 = $db->Execute("SELECT email_templates.entry
FROM " . TABLE_EMAIL_TEMPLATES . "
WHERE email_templates.email_template_id=1");
echo $subject1;
?>
<script type="text/javascript">
templates.subject1.value = $subject1;
templates.entry1.value = $entry1;
</script>
<!-- body_text_eof //-->
As you can tell, I have a table with a form inside (called templates), it contains a couple of textarea boxes, subject1 and entry1. I'm trying to put $subject1 and $entry1 inside them respectively. The JS bit works fine, but the PHP variables just mentioned don't have the expected data. I put an echo command (shown in red) for $subject1 and it outputs "Object", which isn't right. I'm trying to get the variables into the textareas on page load, which is why none of it is inside functions. I'm not sure whether that could be a problem. The database table exists and looks fine. I also did an echo for TABLE_EMAIL_TEMPLATES and that looks ok.
I realise the amount of code I have displayed above may not be enough to determine the problem. If that's the case, I could always email the contribution's files by PM to anyone who wants to help.
Thanks.
Bookmarks