Replying to my own posts, well thought I would update this thread, I've now created the class as such:
$artists = array ('.....'some elements);
class Dynamic_box {
var $elements = array();
function Dynamic_box( $title, $subtitle ) {
$this->title = $title;
$this->subtitle = $subtitle;
}
function display_title() {
echo $this->title;
}
function display_subtitle() {
echo $this->subtitle;
}
function add_element($text){
$n_elements = count($this->elements);
$this->elements[$n_elements] = $text;
}
function display_detail(){
for ($i = 0; $i < count($this->elements); $i++) {
echo $this->elements[$i]."<br>";
}
}
}
Then initiate each instance as follows:
$dynamic_box_1->add_element ("<a href='#' onclick='display_artist();'>name of artist</a>");
Obviously this bit will change, when I add the database but thats another story:
I then found out about the following javascript RPC:
var xmlhttp=false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
function loadFragmentInToElement(fragment_url, element_id) {
var element = document.getElementById(element_id);
element.innerHTML = 'Loading ...';
xmlhttp.open("GET", fragment_url);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
element.innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(null);
}
With the following function definition in the main php page:
<script src="script.js" type="text/javascript"></script>
<script type="text/javascript">
function display_artist() {
loadFragmentInToElement('server1.php', 'current_artist');
}
</script>
I then have the table as follows to get the inital values using the class defined above:
<td class="dym_txt_1_title"><? $dynamic_box_1->display_title(); ?></td>
</tr>
<tr>
<td class="dym_txt_1_title"><? $dynamic_box_1->display_subtitle(); ?></td>
</tr>
<tr>
<td height="0" class="dym_txt_1_title"><? $dynamic_box_1->display_detail() ?></td>
Now I have a seperate PHP file defined as follows:
<?php
include ("classes.inc");
echo $artists[0];
?>
I need to be able to find out how to pass a variable from the main php script over to the backend script inorder to change the contents of the tables dynamically using RPC without refreshing the page... I love a challenge when I suss it out I will repost or if anyone has ideads let me know.