Jump to content

nirvana

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Everything posted by nirvana

  1. Thank you, guys. Very helpful and I will try it out. regards, nirvana
  2. Hi All, I would like to find out the count of a particular number in an array and every time that number is found the counter should increase. For example: There's an array containing numbers and I would like to find out how many of them are less than 45. If a number less than 45 is found the counter should increase. I know I should use loop with mathematicl function < and variable counter but I don't know where to start. I searched in PHP manual and couldn't find one. Is there a specific function for this? I am still new to php and your help is much appreciated. thanks in advance, nirvana
  3. Hi The following is the output: I copy and paste straight out from the database and not suer the table alignment will be shifted. thanks for your help. regards, +----+-------------+--------------------+--------+---------------+---------+---------+----------------------------------------------+----------+-------------+ | id | select_type | table              | type   | possible_keys | key     | key_len | ref                                          | rows     | Extra       | +----+-------------+--------------------+--------+---------------+---------+---------+----------------------------------------------+----------+-------------+ |  1 | SIMPLE      | dwp_data_container | ALL    | [NULL]        | [NULL]  |  [NULL] | [NULL]                                       | 24610672 | Using where | |  1 | SIMPLE      | dwp_data           | eq_ref | PRIMARY       | PRIMARY |       4 | manufacturing.dwp_data_container.test_number |        1 | Using where | |  1 | SIMPLE      | tested_device      | eq_ref | PRIMARY       | PRIMARY |       4 | manufacturing.dwp_data.device_num            |        1 | Using where | +----+-------------+--------------------+--------+---------------+---------+---------+----------------------------------------------+----------+-------------+ [quote author=fenway link=topic=117558.msg498957#msg498957 date=1168179140] Run the SELECT query with "EXPLAIN" in front of it, and post the output. [/quote]
  4. Hi, Thanks for the help and sorry for late response as I was away. I did try the code with join on but it's still slow, the similar timing as before. Can you please explain? thanks in advance, [quote author=fenway link=topic=117558.msg481537#msg481537 date=1165632697] If it's still slow, post the EXPLAIN. [/quote]
  5. Hi All, I am new in this area and have a limited knowledge. Please look at the following two queries which retreive different data points from the same tables. I am puzzled by the time taken to get the data. I am using MySQL database and PHP web interface. The problem started when my graph plotting with JpGraph took a long time and didn't return any graph. It was working fine before and suddenly I didn't get any graph output if the data I queried is more than 700 points on the first query. The query is called 50 times and the graphs are superpositioned together. So to get one graph, 8080 rows need to be retrieved. Before even though it took a while, at least I get the output graph. When I investigated it, I found this: SELECT measured_para_1, measured_para_5 FROM tested_device join dwp_data join dwp_data_container where tested_device.device_num = dwp_data.device_num AND dwp_data.test_number = dwp_data_container.test_number AND device_ID = 7660 AND TestGroup = 2 AND parameter = 'spec' AND port = 1 AND attn = 0 AND measured_para_2 = 39 AND temp = 25 This query took 10.23sec to retrieve 159 rows This second query is called 9 times, altogether 40509 rows need to be retrieved to get one graph which includes 9 superpositioned graphs. It is strange that this query still works and gives output graph although the number of rows are much more than the first one. SELECT measured_para_2, measured_para_3 FROM tested_device join dwp_data join dwp_data_container where tested_device.device_num = dwp_data.device_num AND dwp_data.test_number = dwp_data_container.test_number AND device_ID = 7660 AND parameter = 'xtalk' AND TestGroup = 2 AND measured_para_1 = 1 AND port = 5 AND attn = 0 AND temp = 25 This query took 3.16sec to retrieve 1000 rows Do you guys know why? Is it because there are so many data in the database and that's why taking so long? Is there a way to speed this up? Please let me know if more information is needed. thanks in advance, Nirvana
  6. Hi All, Here is the script I wrote and having problem with it. I am new in this area and would be appreciated for any help. I use the same query in displaying 3 results: minimum, maximum and list all the contents of the query array. Although I think it should work, it didn't. It displays minimum and maximum but it doesn't display all the contents. I tried debugging with var_dump($result) as shown or echo number of rows and columns - it returned resource 17 mysql result and 50 rows and 4 columns. However, it didn't display any content data. Is there something wrong? I tried changing the variable name $row which is the same in both cases as I thought it would be the reason but still didn't work. function table_create() { // Getting information from the form //Assigning Variables - Device# and test $device = $_POST ['device']; if ($device == "0"){     die ("Please Select Device Number!!"); } $test = $_POST['test'];   if ($test == ""){     die ("Please Select Test Parameter!!"); }   $port = $_POST['port'];   $attn = $_POST['attn'];   $date = $_POST['dates'];   if ($date == ""){die ("Please Select Test Group# !!!");}   $ebw = $_POST ['ebw'];   $temp = $_POST['temp'];   $temperature = @mysql_query("SELECT temp FROM tested_device join dwp_data where device_ID = '$device' AND Temperature BETWEEN $temp"); $t = mysql_fetch_row($temperature); switch ($test) { case "Min BW": if ($attn == "All"){ $result = @mysql_query("SELECT measured_paras_1 AS Channel, attn AS Attenuation_dB, measured_paras_2 AS Min_Bandwidth_GHz FROM dwp_data join dwp_data_summary join tested_device where dwp_data.device_num = tested_device.device_num AND dwp_data.test_number = dwp_data_summary.test_number AND parameter = 'PFL($ebw)' AND port = '$port' AND TestGroup = '$date' AND device_ID = '$device' AND temp BETWEEN $temp ORDER BY measured_paras_1 ASC, attn ASC"); while ($row = mysql_fetch_array($result)) { $bw[] = $row[2];} $min = min($bw); $max = max($bw); } else { $result = @mysql_query("SELECT measured_paras_1 AS Channel, attn AS Attenuation_dB, measured_paras_2 AS Min_Bandwidth_GHz FROM dwp_data join dwp_data_summary join tested_device where dwp_data.device_num = tested_device.device_num AND dwp_data.test_number = dwp_data_summary.test_number AND parameter = 'PFL($ebw)' AND port = '$port' AND attn = '$attn' AND TestGroup = '$date' AND device_ID = '$device' AND temp BETWEEN $temp"); while ($row = mysql_fetch_array($result)) { $bw[] = $row[2];} $min = min($bw); $max = max($bw); } echo "<b><center> Minimum Bandwidth at Port $port = $min GHz<b><br>\n"; echo "<b><center> Maximum Bandwidth at Port $port = $max GHz<b><br>\n"; echo " Port $port - Minimum BandWidth by Channel @ $ebw, $t[0] °C<b><br>\n"; break; } if (!$result) { die('<p>Error performing query:' . mysql_error() . '</p>'); } //echo " PORT $port <br>"; //echo "$attn dB <br>"; //echo "$temp Degree <br>"; //echo "Channel- $ch<br>"; //var_dump($result); //Display # of rows, columns & Create Table   $numrows = mysql_num_rows($result);   $fnum = mysql_num_fields($result); //  echo "$numrows Rows <br>\n"; //  echo "$fnum Columns <br><br>\n";     echo "<table border width='75%' align= 'center' border='0' cellpadding= '0'>";   // echo "<tr>";   for ($x = 0; $x < $fnum; $x++) {         echo "<td><b><center>";           echo  (mysql_field_name($result, $x));               echo "</center></b></td>"; }       //  echo "</tr>";   for ($i = 0; $i < $numrows; $i++) {     $row = mysql_fetch_object($result);       echo "<tr align='center'>";         for ($x = 0; $x < $fnum; $x++) {     $fieldname = mysql_field_name($result, $x);         echo "<td>";         echo $row->$fieldname;         echo "</td>"; }         echo"</tr>"; }     echo "</table>"; return 0; } table_create ($result); thanks in advance, nirvana
  7. [!--quoteo(post=380949:date=Jun 7 2006, 06:37 AM:name=nirvana)--][div class=\'quotetop\']QUOTE(nirvana @ Jun 7 2006, 06:37 AM) [snapback]380949[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hi, The text file is comma delimited and here is the sample: 1,191.400,-45.8,0 1,191.405,-44.6,0 1,191.410,-40.6,0 2,191.500,-50.5,0 2,191.505,-48.2,0 2,191.510,-45.3,0 some text files contain more than 4 columns and they are the data of channel, frequency, loss, attenuation etc. thanks, nirvana [/quote] Forgot to mention one more thing. I am going to use these data to plot the graphs using JpGraph. I wrote a program to plot the graphs using php and jpgraph but the data were retrieved from database directly. Now the data location has changed and they are saved as text file and need to access those files in order to plot the graphs. thanks, nirvana
  8. [!--quoteo(post=380889:date=Jun 7 2006, 01:50 AM:name=Prismatic)--][div class=\'quotetop\']QUOTE(Prismatic @ Jun 7 2006, 01:50 AM) [snapback]380889[/snapback][/div][div class=\'quotemain\'][!--quotec--] It is very possible :) What format is the text file? Post the contents of it, or a sample, so we can help you out a little bit better :) [/quote] Hi, The text file is comma delimited and here is the sample: 1,191.400,-45.8,0 1,191.405,-44.6,0 1,191.410,-40.6,0 2,191.500,-50.5,0 2,191.505,-48.2,0 2,191.510,-45.3,0 some text files contain more than 4 columns and they are the data of channel, frequency, loss, attenuation etc. thanks, nirvana
  9. Hi All, I was wondering if someone can help me with this. I am trying to retrieve data from text file - and the location (the path) of that text file is saved in mySQL database. I am wondering if there is a way of retrieving that data. Sorry I am new to PHP and I have done a few queries to retrieve data from database but would like to know if the above approach is feasible. thanks in advance, nirvana
  10. Hi, I have the following codes written to create word document as per tutorial. There are some modifications I did and when I tested apart from echoing all the data it doesn't generate the word doc and it doesn't give any errors either. Is there anything I am missing to do? The server is installed with MS Word as well. If this is not the right forum and I need to post this in COM forum, can someone please direct me to the right forum as this is the only forum I have been posting my problems? thanks in advance Nirvana <?php //This program is to generate datasheet //Connect to Server and Database include ("Connection.php"); //Get device number $device = 2886; //Minimum Insertion Loss Query print "$device <br>\n"; $IL = @mysql_query("SELECT MIN(measured_parameter) FROM test join test_data where test.test_number = test_data.test_number AND test_descriptor = 'Min IL (dB)' AND tracked_component_number = '$device' AND attenuation = 0 GROUP BY temperature"); $row = mysql_num_rows($IL); print "$row<br>"; $i = 0; if ($i < $row) { $value = mysql_fetch_row($IL); $bmk_IL_0 = $value[0]; echo ("$bmk_IL_0 <br>"); } $i = $i++; if ($i < $row) { $value = mysql_fetch_row($IL); $bmk_IL_25 = $value[0]; echo ("$bmk_IL_25 <br>"); } $i = $i++; if ($i < $row) { $value = mysql_fetch_row($IL); $bmk_IL_70 = $value[0]; echo ("$bmk_IL_70 <br>"); } // Instanciate Word $word = new COM("word.application") or die("Unable to instantiate Word"); echo "$word\n"; // specify the MS Word template document $dts_template = "/Inranet/departments/manufacturing/Customer_DataSheet_v2.doc"; // open the template document $word->Documents->Open($dts_template); //get the current date MM/DD/YYYY $current_date = date("m/d/Y"); echo "$current_date\n"; //assign bookmark name to the varalbles $bmk_date = "date"; $bmk_device = "device_sn"; $bmk_name = "name"; $bmk_IL_0 = "IL_0"; $bmk_IL_25 = "IL_25"; $bmk_IL_70 = "IL_70"; //create a new MS Word Range (to enable text substitution) $dateobj = $word->ActiveDocument->Bookmarks($bmk_date); $deviceobj = $word->ActiveDocument->Bookmarks($bmk_device); $ilobj = $word->ActiveDocument->Bookmarks($bmk_IL_0); $date_range = $dateobj->Range; $device_range = $deviceobj->Range; $il_range = $ilobj->Range; //Substitute the bookmark with actual value $date_range->Text = $bmk_date; $device_range->Text = $bmk_device; $il_range->Text = $bmk_IL_0; //$il_range->Text = $bmk_IL_25; //$il_range->Text = $bmk_IL_70; //Save the template as a new document $new_file = "/Intranet/departments/manufacturing/datasheet/'$device'_datasheet.doc"; $word->Documents[1]->SaveAs($new_file); //8. free the object $word->Quit(); $word->Release(); $word = null; ?>
  11. [!--quoteo(post=353550:date=Mar 10 2006, 04:08 AM:name=fooDigi)--][div class=\'quotetop\']QUOTE(fooDigi @ Mar 10 2006, 04:08 AM) [snapback]353550[/snapback][/div][div class=\'quotemain\'][!--quotec--] the function may be parsing the passed values literally, meaning that it will return true no matter what you pass it. try not to use the quotes when you are using numeric data types. [/quote] Thanks. I did try as follows and removed all the quotes. Hope that's what you suggested. No matter what i changed, it still works in Internet Explorer. But still it doesn't work in FireFox. Anymore suggestion please?? <input name="display" type="submit" id="Submit" value="Screen Display" onClick="chkAction(1)"> <input name="excel" type="submit" id="Submit" value="Save to EXCEL" onClick="chkAction(2)"> <script language="javascript"> function chkAction(val){ if (val==1){ document.form1.action="Query.php"; } else{ document.form1.action="autosave.php"; } thanks, Nirvana
  12. Hi All, Please see the codes I've written in the HTML form with two submit buttons. It works fine in IE but the buttons don't work in Firefox browser. Whichever button I press, it just calls up "Query.php" in Firefox. Any idea why it happens? I am new to Javascript and any input is much appreciated. <input name="display" type="submit" id="Submit" value="Screen Display" onClick="chkAction('1')"> <input name="excel" type="submit" id="Submit" value="Save to EXCEL" onClick="chkAction('2')"> <script language="javascript"> function chkAction(val){ if (val=="1"){ document.form1.action="Query.php"; } else{ document.form1.action="autosave.php"; } thanks, Nirvana
  13. Hi, I have an excel file with macro and was wondering if there is a way to open this excel file from PHP and run the macro. The short cut key to run macro is CTRL+SHIFT+A and is it als possible to send shortcut key in PHP? Any suggestion/input is much appreciated. thanks in advance, Nirvana
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.