Jump to content

Search the Community

Showing results for tags 'loop'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 21 results

  1. Hello there, I'm having an issue where my site won't stop reloading/refreshing when you initially go to any of the sites pages for the first time. It's like it gets stuck in a loop. It stops after you touch the screen a few times and/or go to another page. It seems to only be happening in Safari in mobile. I've been trying to figure out what might be causing this, but with no luck. Has anyone encountered this problem before? Or have any thoughts on what may be causing this? Here's a video of what happening: https://www.screenmailer.com/v/FQwkawa2W4kEmlg The link to the site is: http://www.allptscomm.oiw11.com Any and all help/thoughts are greatly appreciated! Thanks! mh
  2. Hi all, I would like to escape a loop if $mainRow's value has already been called. Here is what I have but it is not working. while ($stmt->fetch()) { $mail_main[] = $mainRow; $main_arr .= ''.$main_arr.', '.$mainRow.''; $main_arr_array = explode(",", $main_arr); if (in_array($mainRow, $main_arr_array, TRUE)){ continue; //break; } }
  3. I can not fix this script, because the output is not in sync. I have 3 arrays. 1) present column names. 2) prefix (fixed name). 3) suffix (uniqid value). Can someone explain how exactly I should create a foreach loop in a foreach loop with 3 arrays and fetching the field value from the get_result command as the the value it is related to. This would result in: <---->Present Column Name <-----> New Column Name <---->value1 <--------------------------------> value1_abcd <---->value2 <------------------------------> value2_abcd etc. <?php $prefix_arr = array( 'col_a' , 'col_b' ,'col_c' , 'col_d', 'col_e' , 'col_f' , 'col_g' , ) ; $col2 = uniqid(); $suffix = substr($col2, 5, 11); $servername = "localhost"; $username = "userx"; $password = "pass12345"; $dbname = "test_database"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $stmt = $conn->prepare("SHOW COLUMNS FROM table_xyz"); $stmt->execute(); $res = $stmt->get_result(); $pres_colname = $res; // var_dump($prefix_arr); foreach ($prefix_arr as $los_ele){ $prefix = $los_ele; // var_dump($prefix); // var_dump($suffix); $col_new = $prefix."_".$suffix; //var_dump($col_new); foreach ($pres_colname as $val){ $col = $val['Field']; // var_dump($col); ?> <br><input type="text" value =" <?php echo $col; ?>"><input type="text" value ="<?php echo $col_new;?>"> <?php $stmt = $conn->prepare("ALTER TABLE `table_xyz` CHANGE COLUMN `$col` `$col_new` VARCHAR(30) NOT NULL;"); $stmt->execute(); } } //$stmt->close(); $conn->close(); ?> The complicated thing this time is that I need the exact 'Field' value which is an output of get_result, so I can not fit it in.
  4. This script shows the fetched data in a modify form. In the old situation I used rec_num wich was corresponding to the record number in the database.table For security reasons I added a uniqid column to the table. So not like under with an input hidden attribute for uniqid. If possible I would like it to be stored in a session variable. This is doable like above, but outside the foreach loop only the last value is stored. How to connect every single uniqid value (for multiple records!) to the separated rec_num without users being able to see the uniqid? $value = $_POST['checkbox_values']; $i=0; foreach ($value as $values) { if (++$i > 10) break ; $element = explode(" / " , $values); $_SESSION['uniqid'] = $element[1]; var_dump($_SESSION['uniqid']); ?> <form action = "" method="post"> <input type ="hidden" name="rec_num[]" value="<?php echo $element[0] ;?>" > <!--<input type ="hidden" name="uniqid[]" value="<?php echo $element[1] ;?>" >--> <input type ="text" name="value1[]" value="<?php echo $element[5] ;?>" > <input type ="text" name="value2[]" value="<?php echo $element[6] ;?>" > <input type ="text" name="value3[]" value="<?php echo $element[7] ;?>" > <input type ="text" name="value3[]" value="<?php echo $element[8] ;?>" > <br> <?php } ?><br> <input type="submit" name="send" value="Modify "> </form>
  5. I was try make loop in loop with array. it should be like: L1: T1&C1---L1: T2&C2---L1: T3&C3--- L2: T1&C1---L2: T2&C2---L2: T3&C3--- L3: T1&C1---L3: T2&C2---L3: T3&C3--- But I got other than that i thought, so what did i wrong?
  6. My goal is to loop with foreach through two variables. So I found this script; <?php $abc = array('Mark','Laura'); $add = array('cocktails','champagne'); $array = array($abc,$add); foreach ($array as list($arr1, $arr2)) { // echo '<br>'; echo '<br>'; echo $arr1; echo '<br>'; echo $arr2; } But the output is not wat is desired. It says: And I would rather have: Is there any function / command in the php array reference to do this or should other code be used?
  7. So I have this function that firsts asks the player, which player they are, then asks them a question. if they get it right their score increases by one, and an alert pops up that says correct. The problem is, after you answer a question, an alert pops up that says correct, and then another question pops up. No matter what your answer is nothing happens afterwards. Basically after everything happens, another question comes up but it shouldn't. Can anyone tell me if there is anything wrong with my code that might make this happen? function question(question, answer) { this.question = question; this.answer = answer;}var a = new question("What letter comes after 'a'?", "b")var b = new question("What letter comes after 'b'?", "c")var allquestions = [a, b];var player1total = 0;var player2total = 0;var player3total = 0; function ask(){ var num = Math.floor(Math.random() * allquestions.length); var questions_obj = allquestions[num]; var player = prompt("What player are you?" + " (Hint: use your player number not your name.)"); if (player = "1"){ var trivia = prompt(questions_obj.question); if (trivia === questions_obj.answer){ player1total = player1total + 1; document.getElementById("player1score").innerHTML = player1total; var correct = alert("That is correct!"); $("#character1").animate({top: "-=100px"}, 500); } else{ var incorrect = alert("That is incorrect!"); } } if (player = "2"){ var trivia = prompt(questions_obj.question); if (trivia == questions_obj.answer){ player2total = player2total + 1; document.getElementById("player2score").innerHTML = player2total; var correct = alert("That is correct!"); } else{ var incorrect = alert("That is incorrect!"); } } if (player = "3"){ var trivia = prompt(questions_obj.question); if (trivia == questions_obj.answer){ player3total = player3total + 1; document.getElementById("player3score").innerHTML = player3total; var correct = alert("That is correct!"); } else{ var incorrect = alert("That is incorrect!"); } }}
  8. producttable : id | mid | pid | owgh | nwgh | 1 3 12 1.5 0.6 2 3 12 1.5 0.3 3 3 14 0.6 0.4 4 3 15 1.2 1.1 5 4 16 1.5 1.0 6 4 17 2.4 1.2 7 3 19 3.0 1.4 8 3 19 3.0 1.2 I need result in while loop as **below** : as per mysql query $sql = "SELECT pid,owgh,nwgh from produttable WHERE mid = 3 "; **RESULT I WANT AS BELOW :** Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 12 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 -------------------------------- 15 1.2 1.1 Tot: 1.2 1.1 -------------------------------- 19 3.0 1.4 19 3.0 1.2 Tot: 6.0 2.6 $query = mysql_query($sql); echo"<table> <tr> <td> Product Id </td> <td> Old Weight </td> <td> New Wight </td> </tr> "; while($row = mysql_fetch_array($query )){ echo "<tr>"; echo "<td>".$row['pid']."</td>"; echo "<td>".$row['owgh']."</td>"; echo "<td>".$row['nwgh']."</td>"; echo "</tr>"; echo "<tr><td>-----</td> <td>Tot : </td> <td> </td></tr>"; } echo " </table>"; But result i am getting is as below Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 -------------- Tot 12 1.5 0.3 ---------------Tot 14 0.6 0.4 ---------------Tot 15 1.2 1.1 ---------------Tot 19 3.0 1.4 ---------------Tot 19 3.0 1.2which i dont want , **i want as below** : Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 12 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 -------------------------------- 15 1.2 1.1 Tot: 1.2 1.1 -------------------------------- 19 3.0 1.4 19 3.0 1.2 Tot: 6.0 2.6 **Update : 27/3/2015**Can i get below result, with sum of each Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 12 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 -------------------------------- 15 1.2 1.1 Tot: 1.2 1.1 -------------------------------- 19 3.0 1.4 19 3.0 1.2 Tot: 6.0 2.6------------------------------------------Grand Total : 6.3 5 Note in above Old weight : repeat value is not added thats 1.5 , 3.0 is coming twice hence while addition takensingle of it**OR** Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 -------------------------------- 15 1.2 1.1 Tot: 1.2 1.1 -------------------------------- 19 3.0 1.4 3.0 1.2 Tot: 6.0 2.6------------------------------------------ Grand Total : 6.3 5Note in above Old weight : repeat value is not added thats 1.5 , 3.0 is coming twice hence while addition takensingle of it as product id 12, 19 are coming twice hence shown once with its resp valuePlease help me, if i am wrong in HTML tr td format please correct me , it not necessary to get in same table tr,td ..i just want my result in above format
  9. producttable : id | mid | pid | owgh | nwgh | 1 3 12 1.5 0.6 2 3 12 1.5 0.3 3 3 14 0.6 0.4 4 3 15 1.2 1.1 5 4 16 1.5 1.0 6 4 17 2.4 1.2 7 3 19 3.0 1.4 8 3 19 3.0 1.2 I need result in while loop as **below** : as per mysql query $sql = "SELECT pid,owgh,nwgh from produttable WHERE mid = 3 ";**RESULT I WANT AS BELOW :** Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 12 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 -------------------------------- 15 1.2 1.1 Tot: 1.2 1.1 -------------------------------- 19 3.0 1.4 19 3.0 1.2 Tot: 6.0 2.6 $query = mysql_query($sql); echo"<table> <tr> <td> Product Id </td> <td> Old Weight </td> <td> New Wight </td> </tr> "; while($row = mysql_fetch_array($query )){ echo "<tr>"; echo "<td>".$row['pid']."</td>"; echo "<td>".$row['owgh']."</td>"; echo "<td>".$row['nwgh']."</td>"; echo "</tr>"; echo "<tr><td>-----</td> <td>Tot : </td> <td> </td></tr>"; } echo " </table>"; But result i am getting is as below Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 -------------- Tot 12 1.5 0.3 ---------------Tot 14 0.6 0.4 ---------------Tot 15 1.2 1.1 ---------------Tot 19 3.0 1.4 ---------------Tot 19 3.0 1.2which i dont want , **i want as below** : Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 12 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 -------------------------------- 15 1.2 1.1 Tot: 1.2 1.1 -------------------------------- 19 3.0 1.4 19 3.0 1.2 Tot: 6.0 2.6 **Update : 27/3/2015**Can i get below result, with sum of each Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 12 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 -------------------------------- 15 1.2 1.1 Tot: 1.2 1.1 -------------------------------- 19 3.0 1.4 19 3.0 1.2 Tot: 6.0 2.6**OR** Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 -------------------------------- 15 1.2 1.1 Tot: 1.2 1.1 -------------------------------- 19 3.0 1.4 3.0 1.2 Tot: 6.0 2.6 as product id 12, 19 are coming twice hence shown once with its resp valuePlease help me, if i am wrong in HTML tr td format please correct me , it not necessary to get in same table tr,td ..i just want my result in above format
  10. Hi everyone, I tried to make a video which will start at the beginning and star over again <video id="Video1" controls autoplay loop> <source src="VideoXYZ.mp4" type="video/mp4"> <source src="VideoXYZ" type="video/webm"> <source src="VideoXYZ" type="video/ogg"> Your Browser does not support the video tag </video> But I want to loop the video 5 or 7 times then it definitely stops until I refresh the page, and of course I don't have a clue how to make a timer to LOOP. First, is it possible to do this? if yes, how to do it? Thank you
  11. Basically what I am trying to do is, first you enter a number, which will be the number of time the loop should run. When all details entered, it should print out like a payslip for all entries, name, wage, marital status etc..Now the problem is, when I enter example 2 for the loop(numWorkers) at the last round, it will come up with some error in the line of nameWorker[i] = input.next(); Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 20. Also got some problem with the wage obviously im trying to send a double to the wageCalc method, but just cant get it running. Tried plenty of different versions. Anyone could help me on this please? import java.util.Scanner; public class morePay2 { public static double wageCalc(double ratE, double hourS){return (ratE * hourS);} public static void main(String[] args) { Scanner input = new Scanner(System.in); int numWorkers = 0, i = 1; double intWorkedHours = 0, intHourlyRate = 0; System.out.print("Please type in the number of workers: "); numWorkers = input.nextInt();String[] nameWorker = new String[numWorkers];String[] hourlyRate = new String[numWorkers];String[] workedHours = new String[numWorkers];String[] maritalStat = new String[numWorkers];String[] wage = new String[numWorkers]; for (i = 1; i <= numWorkers; i++){System.out.print("Please type in the name: ");nameWorker[i] = input.next();System.out.print("Please type in hourly rate: ");hourlyRate[i] = input.next();System.out.print("Please type in worked hours: ");workedHours[i] = input.next();System.out.print("Please type in marital status(married/single): ");maritalStat[i] = input.next();intHourlyRate = Double.parseDouble(hourlyRate[i]);intWorkedHours = Double.parseDouble(workedHours[i]);wage[i] = wageCalc(intHourlyRate, intWorkedHours);} for (i = 1; i <= numWorkers; i++){System.out.println(nameWorker[i] + " has earned " + wage[i] );} } }
  12. Dear All; Need your help. I am programming students' roll call in ASP with SQL 2008 R2. There are about 100 students. By default option selected is 'Present' using drop down list. I tried to use radio buttons but only one button remains selected so I am using drop-down list ( How to select multiple radio buttons?). After selecting "Present", "Absent","Late" etc, how do I insert all 100( or whatever number) of rows in the SQL table simultaneously? How should I use "for", "loop" or any other method? Please guide. Regards DAMODAR
  13. Hi, I just started to study javascript and I came across in one of your page to the following notation: var text=""; The page is from w3school tutorial: http://www.w3schools.com/js/tryit.asp?filename=tryjs_loop_for_ex I do not understand what it means and why should be used in the loop of the above example. I tried to define var text; in its place but the result is: undefinedThe number is 0The number is 1The number is 2The number is 3The number is 4 The only difference is the world 'undefined' at the beginning of the first line. Many thanks in advance for your help
  14. function getPassword(){ var correct = "HTML5"; var guess = ""; while (guess != correct){ guess = prompt("Password?"); } // end while alert("You may proceed"); } Hey guys, I am a newbie, here, so it would be much appreciated if you guys could clarify this issue for me. As you can see the above javascript function (asking the user to enter the correct password after they click on the button or the loop will continue forever), my question is that, why do we need to set the "guess" variable's value to empty in this case, why don't we just leave it as undefined(var guess;), I've seen other people's codes like that as well, they always set the initialization variable's value to empty. The second question is, why do we have "guess = prompt('Password?')", is it okay if I just write "prompt = ('Password?')". Please help me guys, any suggestions are greatly appreciated. God bless you.
  15. how can i loop a result from a php function to loop through each 'id'? like for all 'sid's, i want to use following function to get data... /* above this i calculate value for each $cqty */$cqty = $oqty + $inqty - $outqty;$camt = "select date, pqty, prate, pamt from stock stjoin purchase p on st.sid = p.sid where st.sid = $sidunion allselect date, -sqty, srate, samt from stock stjoin sales s on st.sid = s.sid where st.sid = $sidunion allselect null, oqty, oprice, oamt from stock where sid = $sidorder by date asc";$dataSet = array();$camtresult = mysqli_query($connect, $camt);while ($row = mysqli_fetch_array($camtresult)){ $dataSet[] = $row;}function camt($dataSet, $cqty){ $totalPurchaseValue = 0; $totalPurchaseQty = 0; $done = false; foreach($dataSet as $row) { // skip sales rows if ($row['pqty'] < 0) { continue; } for ($i=0; $i<$row['pqty']; $i++ ) { $totalPurchaseQty++; $totalPurchaseValue += $row['prate']; if ($totalPurchaseQty == $cqty) { return $totalPurchaseValue; } } } return $totalPurchaseValue;}// Determine the $countOfGoodsForSale$crate = camt($dataSet, $cqty) / $cqty;$camt = $cqty*$crate; i tried while loop but it said--- please guide through
  16. // * * * * * * * *Get all the vars * * * * * * *$name = filter_input(INPUT_POST, 'companyName', FILTER_SANITIZE_SPECIAL_CHARS); $contact = filter_input(INPUT_POST, 'contact', FILTER_SANITIZE_SPECIAL_CHARS);$phone = filter_input(INPUT_POST, 'phone', FILTER_SANITIZE_SPECIAL_CHARS);$email_from = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_SPECIAL_CHARS);$invNo = filter_input(INPUT_POST, 'invNO', FILTER_SANITIZE_SPECIAL_CHARS); $queryType = filter_input(INPUT_POST, 'typeOfQueryDropDownBox', FILTER_SANITIZE_SPECIAL_CHARS);$details = filter_input(INPUT_POST, 'details', FILTER_SANITIZE_SPECIAL_CHARS);$generalDetails = filter_input(INPUT_POST, 'generalDetails', FILTER_SANITIZE_SPECIAL_CHARS);$hireRatesCB = filter_input(INPUT_POST, 'hireRatesCB', FILTER_SANITIZE_SPECIAL_CHARS);$supplyRatesCB = filter_input(INPUT_POST, 'supplyRatesCB', FILTER_SANITIZE_SPECIAL_CHARS);$salesmanVistCB = filter_input(INPUT_POST, 'salesmanVistCB', FILTER_SANITIZE_SPECIAL_CHARS); $email_message = "---------- Customer Details ----------nn"; $email_message .= "Company Name: ".($name)."n"; $email_message .= "Contact: ".($contact)."n"; $email_message .= "Phone: ".($phone)."n"; $email_message .= "Email: ".($email_from)."n"; $email_message .= "---------- Invoice Query ----------"."nn"; $email_message .= "Invoice No/Contract No: ".($invNo)."n"; $email_message .= "Type of Query: ".($queryType)."n"; $email_message .= "Details: ".($details)."n"; $email_message .= "---------- General Query ----------"."nn"; $email_message .= "Details: ".($generalDetails)."n"; $email_message .= "Request hire rates: ".($hireRatesCB)."nn"; $email_message .= "Supply catalogues: ".($supplyRatesCB)."nn"; $email_message .= "Salesman visit: ".($salesmanVistCB)."nn"; $email_to = "chris.harwood@hotmail.com"; $email_subject = "QUERY form from - " . $name . ", has been filled in.";// Mail Push'Reply-To: '.$email_from."rn" .'X-Mailer: PHP/' . phpversion();mail($email_to, $email_subject, $email_message); ?> <!-- Confirmation message -->Thank you for contacting us. We will be in touch with you very soon. Hi all, On my very basic form http://lannister.info/test/query.html I have a function that creates another invoice query box. It adds _1, _2 etc to the end of the var names.I'm not sure how to capture these additional vars on the PHP end and output them into the e-mail. I image I need to create an array for the vars and check for additional values with a loop? Not sure where to go from here. Many thanks!
  17. I need to loop through an array, in the order that the items appear, and get both the key of the item and its value. I know I can use foreach to loop through an array but as far as I know I can choose between the key and the value of the current item but not get both. Here's an example of an array: <?php$SampleArray = array(55 => "car","2" => "house","boat" => "boat",0 => "engine",666 => "website",);?> It would work somehow like this: loop($SampleArray){ echo key . " - " value . "n";} And the result would be something like:55 - car 2 - house boat - boat 0 - engine 666 - website
  18. Hi, I have form that displaying report per week. First thing to do is choose what week then automatically display the date/shift that week ranges. here is my weekly_report.php <?php error_reporting(0); session_start(); ob_start(); date_default_timezone_set("Asia/Singapore"); include('connection.php'); ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><title>Weekly Report</title><head><link rel="stylesheet" type="text/css" href="op_report.css" /><script type="text/javascript" src="jquery.js"></script><script type='text/javascript' src='jquery.autocomplete.js'></script><link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" /><script type="text/javascript">//----auto complete week--//$().ready(function() { $("#week_selected").autocomplete("get_week_list.php", { width: 115, matchContains: true, mustMatch: true, selectFirst: false }); $("#week_selected").result(function(event, data, formatted) { $("#week_number").val(data[1]); }); }); /*AJAX*/function AJAX(){ var xmlHttp; try{ xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari return xmlHttp; } catch (e){ try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer return xmlHttp; } catch (e){ try{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); return xmlHttp; } catch (e){ alert("Your browser does not support AJAX!"); return false; } } } } //-----get weekdata from week---//function getweekdata() { // if (window.event.keyCode==13 || window.event.keyCode==10) { divid = "week_data"; var url = "get_weekly_data.php"; var str = "id=" + document.getElementById("week_number").value; var xmlHttp = AJAX(); xmlHttp.onreadystatechange = function(){ if(xmlHttp.readyState > 0 && xmlHttp.readyState < 4){ // document.getElementById(divid).innerHTML=loadingmessage; } if (xmlHttp.readyState == 4) { if (xmlHttp.status == 200) { var jsonart = xmlHttp.responseText; document.getElementById(divid).innerHTML = jsonart; } } } xmlHttp.open("POST", url, true); xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlHttp.setRequestHeader("Content-length", str.length); xmlHttp.setRequestHeader("Connection", "close"); xmlHttp.send(str); // } } </script></head><body onload=document.getElementById("week_selected").focus();><form name="weekly_report" action="" method="post"><div id="ddcolortabs"><ul><li> <a href="index.php" title="Operator's Shift Report"><span>Operator's Shift Report</span></a></li><li id="current"> <a href="weekly_report.php" title="Reports"><span>Reports</span></a></li></ul></div><br/><div><table><tr><td style="border: none;">Type Week:</td><td><input type="text" name="week_selected" id="week_selected" value="" size="15" onkeyup="getweekdata();"></td></tr></table></div><input type="hidden" name="week_number" id="week_number"><div id='week_data'></div></form></body></html> //get_week_list.php <?phpob_start();include "connection.php";$q = strtolower($_GET["q"]);if ($q == '') { header("HTTP/1.0 404 Not Found", true, 404); }//else (!$q) return;else{$sql = "select week_id, week_number from week_list where week_number LIKE '$q%'";$rsd = mysql_query($sql);$cnt = mysql_num_rows($rsd); if($cnt > 0) { while($rs = mysql_fetch_array($rsd)) { $pid = $rs['week_id']; $pname = $rs['week_number']; echo "$pname|$pidn"; } } else { header("HTTP/1.0 404 Not Found", true, 404); }}?> and here is my get_weekly_data.php // which display the data for that week. <?phpob_start();include "connection.php";if($_POST["id"]){ $sql = "select r.report_date, s.shift_type FROM op_reports AS r, shift_list AS s WHERE WEEK(report_date) + 1 = '" . ($_POST["id"]) . "' GROUP BY shift_type ORDER BY shift_id ASC"; $res = mysql_query($sql); echo "<table>"; echo "<tr>"; echo "<th>Comp</th>"; while($row = mysql_fetch_assoc($res)) { $report_date = $row['report_date']; $report_shift = $row['shift_type']; echo "<th>$report_date/$report_shift</th>"; } echo "</tr>"; $sql_r = "select r.report_date, s.shift_type FROM op_reports AS r, shift_list AS s WHERE WEEK(report_date) + 1 = '" . ($_POST["id"]) . "' GROUP BY shift_type ORDER BY shift_type DESC"; $res_r = mysql_query($sql_r); echo "<tr>"; echo "<th></th>"; while($r = mysql_fetch_assoc($res_r)){ echo "<th>Output</th>"; } echo "</tr>"; $sql_comp = "SELECT DISTINCT p.process_name , r.process_id, r.report_shift FROM op_reports AS r JOIN process_list AS p ON (p.process_id = r.process_id) WHERE WEEK(report_date) + 1 = '" . ($_POST["id"]) . "' GROUP BY process_name ORDER BY p.process_name ASC"; $res_comp = mysql_query($sql_comp); echo "<tr>"; while($row_comp = mysql_fetch_assoc($res_comp)) { $process = $row_comp['process_name']; $process_id = $row_comp['process_id']; echo "<td>$process</td>"; $comp = "SELECT DISTINCT o.compound_type, o.process_id, o.shift_date FROM op_output AS o WHERE process_id = '$process_id' GROUP BY o.shift_id, compound_type ORDER BY compound_type ASC"; $c = mysql_query($comp); echo "<tr>"; while($co = mysql_fetch_assoc($c)) { $compound_type = $co['compound_type']; $process_i = $co['process_id']; $shift_date = $co['shift_date']; echo "<td>$compound_type</td>"; $sql_output = "SELECT DISTINCT o.compound_type, SUM(o.compound_output) AS compound_output, o.process_id, o.shift_id, o.shift_date FROM op_output AS o WHERE process_id = '$process_id' AND o.compound_type = '$compound_type' GROUP BY o.shift_id, o.shift_date, compound_type ORDER BY o.shift_id ASC"; $res_output = mysql_query($sql_output); while($row_output = mysql_fetch_assoc($res_output)) { $compound_output = $row_output['compound_output']; $shift = $row_output['shift_id']; $compound = $row_output['compound_type']; $date = $row_output['shift_date']; if($shift == 1 && $date == $shift_date) { echo"<td>$compound_output</td>"; } else { echo "<td></td>"; } if($shift == 2 && $date == $shift_date) { echo"<td>$compound_output</td>"; } else { echo "<td></td>"; } if($shift == 3 && $date == $shift_date) { echo"<td>$compound_output</td>"; } else { echo "<td></td>"; } if($shift == 4 && $date == $shift_date) { echo"<td>$compound_output</td>"; } else { echo "<td></td>"; } if($shift == 5 && $date == $shift_date) { echo"<td>$compound_output</td>"; } else { echo "<td></td>"; } } echo "</tr>"; } } echo "</tr>"; echo "</table>"; }?> My problem now is on displaying of output per date/shift. It's been todays that I tried to fixed this. I hope somebody can help me. Thank you so much
  19. Hello! I wanna create a form that can send sms to multiple recipient, i've created a form that uses javascript to add or remove textbox dynamically, this code successfully send sms when i fill one recipient number, but fails to send more than one recipient, and as i try to make it send sms to more than one user by making it loop, i get this error, Can someone help? i want to know how do i make this form sends sms towards multiple user Warning: Invalid argument supplied for foreach() <script language="javascript"> function addRow(tableID) { var table = document.getElementById(tableID); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var cell1 = row.insertCell(0); var element1 = document.createElement("input"); element1.type = "checkbox"; element1.name="chkbox[]"; cell1.appendChild(element1); var cell2 = row.insertCell(1); cell2.innerHTML = rowCount + 1; var cell3 = row.insertCell(2); var element2 = document.createElement("input"); element2.type = "text"; element2.name = "CTL_TEL"; cell3.appendChild(element2); } function deleteRow(tableID) { try { var table = document.getElementById(tableID); var rowCount = table.rows.length; for(var i=0; i<rowCount; i++) { var row = table.rows[i]; var chkbox = row.cells[0].childNodes[0]; if(null != chkbox && true == chkbox.checked) { table.deleteRow(i); rowCount--; i--; } } }catch(e) { alert(e); } } </SCRIPT> <?php error_reporting(E_ALL ^ E_NOTICE);//Example$gsm_send_sms = new gsm_send_sms();$gsm_send_sms->debug = false;$gsm_send_sms->port = 'COM6';$gsm_send_sms->baud = 115200;$gsm_send_sms->init();$name="CTL_TEL[]";foreach ($tel as $_POST['CTL_TEL']) {$status = $gsm_send_sms->send($_POST["CTL_TEL"] , $_POST["CTL_MSG"]);$status = $gsm_send_sms->send($tel , $_POST["CTL_MSG"]); if ($status) { echo "Message sent\n";} else { echo "Message not sent\n";}}$gsm_send_sms->close(); //Send SMS via serial SMS modemclass gsm_send_sms { public $port = 'COM6'; public $baud = 115200; public $debug = false; private $fp; private $buffer; //Setup COM port public function init() { $this->debugmsg("Setting up port: \"{$this->port} @ \"{$this->baud}\" baud"); exec("MODE {$this->port}: BAUD={$this->baud} PARITY=N DATA=8 STOP=1", $output, $retval); if ($retval != 0) { throw new Exception('Unable to setup COM port, check it is correct'); } $this->debugmsg(implode("\n", $output)); $this->debugmsg("Opening port"); //Open COM port $this->fp = fopen($this->port . ':', 'r+'); //Check port opened if (!$this->fp) { throw new Exception("Unable to open port \"{$this->port}\""); } $this->debugmsg("Port opened"); $this->debugmsg("Checking for responce from modem"); //Check modem connected fputs($this->fp, "AT\r"); //Wait for ok $status = $this->wait_reply("OK\r\n", 5); if (!$status) { throw new Exception('Did not receive responce from modem'); } $this->debugmsg('Modem connected'); //Set modem to SMS text mode $this->debugmsg('Setting text mode'); fputs($this->fp, "AT+CMGF=1\r"); $status = $this->wait_reply("OK\r\n", 5); if (!$status) { throw new Exception('Unable to set text mode'); } $this->debugmsg('Text mode set'); } //Wait for reply from modem private function wait_reply($expected_result, $timeout) { $this->debugmsg("Waiting {$timeout} seconds for expected result"); //Clear buffer $this->buffer = ''; //Set timeout $timeoutat = time() + $timeout; //Loop until timeout reached (or expected result found) do { $this->debugmsg('Now: ' . time() . ", Timeout at: {$timeoutat}"); $buffer = fread($this->fp, 1024); $this->buffer .= $buffer; usleep(200000);//0.2 sec $this->debugmsg("Received: {$buffer}"); //Check if received expected responce if (preg_match('/'.preg_quote($expected_result, '/').'$/', $this->buffer)) { $this->debugmsg('Found match'); return true; //break; } else if (preg_match('/\+CMS ERROR\:\ \d{1,3}\r\n$/', $this->buffer)) { return false; } } while ($timeoutat > time()); $this->debugmsg('Timed out'); return false; } //Print debug messages private function debugmsg($message) { if ($this->debug == true) { $message = preg_replace("%[^\040-\176\n\t]%", '', $message); echo $message . "\n"; } } //Close port public function close() { $this->debugmsg('Closing port'); fclose($this->fp); } //Send message public function send($tel, $message) { //Filter tel $tel = preg_replace("%[^0-9\+]%", '', $tel); //Filter message text $message = preg_replace("%[^\040-\176\r\n\t]%", '', $message); $this->debugmsg("Sending message \"{$message}\" to \"{$tel}\""); //Start sending of message fputs($this->fp, "AT+CMGS=\"{$tel}\"\r"); //Wait for confirmation $status = $this->wait_reply("\r\n> ", 5); if (!$status) { //throw new Exception('Did not receive confirmation from modem'); $this->debugmsg('Did not receive confirmation from modem'); return false; } //Send message text fputs($this->fp, $message); //Send message finished indicator fputs($this->fp, chr(26)); //Wait for confirmation $status = $this->wait_reply("OK\r\n", 180); if (!$status) { //throw new Exception('Did not receive confirmation of messgage sent'); $this->debugmsg('Did not receive confirmation of messgage sent'); return false; } $this->debugmsg("Message sent"); return true; }}?> <html><head><title>SMS via GSM</title><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><style> .clbody { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:9pt; font-weight:normal;}.clfooter { font-family:Verdana; font-size:7pt; font-weight:normal;}h1, .h1 { width:100%; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:18px; font-weight:bold;}hr, .hr { color:#b0b0b0;}</style></head><body class="clbody"><h1>SMS via GSM</h1><div style="WIDTH:700px"></div><hr size="1"><?phperror_reporting(E_ALL ^ E_NOTICE);?><form action="" method="post" name="myForm"><table class ="clbody" width="700" border="1"> <tr> <td valign="top">Recipient:</td> <td valign="top"> <INPUT type="button" value="Add Row" onclick="addRow('dataTable')" /> <INPUT type="button" value="Delete Row" onclick="deleteRow('dataTable')" /> <TABLE id="dataTable" width="350px" border="1"> <TR> <TD><INPUT type="checkbox" name="chk"/></TD> <TD> 1 </TD> <TD> <input type="text" name="CTL_TEL" value="<?php echo $_GET['CTL_TEL']; ?>"> </TD> </TR> </TABLE> </td> </tr> <tr> <td valign="top">Message:</td> <td valign="top"> <input style="width: 250px" type="text" name="CTL_MSG" value="<?php echo $_GET['CTL_MSG']; ?>"></td> </tr> <tr> <td valign="top">Result code:<font color=green></td> <td valign="top"></td> </tr> <tr> <td valign="top"> </td> <td valign="top"><input size="25" type="submit" value="Send" name="CTL_SEND" style="height: 23px; width: 250px"></td> </tr></table><br><br></form></body></html>
  20. Hello everyone.There is a small problem with a drop-down form field I am trying to get work. I've this peace of code: <select name="pot"> <option value="0" selected="selected">1</option> <?php for($p=0.12; $p<=5; $p++){ ?> <option value="<?php echo $p ?>"></option> <?php } ?> </select> and what I get is this: <select name="pot"> <option value="0" selected="selected">1</option> <option value="0.12"></option> <option value="1.12"></option> <option value="2.12"></option> <option value="3.12"></option> <option value="4.12"></option> </select> but it should be like this: <select name="pot"> <option value="0" selected="selected">1</option> <option value="0.12">2</option> <option value="0.24">3</option> <option value="0.36">4</option> <option value="0.48">5</option> <option value="0.60">6</option> </select> please notice, first option is selected and it's value is 0.
  21. Hello everyone,I recently created a blog on tumblr to showcase video contributions for a project I launched. I was intending to have the videos loop once played and I am struggling. I looked online and found all the appropriate codes to create loops and although the videos obediently follow instructions when played in my browser they refuse to loop once I embed them in the blog.I am very new to HTML and was advised to "use the Plain Text Editor to create or edit advanced post embeds or to control element formatting via HTML" I really don't know what that means. My blog sits here: www.thenonresidents.tumblr.comand the first video in question is: Within the HTML editor for the theme I assume this is the relevant bit for me /* Video Entry Markup */ .video {width: 250px;margin: 0 0 10px -30px;{block:PermalinkPage}width: 500px;margin: 0;{/block:PermalinkPage}} /* End Video Entry Markup * Could someone please help me with the code and let me know just what I need to edit to allow the videos to loop.Thank you so much for your time.
×
×
  • Create New...