pulling data from array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am trying to pass the data from a table to a google.visualization.OrgChart javascript
I have converted the data to an array called $customf_array.
Look down in the script to where I need to pull the data out of the array to see the reset of my question


$query = "SELECT * FROM member WHERE members_id = '$_SESSION[members_id]'";
$result=mysql_query($query);
$row = mysql_fetch_array($result);
$memberrep=$row['repnumber'];


$query1 = "SELECT sponserrep,rep,firstname,lastname,phonenumber FROM contacts WHERE members_id = '8' AND sponserrep != ''";
$result1=mysql_query($query1);
$num_rows = mysql_num_rows($result1);
while($row1=mysql_fetch_array($result1)){
$customf_array[]=$row1[0] . "," . $row1[1] . "," . $row1[2] . "," . $row1[3];
}



foreach ($customf_array as $value) {
   echo "Value: $value<br />\n";
}

this is the data that is put out by the foreach
Value: 0000,1234,top,manager
Value: 1342,4523,Leeann,Rodriguez
Value: 4325,1111,Carolyn,Sanderssandifer
Value: 1342,4567,Annie B,Scott
Value: 1234,4325,Jessica,Hobirk
Value: 1234,12356,Kaye,Meadows
Value: 1234,1342,Misty,Coe
Value: 1234,3462,Donald,Skinner



?>
<html>
<head>
<script type="text/javascript" src="http://www.google.com/jsapi";></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["orgchart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
       var data = new google.visualization.DataTable();
       data.addColumn('string', 'Name');
       data.addColumn('string', 'Manager');
data.addRows(<? echo $num_rows?>); data.setCell(0, 0, '<? echo$row["firstname"]?> <? echo$row["lastname"]?>','<font size="+1" color="#FF0000"><? echo$row["firstname"]?> <? echo$row["lastname"]?> </font><br><? echo$row["phonemember"]?>');





<*****************************look at this section***********************>
This is what I do not understand how to do if you can give me some examples on how to sort and pull this data out of the array or if there is a better way to do this
I have been working with this for a few days and do not no where to go

This is the section I need to loop through the array and add the data
it needs to number each recored and the add the members name according to the rep# and the managers name according to the sponserrep#
$number //the recored number
$addname // the members name
$addmanager// the managers name
data.setCell($number, 0, '$addname','<h1>$addname</h1>'); data.setCell($number, 1, '$addmanager');


<*****************************l***********************>
       var table = new
google.visualization.OrgChart(document.getElementById('chart_div'));
       table.draw(data, {allowHtml:true});
}

</script></head>
<body><div id="chart_div"></div></body>
</html>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux