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

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

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


Age


Donation Link

  1. I am trying to declare javascript variables from php array values using a loop. Trying to declare javascript var h1 as php array value from $array[1][h], and h2 as $array[2][h], and h3 as $array[3][h],and so on... Here is my code: <SCRIPT LANGUAGE="JavaScript"> for (var i=0;i<61;i++) { var h[i] = "<?php echo $array[i][h] ?>"; var hl[i] = "<?php echo $array[i][hl] ?>"; var hs[i] = "<?php echo $array[i][hs] ?>"; } </script> When I <script type="text/javascript"> document.write(h1); </script> it is blank
  2. I've narrowed down my problem to this function... The page won't load, I suspected it was because it was stuck in a loop, but I couldn't see why, checking the error log confirmed this, as there were hundreds of errors for an undeclared variable.... I can't figure out why it is stuck in this loop, and I can't get the undeclared variable to go away, I even renamed it and it is still saying the old name of the variable is undeclared even though it isn't mentioned in the code anywhere I've renamed it.... Can anyone spot what is causing me grief? The only thing that would make sense would be if I wasn't updating the files when I uploaded them, but I am completely certain that I am... error log: code: while ($i<=14) { if($replacement_company_PartNo[$i] = NULL) { //this isn't an item from the database, simply print the description $replacement_Description //write details to new delivery note via 'delnoteitems' $sql = "INSERT INTO `companyorders`.`delnoteitems`(`deliverNote`, `itemDesc`, `itemQuantity`, `itemNotes`, `company_PartNo`) VALUES ('$deliverNote', '$replacement_Part_Name[$i]', '$replacement_Quantity[$i]', '$replacement_Description[$i]', '$replacement_company_PartNo[$i]');" ; $result = mysql_query($sql); if(!$result) {echo "$sql<br>sql error! code: DL4-A031-$i. This isn't an item from the database, skipping write to 'fullnotestock'; however, 'delnoteitems' could not be written to. Round $i."; exit;} } else { //this is an item from the database, the stock listings must be updated as the item is listed onto the delivery note //write details to new delivery note via 'delnoteitems' $sql = "INSERT INTO `companyorders`.`delnoteitems`(`deliverNote`, `itemDesc`, `itemQuantity`, `itemNotes`, `company_PartNo`) VALUES ('$deliverNote', '$replacement_Part_Name[$i]', '$replacement_Quantity[$i]', '$replacement_Description[$i]', '$replacement_company_PartNo[$i]');" ; $result = mysql_query($sql); if(!$result) {echo "$sql<br>sql error! code: DL4-A032-$i. This is an item from the database, havent yet attempted to write to 'fullnotestock'; failed on 'delnoteitems' which could not be written to. Round $i."; exit;} //update the stock listing in 'fullstocklist' $sql = "UPDATE `fullstocklist` SET `Stock`='$stockfromdatabase[$i]' WHERE `company_PartNo`='$replacement_company_PartNo[$i]';" ; $result = mysql_query($sql); if(!$result) {echo "$sql<br>sql error! code: DL4-A033-$i. This is an item from the database, havent yet attempted to write to 'fullnotestock'; failed on 'delnoteitems' which could not be written to. Round $i."; exit;} } $i++; }
  3. 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 <?php ob_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|$pid\n"; } } 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. <?php ob_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>"; } ?> I attached my sample screenshots that display by this code and also a format that I need to display and the database. 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 sample updated.zip
  4. Good day, I have a question using for loop for pagination and setting up the Adjustment. This what I've done. $offs = 0; $numberofrecords = 20; $totalrecords = 490; $totalView = 5; $page = 1; $result = ''; $result .= '<ul class="pagination">'; for ($i=1; $i<=$totalrecords; $i++) { if ($i % $numberofrecords==0) { if($offs == $offset){ $result .= '<li class="active" onclick="paginate('.$offs.')">'.$page.'</li>'; } $result .= '<li onclick="paginate('.$offs.')">'.$page.'</li>'; $offs += $numberofrecords; $page += 1; } } $result .= '</ul>'; The output will be: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 >> My question is how do I set up the adjustment. Adjustment means I am on page 8 and I've got 24 pagination links so the pagination will show something like $offset = 140; << 6 7 8 9 10 .. 20 >> How do I do that using the given loop? I'm sorry I am not really good in looping.
  5. Hi all, I need a little help please. I've got some code that creates a socket and a echo server, but I'm not having any luck in getting it to run. I've got the socket created, and closes, but when I try to run the code inside the "Do" "While" section the web page just hangs. I can see the port created on my server. Can some please shed some light at to what I'm doing wrong or what settings I need to change. My server is Apache/2.0.64 (Win32) PHP/5.2.17 .code below. Thanks in anticipation. Nev <?php error_reporting(E_ALL); /* Allow the script to hang around waiting for connections. */ set_time_limit(0); /* Turn on implicit output flushing so we see what we're getting * as it comes in. */ ob_implicit_flush(); $address = '192.168.0.7'; $port = 10001; if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) { echo "socket_create() failed: reason:1 " . socket_strerror(socket_last_error()) . "\n"; } if (socket_bind($sock, $address, $port) === false) { echo "socket_bind() failed: reason:2 $address" . socket_strerror(socket_last_error($sock)) . "\n"; } echo '<p>Hello World</p>'; if (socket_listen($sock, 5) === false) { echo "socket_listen() failed: reason:3 " . socket_strerror(socket_last_error($sock)) . "\n"; } do { if (($msgsock = socket_accept($sock)) === false) { echo "socket_accept() failed: reason:4 " . socket_strerror(socket_last_error($sock)) . "\n"; break; } /* Send instructions. */ $msg = "\nWelcome to the PHP Test Server. \n" . "To quit, type 'quit'. To shut down the server type 'shutdown'.\n"; socket_write($msgsock, $msg, strlen($msg)); do { if (false === ($buf = socket_read($msgsock, 2048, PHP_NORMAL_READ))) { echo "socket_read() failed: reason: " . socket_strerror(socket_last_error($msgsock)) . "\n"; break 2; } if (!$buf = trim($buf)) { continue; } if ($buf == 'quit') { break; } if ($buf == 'shutdown') { socket_close($msgsock); break 2; } $talkback = "PHP: You said '$buf'.\n"; socket_write($msgsock, $talkback, strlen($talkback)); echo "$buf\n"; } while (true); socket_close($msgsock); } while (true); socket_close($sock); ?>
  6. I'm designing a website for a wine wholesaler that needs to be able to update and display their product catalog in a certain specific way. The site in development is at www.metrocellars.com/new/ Let me first begin by outlining the database tables in use: location​ - a table of 6 records, the broader breakdown of geographic location (Brazil, California, etc.) These rows are used in the navigation menu, and each location has many "regions" referencing them. region​ - the more specific area of origin of each product (wine). Each "Region" references one of the 6 broader "Locations". product​ - The meat of the db, each Product record references a Producer/Winery (PID), a specific Region (RID - which also references a broader Location), and a specific Varietal (VID - Wine type/color). The left part of the image below shows part of the Product table. winery​ - This table holds records of each Winery/Producer referenced by PID in Product table. varietals - This table lists each type of wine, (Pinot, Merlot, etc) referenced by VID in the Product table. ​ On the right side of the above image, I included a visual of the relevant tables with FK relation lines. I haven't figured out which ON DELETE/UPDATE to use, as I got errors a couple times from child rows as I was assigning indexes/keys. I'm a little rusty with the SQL at the moment. Using this model, I need to be able to output the data to a wine list page, but I am having problems putting together the right queries and loops to list the data in the requested format. Here is an example of what the page content should look like when the 'region' California (LID = 2) is clicked on the nav menu. California Slo Down Wines http://www.slodownwines.com/ Broken Dreams Sexual Chocolate Central Coast Jackhammer http://jackhammerwine.com Pinot Noir Happy Canyon of Santa Barbara Cimarone Winery http://www.cimarone.com/ 3CV Bank 3CV Cilla’s Blend Le Clos Secret Gran Premio 3CV Estate Sauvignon Blanc Dragonette Cellars http://dragonettecellars.com/ GMS Rose Sauvignon Blanc Happy Canyon Vineyards http://happycanyonvineyard.com/ Ten Goal Merlot http://happycanyonvineyard.com/ Piocho Margerum Wine Company Sybarite Sauvignon Blanc Paso Robles Spaceman Vineyards Reserve Airspace Santa Barbara County Ampelos Cellars Syrache - Syrah & Grenache Margerum Wine Company http://www.margerumwinecompany.com/ Chenin Blanc M5 Riesling Uber Reserve Tercero http://tercerowines.com/ Grenache Grenache Blanc The Climb Santa Lucia Highlands Jackhammer http://jackhammerwine.com Chardonnay Santa Maria Tyler Winery Bien Nacido Pinot Noir Sta Rita Hills Ampelos Cellars http://ampeloscellars.com/ Pinot Noir Lambda Reserve Rho Reserve Viognier Dragonette Cellars http://dragonettecellars.com/ In the above list, each heading is a record of each "Region" with the same LID as California in the Location table. LID = 2, so I need to list each Region within California, and within each of those listings, list each Wine that has the same RID as that Region, but grouped by their respective Wineries. Basically, there are a few Wineries that have products (child rows I believe) with differing Regions of origin. So, there are products that can have the same PID, but different RID. You can get an idea of the format from the above example. My problem is, is how would I nest the loops and queries, and what joins would be necessary? Any and all help is a godsend. This has been quite a headache.
  7. if (is_array($_POST['uid'])) { foreach($_POST['hours']AS $keyd => $value) { echo "UPDATE participantlog SET noshow=1 AND hours=" . $value . " WHERE cid=" . $cid . " AND uid=" . $keyd . "<br>"; mysql_query("UPDATE participantlog SET noshow='1' AND hours='$value' WHERE cid='$cid' AND uid='$keyd'") or die(mysql_error()); } } For some reason my query isn't executing. The foreach is working properly and producing all the right variables (as verified by the echo). But it just isn't updating the DB. Why might this be? Thanks! Clinton
  8. I need help displaying more than 12 months on this project. I can't seem to make this loop work without repeating months of the year. All I really need is to display more than 12 months at a time. echo" "; date_default_timezone_set('America/Los_Angeles'); $dateComponents = getdate(); $month = $dateComponents['mon']; $year = $dateComponents['year']; $max = 0; while($max < 12){ if($month == 13){ $month = 1; $year++; } $thisMonth = date("F", mktime(0, 0, 0, $month, 1, 2012)); echo "#$thisMonth$year "; $month++; $max++; } echo " "; ?>
  9. Hi, I am building a dashboard/report in work and I have it working at present (not fully) but I made the table structure static, in that if I wanted to make another one for another part of the business, I would need to redo the html table structure. I want to have it create the table itself based on the information in the array. I have included a sample of $data_array and also a screenshot of the current layout I have aswell as a sample of the HTML that is currently in use to generate the below table. I understand its probably going to be a loop job, however Im getting confused as normally you loop for each row, but in this case I need to loop for each TD. If there is any furthe info I can provide that would help, please let me know. Apologies if I have not explained what I am looking for very well. <table border="1" bordercolor="#000000" style="background-color:#FFFFFF" width="100%" cellpadding="3" cellspacing="0"> <tr> <td colspan="3" rowspan="3" class="unused"></td> <td class = "center main_heading" colspan="33">UK Retail</td> </tr> <tr> <td class = "center channel_heading" colspan="<?php echo $chat_width;?>" ><a href="uk_retail_hh.php?c=Chat">Chat</a></td> <td class = "center channel_heading" colspan="<?php echo $phone_width;?>"><a href="uk_retail_hh.php?c=Phone">Phone</a></td> <td class = "center channel_heading" colspan="<?php echo $email_width;?>"><a href="uk_retail_hh.php?c=Email">Email</a></td> </tr> <tr> <td class = "center site_heading chat_ORK" >ORK</td> <td class = "center site_heading chat_EDI" >EDI</td> <td class = "center site_heading chat_VCC" >VCC</td> <td class = "center site_heading chat_HYD" >HYD</td> <td class = "center site_heading chat_BCD" >BCD</td> <td class = "center site_heading chat_SUT" >SUT</td> <td class = "center site_heading" >ORK</td> <td class = "center site_heading" >EDI</td> <td class = "center site_heading" >VCC</td> <td class = "center site_heading" >CBU</td> <td class = "center site_heading" >CPT</td> <td class = "center site_heading" >DAK</td> <td class = "center site_heading" >JAM</td> <td class = "center site_heading" >MNL</td> <td class = "center site_heading" >ORK</td> <td class = "center site_heading" >EDI</td> <td class = "center site_heading" >VCC</td> <td class = "center site_heading" >HYD</td> <td class = "center site_heading" >BCD</td> <td class = "center site_heading" >SUT</td> <td class = "center site_heading" >DAK</td> </tr> <tr> <td colspan="3">Offered</td> <td class = "center Chat_ORK"><?php echo $data_array['Chat']['ORK1']['Incoming'] ?></td> <td class = "center Chat_EDI"><?php echo $data_array['Chat']['EDI3']['Incoming'] ?></td> <td class = "center Chat_VCC"><?php echo $data_array['Chat']['UKVCC']['Incoming'] ?></td> <td class = "center Chat_HYD"><?php echo $data_array['Chat']['HYD']['Incoming'] ?></td> <td class = "center Chat_BCD"><?php echo $data_array['Chat']['BCD']['Incoming'] ?></td> <td class = "center Chat_SUT"><?php echo $data_array['Chat']['SUT']['Incoming'] ?></td> <td class = "center Phone_ORK"><?php echo $data_array['Phone']['ORK1']['Incoming'] ?></td> <td class = "center Phone_EDI"><?php echo $data_array['Phone']['EDI3']['Incoming'] ?></td> <td class = "center Phone_VCC"><?php echo $data_array['Phone']['UKVCC']['Incoming'] ?></td> <td class = "center Phone_CBU"><?php echo $data_array['Phone']['CBU1']['Incoming'] ?></td> <td class = "center Phone_CPT"><?php echo $data_array['Phone']['CPT']['Incoming'] ?></td> <td class = "center Phone_DAK"><?php echo $data_array['Phone']['DAK']['Incoming'] ?></td> <td class = "center Phone_JAM"><?php echo $data_array['Phone']['JAM']['Incoming'] ?></td> <td class = "center Phone_MNL"><?php echo $data_array['Phone']['MNL']['Incoming'] ?></td> <td class = "center Email_ORK"><?php echo $data_array['Email']['ORK1']['Incoming'] ?></td> <td class = "center Email_EDI"><?php echo $data_array['Email']['EDI3']['Incoming'] ?></td> <td class = "center Email_VCC"><?php echo $data_array['Email']['UKVCC']['Incoming'] ?></td> <td class = "center Email_HYD"><?php echo $data_array['Email']['HYD']['Incoming'] ?></td> <td class = "center Email_BCD"><?php echo $data_array['Email']['BCD']['Incoming'] ?></td> <td class = "center Email_SUT"><?php echo $data_array['Email']['SUT']['Incoming'] ?></td> <td class = "center Email_DAK"><?php echo $data_array['Email']['DAK']['Incoming'] ?></td> </tr> <tr> <td colspan="3">Handled</td> <td class = "center Chat_ORK"><?php echo $data_array['Chat']['ORK1']['Handled_incoming'] ?></td> <td class = "center Chat_EDI"><?php echo $data_array['Chat']['EDI3']['Handled_incoming'] ?></td> <td class = "center Chat_VCC"><?php echo $data_array['Chat']['UKVCC']['Handled_incoming'] ?></td> <td class = "center Chat_HYD"><?php echo $data_array['Chat']['HYD']['Handled_incoming'] ?></td> <td class = "center Chat_BCD"><?php echo $data_array['Chat']['BCD']['Handled_incoming'] ?></td> <td class = "center Chat_SUT"><?php echo $data_array['Chat']['SUT']['Handled_incoming'] ?></td> <td class = "center Phone_ORK"><?php echo $data_array['Phone']['ORK1']['Handled_incoming'] ?></td> <td class = "center Phone_EDI"><?php echo $data_array['Phone']['EDI3']['Handled_incoming'] ?></td> <td class = "center Phone_VCC"><?php echo $data_array['Phone']['UKVCC']['Handled_incoming'] ?></td> <td class = "center Phone_CBU"><?php echo $data_array['Phone']['CBU1']['Handled_incoming'] ?></td> <td class = "center Phone_CPT"><?php echo $data_array['Phone']['CPT']['Handled_incoming'] ?></td> <td class = "center Phone_DAK"><?php echo $data_array['Phone']['DAK']['Handled_incoming'] ?></td> <td class = "center Phone_JAM"><?php echo $data_array['Phone']['JAM']['Handled_incoming'] ?></td> <td class = "center Phone_MNL"><?php echo $data_array['Phone']['MNL']['Handled_incoming'] ?></td> <td class = "center Email_ORK"><?php echo $data_array['Email']['ORK1']['Handled_incoming'] ?></td> <td class = "center Email_EDI"><?php echo $data_array['Email']['EDI3']['Handled_incoming'] ?></td> <td class = "center Email_VCC"><?php echo $data_array['Email']['UKVCC']['Handled_incoming'] ?></td> <td class = "center Email_HYD"><?php echo $data_array['Email']['HYD']['Handled_incoming'] ?></td> <td class = "center Email_BCD"><?php echo $data_array['Email']['BCD']['Handled_incoming'] ?></td> <td class = "center Email_SUT"><?php echo $data_array['Email']['SUT']['Handled_incoming'] ?></td> <td class = "center Email_DAK"><?php echo $data_array['Email']['DAK']['Handled_incoming'] ?></td> </tr> Array ( [Phone] => Array ( [CBU1] => Array ( [statistic_date] => 2013-05-20 [time] => 0 [site] => CBU1 [phone_skill] => Primary [OU] => UK [Incoming] => 1005 [Handled_incoming] => 902 [Aband_6] => 39 [Aband_210] => 39 [Aband_30] => 32 [Ans_60sec] => 810 [Ans_210sec] => 966 [Ans_30sec] => 683 [SL_60] => 0.8448 [SL_210] => 1.0000 [SL_30] => 0.7114 ) [DAK] => Array ( [statistic_date] => 2013-05-20 [time] => 0 [site] => DAK [phone_skill] => Primary [OU] => UK [Incoming] => 913 [Handled_incoming] => 876 [Aband_6] => 18 [Aband_210] => 18 [Aband_30] => 14 [Ans_60sec] => 807 [Ans_210sec] => 894 [Ans_30sec] => 730 [SL_60] => 0.9036 [SL_210] => 0.9989 [SL_30] => 0.8149 ) [JAM] => Array ( [statistic_date] => 2013-05-20 [time] => 0 [site] => JAM [phone_skill] => Primary [OU] => UK [Incoming] => 1171 [Handled_incoming] => 1377 [Aband_6] => 15 [Aband_210] => 15 [Aband_30] => 12 [Ans_60sec] => 1147 [Ans_210sec] => 1155 [Ans_30sec] => 1123 [SL_60] => 0.9923 [SL_210] => 0.9991 [SL_30] => 0.9693 ) [MNL] => Array ( [statistic_date] => 2013-05-20 [time] => 530 [site] => MNL [phone_skill] => Primary [OU] => UK [Incoming] => 1918 [Handled_incoming] => 1764 [Aband_6] => 24 [Aband_210] => 27 [Aband_30] => 16 [Ans_60sec] => 1711 [Ans_210sec] => 1891 [Ans_30sec] => 1459 [SL_60] => 0.9046 [SL_210] => 1.0000 [SL_30] => 0.7690 ) [ORK1] => Array ( [statistic_date] => 2013-05-20 [time] => 700 [site] => ORK1 [phone_skill] => Primary [OU] => UK [Incoming] => 133 [Handled_incoming] => 128 [Aband_6] => 3 [Aband_210] => 3 [Aband_30] => 2 [Ans_60sec] => 96 [Ans_210sec] => 130 [Ans_30sec] => 86 [SL_60] => 0.7444 [SL_210] => 1.0000 [SL_30] => 0.6617 ) [UKVCC] => Array ( [statistic_date] => 2013-05-20 [time] => 700 [site] => UKVCC [phone_skill] => CsPromotions [OU] => UK [Incoming] => 1264 [Handled_incoming] => 1191 [Aband_6] => 28 [Aband_210] => 30 [Aband_30] => 27 [Ans_60sec] => 1133 [Ans_210sec] => 1234 [Ans_30sec] => 1047 [SL_60] => 0.9185 [SL_210] => 1.0000 [SL_30] => 0.8497 ) [CPT] => Array ( [statistic_date] => 2013-05-20 [time] => 800 [site] => CPT [phone_skill] => Primary [OU] => UK [Incoming] => 624 [Handled_incoming] => 624 [Aband_6] => 16 [Aband_210] => 16 [Aband_30] => 13 [Ans_60sec] => 562 [Ans_210sec] => 608 [Ans_30sec] => 535 [SL_60] => 0.9263 [SL_210] => 1.0000 [SL_30] => 0.8782 ) [EDI3] => Array ( [statistic_date] => 2013-05-20 [time] => 900 [site] => EDI3 [phone_skill] => Primary [OU] => UK [Incoming] => 779 [Handled_incoming] => 775 [Aband_6] => 21 [Aband_210] => 22 [Aband_30] => 19 [Ans_60sec] => 724 [Ans_210sec] => 757 [Ans_30sec] => 708 [SL_60] => 0.9564 [SL_210] => 1.0000 [SL_30] => 0.9332 ) ) [Chat] => Array ( [BCD] => Array ( [statistic_date] => 2013-05-20 [time] => 0 [site] => BCD [phone_skill] => PrimaryChat [OU] => UK [Incoming] => 809 [Handled_incoming] => 777 [Aband_6] => 10 [Aband_210] => 11 [Aband_30] => 8 [Ans_60sec] => 765 [Ans_210sec] => 798 [Ans_30sec] => 687 [SL_60] => 0.9580 [SL_210] => 1.0000 [SL_30] => 0.8591 ) [HYD] => Array ( [statistic_date] => 2013-05-20 [time] => 0 [site] => HYD [phone_skill] => PrimaryChat [OU] => UK [Incoming] => 862 [Handled_incoming] => 954 [Aband_6] => 8 [Aband_210] => 10 [Aband_30] => 8 [Ans_60sec] => 818 [Ans_210sec] => 852 [Ans_30sec] => 765 [SL_60] => 0.9582 [SL_210] => 1.0000 [SL_30] => 0.8968 ) [ORK1] => Array ( [statistic_date] => 2013-05-20 [time] => 0 [site] => ORK1 [phone_skill] => PrimaryChat [OU] => UK [Incoming] => 314 [Handled_incoming] => 317 [Aband_6] => 3 [Aband_210] => 3 [Aband_30] => 3 [Ans_60sec] => 311 [Ans_210sec] => 311 [Ans_30sec] => 290 [SL_60] => 1.0000 [SL_210] => 1.0000 [SL_30] => 0.9331 ) [SUT] => Array ( [statistic_date] => 2013-05-20 [time] => 0 [site] => SUT [phone_skill] => PrimaryChat [OU] => UK [Incoming] => 1369 [Handled_incoming] => 1234 [Aband_6] => 21 [Aband_210] => 22 [Aband_30] => 19 [Ans_60sec] => 1299 [Ans_210sec] => 1347 [Ans_30sec] => 1181 [SL_60] => 0.9642 [SL_210] => 1.0000 [SL_30] => 0.8766 ) [UKVCC] => Array ( [statistic_date] => 2013-05-20 [time] => 0 [site] => UKVCC [phone_skill] => PrimaryChat [OU] => UK [Incoming] => 300 [Handled_incoming] => 300 [Aband_6] => 2 [Aband_210] => 2 [Aband_30] => 2 [Ans_60sec] => 298 [Ans_210sec] => 298 [Ans_30sec] => 263 [SL_60] => 1.0000 [SL_210] => 1.0000 [SL_30] => 0.8833 ) [EDI3] => Array ( [statistic_date] => 2013-05-20 [time] => 900 [site] => EDI3 [phone_skill] => PrimaryChat [OU] => UK [Incoming] => 273 [Handled_incoming] => 296 [Aband_6] => 2 [Aband_210] => 2 [Aband_30] => 2 [Ans_60sec] => 269 [Ans_210sec] => 271 [Ans_30sec] => 251 [SL_60] => 0.9927 [SL_210] => 1.0000 [SL_30] => 0.9267 ) ) [Email] => Array ( [BCD] => Array ( [statistic_date] => 2013-05-20 [time] => 0 [site] => BCD [phone_skill] => RetailEmail [OU] => UK [Incoming] => 1309 [Handled_incoming] => 1293 [Aband_6] => 0 [Aband_210] => 0 [Aband_30] => 0 [Ans_60sec] => 0 [Ans_210sec] => 0 [Ans_30sec] => 0 [SL_60] => 0.0000 [SL_210] => 0.0000 [SL_30] => 0.0000 ) [CPT] => Array ( [statistic_date] => 2013-05-20 [time] => 0 [site] => CPT [phone_skill] => CsPromotionsEmail [OU] => UK [Incoming] => 15 [Handled_incoming] => 49 [Aband_6] => 0 [Aband_210] => 0 [Aband_30] => 0 [Ans_60sec] => 0 [Ans_210sec] => 0 [Ans_30sec] => 0 [SL_60] => 0.0000 [SL_210] => 0.0000 [SL_30] => 0.0000 ) [DAK] => Array ( [statistic_date] => 2013-05-20 [time] => 0 [site] => DAK [phone_skill] => Email [OU] => UK [Incoming] => 1081 [Handled_incoming] => 1129 [Aband_6] => 0 [Aband_210] => 0 [Aband_30] => 0 [Ans_60sec] => 0 [Ans_210sec] => 0 [Ans_30sec] => 0 [SL_60] => 0.0000 [SL_210] => 0.0000 [SL_30] => 0.0000 ) [EDI3] => Array ( [statistic_date] => 2013-05-20 [time] => 0 [site] => EDI3 [phone_skill] => Email [OU] => UK [Incoming] => 709 [Handled_incoming] => 754 [Aband_6] => 0 [Aband_210] => 0 [Aband_30] => 0 [Ans_60sec] => 0 [Ans_210sec] => 0 [Ans_30sec] => 0 [SL_60] => 0.0000 [SL_210] => 0.0000 [SL_30] => 0.0000 ) [HYD] => Array ( [statistic_date] => 2013-05-20 [time] => 0 [site] => HYD [phone_skill] => RetailEmail [OU] => UK [Incoming] => 2012 [Handled_incoming] => 1766 [Aband_6] => 0 [Aband_210] => 0 [Aband_30] => 0 [Ans_60sec] => 0 [Ans_210sec] => 0 [Ans_30sec] => 0 [SL_60] => 0.0000 [SL_210] => 0.0000 [SL_30] => 0.0000 ) [ORK1] => Array ( [statistic_date] => 2013-05-20 [time] => 0 [site] => ORK1 [phone_skill] => Email [OU] => UK [Incoming] => 1320 [Handled_incoming] => 336 [Aband_6] => 0 [Aband_210] => 0 [Aband_30] => 0 [Ans_60sec] => 0 [Ans_210sec] => 0 [Ans_30sec] => 0 [SL_60] => 0.0000 [SL_210] => 0.0000 [SL_30] => 0.0000 ) [SUT] => Array ( [statistic_date] => 2013-05-20 [time] => 0 [site] => SUT [phone_skill] => CarriersEmail [OU] => UK [Incoming] => 3785 [Handled_incoming] => 3704 [Aband_6] => 0 [Aband_210] => 0 [Aband_30] => 0 [Ans_60sec] => 0 [Ans_210sec] => 0 [Ans_30sec] => 0 [SL_60] => 0.0000 [SL_210] => 0.0000 [SL_30] => 0.0000 ) [UKVCC] => Array ( [statistic_date] => 2013-05-20 [time] => 0 [site] => UKVCC [phone_skill] => CarriersEmail [OU] => UK [Incoming] => 746 [Handled_incoming] => 750 [Aband_6] => 0 [Aband_210] => 0 [Aband_30] => 0 [Ans_60sec] => 0 [Ans_210sec] => 0 [Ans_30sec] => 0 [SL_60] => 0.0000 [SL_210] => 0.0000 [SL_30] => 0.0000 ) ) )
  10. I have a set rental amount with some variable making an equation. The final variable is the TOTAL of all the equations, i need the total of this variable <?php //option 1 52 weeks $weeklyToStudent = $row_rsTenProp['rental_price']; $fourWeeksSecurityDep = 4 * $weeklyToStudent; $fivetwoWeeksPayable = $weeklyToStudent * 52; $fee = 184.80; $resFee = 250; $fivetwoPayIncFeedSecDep = $fourWeeksSecurityDep + $fivetwoWeeksPayable + $fee; $initPay15Wks = $weeklyToStudent*15; $initPay15WksFeeSecDep = $initPay15Wks + $fee + $fourWeeksSecurityDep; $balanceB4MovingIn = $initPay15WksFeeSecDep - $resFee; $second14Wks = $weeklyToStudent * 14; $third14Wks = $weeklyToStudent * 14; $fourth9Wks = $weeklyToStudent * 9; $totalPayment = $initPay15WksFeeSecDep + $second14Wks + $third14Wks + $fourth9Wks; ?> <?php do { ?> <tr> <td class="table-text"><a href="customer-info.php?recordID=<?php echo $row_rsTenProp['userid']; ?>"><?php echo $row_rsTenProp['userid']; ?></a></td> <td class="table-text"><?php echo $row_rsTenProp['weeks'] / 7; ?> weeks</td> <td class="table-text"><?php echo $row_rsTenProp['payment_option']; ?></td> <td class="table-text"><?php echo $row_rsTenProp['rental_price']; ?></td> <td class="table-text"><?php echo $row_rsTenProp['prop_id']; ?></td> <td class="table-text"><?php echo DoFormatCurrency($totalPayment, 2, ',', '.', '£ '); ?></td> <td> </td> <td> </td> </tr> <?php } while ($row_rsTenProp = mysql_fetch_assoc($rsTenProp)); ?> i need to multiple the $totalPayment to get the TOTAL of this variable <?php $totalPaymentTot = 0; while ($totalPayment = ($row_totalPayment)); $totalPaymentTot += $row_totalPayment;{ $row_totalPayment; } echo $totalPaymentTot;?>
  11. Hi. I'm having a problem regarding my codes involving radio buttons and subloop. I couldn't retrieve the data from post and I can't insert them to the database. I just couldn't find the error. Here's my form's code: <form method="post"> <?php $select_paragraph=mysql_query('SELECT * FROM dependency'); $questrows = 0; while($get_paragraph = mysql_fetch_array($select_paragraph)) { $TestID = $get_paragraph['testId']; $Dependid = $get_paragraph['DependencyId']; echo" <table border='1'> <tr class='classheader1'> <td align='center' class='paragraph'>". $get_paragraph['Situation']. "</td> <table>"; $select_question=mysql_query('SELECT * FROM dependentitems where DependencyId="'.$Dependid.'"'); while($get_question = mysql_fetch_array($select_question)) { echo $LitId = $get_question['LiteralId']; echo $ItemID = $get_question['ItemId']; echo" <tr><td align='left' class='paragraph'><br>". $get_question['Question']. "</td></tr> <tr><td align='left' class='paragraph'><input type='radio' name='Option".$questrows."' value = '". $get_question['Option1']. "'>". $get_question['Option1']. "</td></tr> <tr><td align='left' class='paragraph'><input type='radio' name='Option".$questrows."' value = '". $get_question['Option2']. "'>". $get_question['Option2']. "</td></tr> <tr><td align='left' class='paragraph'><input type='radio' name='Option".$questrows."' value = '". $get_question['Option3']. "'>". $get_question['Option3']. "</td></tr> <tr><td align='left' class='paragraph'><input type='radio' name='Option".$questrows."' value = '". $get_question['Option4']. "'>". $get_question['Option4']. "</td></tr> "; echo "Radio Names = Option".$questrows." "; $questrows++; } echo" </table> </td> </tr> </table> "; } ?> <input type="submit" name="enter" value="Submit"/> </form> And here's the code where I retrieve the post so I could insert them into my database: <?php if(@$_POST['enter']) { $select_paragraph=mysql_query('SELECT * FROM dependency'); $questrows = 0; while($get_paragraph = mysql_fetch_array($select_paragraph)) { $TestID = $get_paragraph['testId']; $Dependid = $get_paragraph['DependencyId']; $select_question=mysql_query('SELECT * FROM dependentitems where DependencyId="'.$Dependid.'"'); while($get_question = mysql_fetch_array($select_question)) { echo "Hi".@$option=$_POST['Option'.$questrows]; echo "<br>LitId = ".$LitId = $get_question['LiteralId']; echo "<br>ItemId = ".$ItemID = $get_question['ItemId']; echo '<br>ThisOption'.$questrows; $insertToTemp="insert into temp(StudId, TestId, ItemId, LiteralId, Choice) values(1, 3, $ItemID,$LitId,'$option[$questrows]')"; mysql_query($insertToTemp); $questrows++; echo "<br>"; } } } ?> Hope you could help me find the error. Thanks.
  12. I've got a foreach ($acct as $val){ $acc_s = explode(',',$val["access_type"]); } The value of ACC will Array from every foreach var_dump($acc_s); Output: array(1) { [0]=> string(1) "1" } array(2) { [0]=> string(1) "1" [1]=> string(1) "2" } array(2) { [0]=> string(1) "3" [1]=> string(1) "4" } array(1) { [0]=> string(1) "3" } My question is, how do I make a condition if the value of the "explode" element have 1 or 2 or 3 or 4. I'd try. for($i=0;$i<count($acc_s);$i++){ $out_acc = $acc_s[$i]; } But it won't give me the right output to what I need.
  13. I have an array ($sm[]) which stores several decimal numbers. Now I want to insert these data present in the array to a column "SM" present under empty table "sm". So anybody please suggest how should I do this by writing few lines of php code.
  14. Hello all! I want to format my post array so that I can insert the data into the database in a particular way such as this: Also, I'm making this dynamic in that I'm not always going to know the column names. So hardcoding the keys is not an option for this solution. INSERT INTO invoice_items (itemCode, itemDesc, itemQty, itemPrice, itemLineTotal) VALUES (1000', Widget0', 10', '25.00', '900.54), (1001', Widget1', 11', '25.01', '900.54), (1002', Widget2', 12', '25.02', '900.54) BUT my current output looks like this. Which is not right of course: INSERT INTO invoice_items (itemCode, itemDesc, itemQty, itemPrice, itemLineTotal) VALUES (1000', '1001', '1003), (Widget', 'Red Hat', 'ioPad with Cover), (1', '2', '3), (100.5', '25.02', '300.18), (25.02', '600.36', '900.54); I don't think I'm that far from having a solution but I can't wrap my head around how to get the output the way I need it. The original $_POST Array: Array ( [itemCode] => Array ( [0] => 1000 [1] => 1001 [2] => 1003 ) [itemDesc] => Array ( [0] => Widget [1] => Red Hat [2] => ioPad with Cover ) [itemQty] => Array ( [0] => 1 [1] => 2 [2] => 3 ) [itemPrice] => Array ( [0] => 100.5 [1] => 25.02 [2] => 300.18 ) [itemLineTotal] => Array ( [0] => 100.50 [1] => 50.04 [2] => 900.54 ) ) Here's the loop that creates the following arrays: $fields = $values = array(); foreach ($post as $column => $value) { $fields[] = $column; $value = implode("', '", $value); $values[$column] = $value; } $columns Array: Array ( [0] => itemCode [1] => itemDesc [2] => itemQty [3] => itemPrice [4] => itemLineTotal ) $values Array: Array ( [itemCode] => 1000', '1001', '1003 [itemDesc] => Widget', 'Red Hat', 'ioPad with Cover [itemQty] => 1', '2', '3 [itemPrice] => 100.5', '25.02', '300.18 [itemLineTotal] => 25.02', '600.36', '900.54 ) Create the sql statement: $query = "INSERT INTO " . $this->table ; $query .= " (" . implode(", ", $fields) . ") "; $query .= "VALUES (" . implode("), (", $values) . "); "; Which outputs this: INSERT INTO invoice_items (itemCode, itemDesc, itemQty, itemPrice, itemLineTotal) VALUES (1000', '1001', '1003), (Widget', 'Red Hat', 'ioPad with Cover), (1', '2', '3), (100.5', '25.02', '300.18), (25.02', '600.36', '900.54); THANK YOU for any help you can provide me!
  15. I've been given a function that return all the list of data in an array. Only that function I can update nothing else specially on the database. From all the list of data, by using foreach I can print all the list of data. But my problem now is on the list of data e.g. (name, address, phone_number, zip_code). . How can I make a condition that will only show all the data by the same zip_code or name whatever. e.g. (John, John, John, John) for me it will be easy if i have access on the database, but unfortunately I don't have. Anyone can help me with this?
  16. I'm wondering if it's possible in an easy way that when I use while function to call out a bunch of data and put them into table but I want to use css to make it one row with regular background and one row with light background. hopefully what I sad make sense.... this is what I have echo "<style type='text/css'>"; echo "th {background: #CEED5E;}"; echo "</style>"; echo "<table border=1>"; echo "<tr><th>Product ID</th><th>Title</th><th>Author</th><th>Description</th></tr>"; while ($row = mysqli_fetch_assoc($result)) { echo "<tr><td>" . $row["id"] . "</td><td>" . $row["title"] . "</td><td>" . ucwords(strtolower($row["authorFirstName"] . " " . $row["authorLastName"])) . "</td><td>" . $row["description"] . "</td></tr>"; } echo "</table>";
  17. I have created a user defined function to return a string value function getModel($part) { $root = substr($part,0,4); $query = "SELECT Root, Model FROM tbl_Root WHERE Root = '$root'"; $result = mysql_query($query) or die ("Query Root failed: " . mysql_error()); while ($rec = mysql_fetch_array($result, MYSQL_ASSOC)) { if (in_array($root, $rec)): $Model = $rec['Model']; else: $Model = 'UNKNOWN'; endif; } return $Model; } When trying to find the attributes of several hundred part numbers, I pass them to a MySQL temp table that would then select the distinct part numbers and loop them through my functions. $query = "SELECT DISTINCT A FROM TempAttributes"; $result = mysql_query($query) or die ("Query failed: " . mysql_error()); while ($rec = mysql_fetch_array($result, MYSQL_ASSOC)) { $part = mysql_escape_string($rec['A']); $Model = getModel($part); $query = "REPLACE INTO tbl_Attributes (Part, Model) VALUES ('$part', '$Model')"; $endresult = mysql_query($query) or die ("Query Load failed: " . mysql_error()); } The line of code that stops the execution of my loop is $Model = getModel($part); I executed the loop with this line of code in and it stops after the first part number. When I comment this line of code out, my loop processes all of my part numbers, but of course not with the return values I am looking for. Why does my user defined function not process through the while loop to assign the $Model variable the return value of the getModel function? Please help!
  18. Hi, I need help with looping through the dates of working days (Monday to Friday) for the following week. I need to send an email once a week (probably on a Thursday or Friday) informing people of their rooms for the following week. I need to loop through each day, starting with Monday and finishing on Friday. I wrote this: for($i=0;$i<5;$i++) { echo date('Y-m-j', strtotime('Monday+'.$i)).'<br />'; } I thought this would work, but it returns the correct date for next Monday (2013-03-25) and then the other 4 days are all showing as 2013-03-24. Any ideas how I can get this to work? Thank you for taking the time to help. Many Thanks, John
  19. Hi, I am trying to develop a room allocation application, but am struggling a bit to get my head around the coding. I am trying to break it down into small chunks and then maybe see if I can get everything to work together. I have a mysql table which contains a list of users. I have returned the results of the user IDs from my select query into an array. I also have another table which holds a numeric marker. The marker will change. My array of user IDs would look like: Array ( [0] => 1 [1] => 3 [2] => 5 ) My numeric marker could be: 1 What I need to do is do a complete loop through my array starting at the numeric marker position. This would return: [1]=>3 [2]=>5 [0]=>1 As you can see, it jumps back to the beginning of the array and outputs the first element to complete the loop. Depending on the numeric marker and this particular data set, the array could also run like: Marker = 0: [0]=>1 [1]=>3 [2]=>5 Marker = 2: [2]=>5 [0]=>1 [1]=>3 I have had a go at writing the code and if I start at numeric marker 1, I can get it to run to the end of the array. I just have no idea how to reset back to the beginning and run until I reach numeric marker minus 1. Here is what I have so far: $i = $numericMarker; foreach ($userID as $key => $value) { if ($key < $numericMarker) continue; echo '$i = '.$i.' $value = '.$value.'<br />'; $i++; } Any help you can give me would be greatly appreciated. Many thanks, John
  20. all, I have this block of code: If ($ctr = 4) { for ($block = 1; $block <= 9; $block++) { for ($ctr2 = 1; $ctr2 <= 3; $ctr2++) { //each line. for ($ctr3 = 1; $ctr3 <= 3; $ctr3++) { //char 1 - 3 in each line. switch ($ctr2) { //which line? Case 1: $strOut = $strOut . substr($Line1, $ctr3, 1); Case 2: $strOut = $strOut . substr($Line2, $ctr3, 1); Case 3: $strOut = $strOut . substr($Line3, $ctr3, 1); } } } } } what I'd like to do is streamline it. There are 3 lines of text being captured here. What is (supposed to be) happening is that each block of characters (3 characters per line positions, starting at position 1 or positions every 3 char increments after that) is being captured until all 9 chars are stored in $strOut. 9 chars = 3 chars on each line * 3 lines. is there any better way to do this mathematically? I realize that we can manipulate the variables and coding many different ways, but I'm not interested in that. I'm only interested in using math or leveraging techniques to speed up the process here. Resources from PHP would be OK but I'm trying to focus on the massive iteration and turning it into something more useful. comments welcome. thanks!
  21. How do I put condition upon exploding a variable that outputting different values. I've got a $variable from a loop, each loop the variable has a different content(style attribute) . sample content of the variable. . array(6) { [0]=> string(17) "font-family:Arial" [1]=> string(14) "font-size:11px" [2]=> string(13) "color:#000000" [3]=> string(16) "font-weight:bold" [4]=> string(25) "text-decoration:underline" [5]=> string(0) "" } array(4) { [0]=> string(17) "font-family:Arial" [1]=> string(14) "font-size:11px" [2]=> string(13) "color:#000000" [3]=> string(0) "" } array(3) { [0]=> string(15) "padding:1px 2px" [1]=> string(12) "display:none" [2]=> string(0) "" } array(1) { [0]=> string(0) "" } array(3) { [0]=> string(15) "padding:1px 2px" [1]=> string(12) "display:none" [2]=> string(0) "" } so if i'm going to explode it $style = explode(';', $variable); so to print out put; echo $style[0]; right? But how will I going to be more specifi. Like . . $style->font-family, or $style->font-weight Then make a condition etc. .
  22. Hey Guys! I've been trying to figure out how to tackle a solution for this, on the site you have a combobox to select a subject and add other fields aswell. My problem is if the subjects are the same group them together and only echo the subject once but echo the other fields aswell. if($execute){ $con = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD ); $sthandre = $con->prepare("SELECT book.id, book.title, book.url, book.viewer, book.sub_id, subj.subject_id, subj.name FROM book LEFT JOIN subj ON(book.sub_id = subj.subject_id) WHERE book.username_id = :yourid ORDER BY subj.subject_id"); $sthandre->execute(array(':yourid'=>$userid)); while ($row = $sthandre->fetch()){ $bmid = ($row ['id']); $title = ($row ['title']); $url = ($row ['url']); $audience= ucfirst($row ['viewer']); $subid = ($row ['subject_id']); $subjectname = ($row ['name']); //somehow if the subject name is a duplicate echo it once and carry on with the other variables looping echo "$subjectname,$title,$audience" } } the current output; Subject | Title |audience ------------------------------------------------------ |Classic | The Who | Everyone| |Classic | The End | Mature | |Classic | Happy | Teen | |Other | Last | Everyone | what im hoping it to be; Subject | Title |audience ------------------------------------------------------ |Classic | The Who | Everyone| | | The End | Mature | | | Happy | Teen | |Other | Last | Everyone | it will be in another format its just easier to explain in a grid format. Thanks i appreciate it!
  23. I've been playing for this and I really can't figure how to count the sub array and post a value: Array ( [1] => Array ( [A] => Hello [b] => [C] => Hello [D] => ) [2] => Array ( [A] => [b] => world! [C] => [D] => world! ) [3] => Array ( [A] => [b] => [C] => [D] => ) [4] => Array ( [A] => Miscellaneous [b] => [C] => [D] => ) [5] => Array ( [A] => List [b] => bump [C] => [D] => ) ) So what I want to happen is: <table> <tbody> <tr> <td>Hello</td><td>B</td><td>Hello</td><td>D</td> </tr> <tr> <td></td><td>world!</td><td></td><td>world!</td> </tr> <tr> <td>A</td><td>B</td><td>C</td><td>D</td> </tr> <tr> <td>A</td><td>B</td><td>C</td><td>D</td> </tr> <tr> <td>A</td><td>B</td><td>C</td><td>D</td> </tr> </tbody> </table> I already count the main array, but I can't get the sub array and post them on a table data w/ each specific value.
  24. Hey there, so I have a custom Wordpress loop that is working just fine. Inside that loop I have a second loop using Salesforce API. What is happening is that the main loop is looping but the secondary Salesforce loop is showing the same record for each and not looping. There is a unique ID for each so that isn't the problem. while ($wp_query->have_posts()) : $wp_query->the_post(); $sid = get_the_ID(); $SalesForceId = get_post_meta($sid, 'SalesForceId', true); $query = "SELECT Name, Phone, BillingCity, BillingState from Account WHERE Id = '" . $SalesForceId . "'"; $response = $mySforceConnection->query(($query)); foreach ($response->records as $record) { $Name = $record->{Name}; $Phone = $record->{Phone}; $BillingCity = $record->{BillingCity}; $BillingState = $record->{BillingState}; } echo $Name; echo $BillingCity; echo $BillingState; endwhile; ?>
  25. Hi guys. I've built an application for my company, and everyone likes it, but on some of the "events" they create, there is an infinite loop. It doesn't always happen, so i was investigate the 'else' part of it. I've looked over the script a few times over the past few months, not religiously until today. i still can't seem to find the issue. Can someone please help me? <?php $rowtot=0; while($rowtot<count($resultsIOCC['IOCC'])){ foreach ($resultsIOCC['IOCC'] as $IOCC ) { if( $IOCC->ioccCostID == $Cost->CostID ) { if( ($IOCC->ioccLabor + $IOCC->ioccTravel + $IOCC->ioccMileage) > 0 ) { $rowtot = $IOCC->ioccLabor + $IOCC->ioccTravel + $IOCC->ioccMileage; echo money_format('$%i',$rowtot) . '<br>'; $rowstot += $rowtot; } else { echo "$" . number_format("0", 2) . '<br>'; $rowstot = ($rowstot + 0); } } $rowtot++; } } ?> I can post more of it if necessary, but I believe it's in this part of the script. I know the script is not very "professional" looking and the variables are terribly named (like rowstot and rowtot), but it was a learning experience at the time, I didn't know PHP and it was my first project.
×
×
  • 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.