Forum Moderators: open
"The bigger part is the one that I want to work with"
What I want to do is that :
if I click on any of the Cellid(from table "traff" that is displayed), it will get that Cellid Value and then match it with tablename " comments" and then on click will pop up a balloon with all the values from table "comments" where date =Currdate
Below is all that you will need:
==========================================================
My data base table "comments" is
CELLID , problem ,solution , comments ,userid , date .
===========================================================
My data base table traff is
BSCID, Cellid , Seiz , Drps ,dropflag ,RF, Oth ,Traff, trafflag , Total , DIT , IHFL ,ihfflag , TCD , TCA ,SDD , SDA ,TAVL ,tchaflag , Drate ,date .
===========================================================
This is the page that displays the whole table:
<?php
$host = "localhost";
$user = "shruti";
$pass = "patel";
$dbname = "tmetrix";
$connection = mysql_connect("localhost", "root", "") or die("Cannot connect to MySQL server: " . mysql_error());
$db_selected = mysql_select_db('tmetrix', $connection);
$dt= DATE('Y-m-d');
$data = mysql_query("SELECT * FROM traff where date = '$dt'")
or die(mysql_error());
Print "<table border=0 cellspacing=0 cellpadding=0 style='width:100%'>";
$info= mysql_query($query);
$num_data = mysql_num_rows($data);
for($i=0; $i < $num_data; $i++) {
$row = mysql_fetch_array($data);
$rows[$i]['BSCID'] = "<td style='text-align:left'>" . $row['BSCID'] . "</td>";
$rows[$i]['Cellid'] = "<td style='text-align:left'>" . $row['Cellid'] . "</td>";
$rows[$i]['Seiz'] = "<td>" . $row['Seiz'] . "</td>";
$rows[$i]['Drps'] = "<td>" . $row['Drps'] . "</td>";
$rows[$i]['RF'] = "<td>" . $row['RF'] . "</td>";
$rows[$i]['Oth'] = "<td>" . $row['Oth'] . "</td>";
$rows[$i]['Traff'] = "<td>" . $row['Traff'] . "</td>";
$rows[$i]['Total'] = "<td>"."(" . $row['Total'] .")". "</td>";
$rows[$i]['DIT'] = "<td>" . $row['DIT'] . "</td>";
$rows[$i]['IHFL'] = "<td>" . $row['IHFL'] . "</td>";
$rows[$i]['TCD'] = "<td>" . $row['TCD'] . "</td>";
$rows[$i]['TCA'] = "<td>" . $row['TCA'] . "</td>";
$rows[$i]['SDD'] = "<td>" . $row['SDD'] . "</td>";
$rows[$i]['SDA'] = "<td>" . $row['SDA'] . "</td>";
$rows[$i]['TAVL'] = "<td>" . $row['TAVL'] ."%". "</td>";
$rows[$i]['Drate'] = "<td>" . $row['Drate'] . "</td>";
if($row['dropflag'])
$rows[$i]['Drps'] = str_replace('<td>','<td style="font-weight:bold;color:#CC0066">',$rows[$i]['Drps']);
if($row['trafflag'])
$rows[$i]['Traff'] = str_replace('<td>','<td style="font-weight:bold;color: #CC0066">',$rows[$i]['Traff']);
if($row['ihfflag'])
$rows[$i]['IHFL'] = str_replace('<td>','<td style="font-weight:bold;color:#CC0066">',$rows[$i]['IHFL']);
if($row['tchaflag'])
$rows[$i]['TAVL'] = str_replace('<td>','<td style="font-weight:bold;color:#CC0066 ">',$rows[$i]['TAVL']);
}
for($i=0; $i < $num_data; $i++) {
if($i % 2)
{
print '<TR bgcolor="#ffffff">';
}
else
{
print '<TR bgcolor="#CCCCCC">';
}
foreach($rows[$i] as $cell)
echo $cell;
}
print "</TR>\n";
?>
[edited by: DrDoc at 12:41 am (utc) on July 26, 2008]
$rows[$i]['Cellid'] = "<td style='text-align:left'>" . $row['Cellid'] . "</td>"; If you modify it slightly:
$rows[$i]['Cellid'] = "<td style='text-align:left' [b]onclick='getComments(" . $row['Cellid'] . ")'[/b]>" . $row['Cellid'] . "</td>"; Then you will need to create the
getComments function, which should initiate an AJAX call to the server in order to retrieve the data. Set up another PHP script which is dedicated to extracting the comments. Do you have any AJAX experience?