I have 3 td's in a portion of a table. Sometimes, the data coming in from the database is less than 3. I need a method that will lay-out the data precisely compared to a rank in the table. Ideal situation: array |-0 |-name => Joe |-rank => 0 |-1 |-name => Dick |-rank => 1 |-2 |-name => Mike |-rank => 2 Yields: <tr> <td data-rank="0"> Joe </td> <td data-rank="1"> Dick </td> <td data-rank="2"> Mike </td> </tr> Problem situation: array |-0 |-name => Dick |-rank => 1 |-1 |-name => Mike |-rank => 2 Yields: <tr> <td data-rank="0"> Dick …

Member Avatar
Member Avatar
+0 forum 7

Hello, i want to make a categories menu which each will have its own sub-categories and that category will have own sub-categories im trying to make with arrays but i'm not really good at it.. im trying right now with bunch if statements but is there any other method of doing this with loops or something eazier ? <form action="" method="POST"> <?php $category = array("Cars" => 1, "Bikes" => 2, "Phones" => 3); $cars_category = array("Honda" => 1, "BMW" => 2, "Mercedes" => 3); $bikes_category = array("Suzuki" => 1, "GSXR" => 2, "Yamaha" => 3); $phones_category = array("Samsung" => 1, …

Member Avatar
Member Avatar
+0 forum 5

so the program needs to dynamically allocate an array large enough to hold a user=defined number of test scores. once all scores are entered, the array should be passed to a function that sorts them in ascending order. another function should be called that calculates the average score. the program should display the sorted list of scores and averages with appropriate headings. use pointer notation rather than array notation whenever possible. the problem i am having is making it so that the program doesn't accept negative numbers for test scores. errors - Error C4716 'showAverage': must return a value ConsoleApplication9 …

Member Avatar
Member Avatar
+0 forum 2

Hello, I'm trying to plot this function with using this values: Rh = 9.8 H0 = 0.063 def Thickness_H(H0, r, Rh): return float(H0)*np.exp(float(r)/float(Rh)) r = np.linspace(0,1, 10) x =Thickness_H(H0, r, Rh) plt.plot(r, x) plt.show() I'm trying to defind r like what i know but this dose not work, I'm getting this error: only length-1 arrays can be converted to Python scalars. may you please help me in this point? Thank you

Member Avatar
Member Avatar
+0 forum 6

Hi all, I am using a for statement to generate lots of arrays, example: Array ( [0] => 2 [1] => 395.0 [2] => 0.33 ) Array ( [0] => 3 [1] => 394.0 [2] => 0.81 ) But, I want to have them all within 1 array, example: Array ( [0] ( [0] => 2 [1] => 395.0 [2] => 0.33 ) [1] ( [0] => 3 [1] => 394.0 [2] => 0.81 ) ) Am I able to do this within my for statement, which is currently: for ($c=0; $c < $num; $c++) { echo '<pre>'; print_r(str_getcsv($data[$c], ' …

Member Avatar
Member Avatar
+0 forum 2

Hi there, I am trying to populate a page with multiple rows from a mySQL database. To grab the data, I am using: for ($i=1; $i < 5; $i++) { $query = 'SELECT * FROM table WHERE column = ?'; $statement = $mySQL_con->prepare($query); try { $statement->execute(array($i)); } catch (PDOException $error) { echo 'Sorry, we failed to load this page: ' . $error->getMessage(); } $row = $statement->fetch(); $results[] = $row; } That creates a mutil-dimensional array. However, when I try to access that data things go a bit weird. For example,`print_r($results[2][name]);` should output the name from the third row I grabbed …

Member Avatar
Member Avatar
+0 forum 4

Hi all i generated table,but it looks like the code is a bit messy,long,how can i do the same with the arrays or loops? <html> <head> <meta charset="UTF-8"> <title></title> <style> table{border-collapse: collapse;} tr th, tr td{border: 1px solid black;} #resize { width :100%; position: relative; } </style> </head> <body> <?php $numbers = mt_rand(1,100); $numbers1 = mt_rand(1,100); $numbers2 = mt_rand(1,100); $numbers3 = mt_rand(1,100); $numbers4 = mt_rand(1,100); $numbers5 = mt_rand(1,100); $numbers6 = mt_rand(1,100); $numbers7 = mt_rand(1,100); $numbers8 = mt_rand(1,100); $numbers9 = mt_rand(1,100); $numbers10 = mt_rand(1,100); $numbers11 = mt_rand(1,100); ?> <div id="resize"> <table width ="100%"> <tr> <th>knumber</th> <th>WP</th> <th>WD</th> <th>ID</th> <th>DV</th> <th>HC</th> <th>PR</th> …

Member Avatar
Member Avatar
+0 forum 7

Hello, I was hoping to get some input from anyone in the Java section. My professor gave us a practice problem about two weeks ago and I have been running into an out of bounds error. The program seemed simple enough, take in two arrays of binary numbers from a user, add them, and return the sum as a third array. So far I have this: import java.util.*; public class Binary { public static int[] calculate(int[] arr1, int[] arr2) { int length = (arr1.length + arr2.length); int carry = 0; int[] newArray = new int[length]; for(int i = 0; i …

Member Avatar
Member Avatar
+0 forum 3

Hi all,i tried to do some research regarding associated arrays in php,even manual on the php documentations,but can not find the answer,how do i print the smallest value and the associated key from the array?

Member Avatar
Member Avatar
+0 forum 3

array([details] => Array([0] => Array( [name] => 454 [location] => 4) [2] => Array([name] => 454 [location] => 5))) I have array details with two sub arrays [0] and [2] how to convert and order [2] to [1] array([details] => Array([0] => Array( [name] => 454 [location] => 4) [1] => Array([name] => 454 [location] => 5))) any body help me

Member Avatar
Member Avatar
+0 forum 2

Ok guys ! I'm trying to study operator overloading. which i found the toughest article in OOP :( I tried a code for == operator overloading to check whether both arrays have same elements or not but it isn't working. Can anyone help? Here is my code: #include<iostream> using namespace std; class array { private: int arr[5]; public: array() { for (int i=0;i<5;i++) arr[i]=-1; } input() { for(int j=0;j<5;j++) { cin>>arr[j]; } } show() { for(int k=0;k<5;k++) { cout<<arr[k]<<endl; } } int operator ==(array a) { if(a.arr==a) return 1; else return 0; } }; int main() { array obj1,obj2; cout<<"enter …

Member Avatar
Member Avatar
+0 forum 5

Trying to insert both of these arrays of random quotes on the same page so that both show at the same time. I realize I have to rename some of the elements within, but apparently I have no clue which. I've tried giving each rannum, ShowText, and RndText a number behind it, but that didn't work. I'm sure there's just something small I'm missing. Any help would be greatly appreciated. Thanks! <div> <!-- Math Conversation --> <script type="text/javascript"> var textarray = [ "The most incomprehensible about Mathematics is that it is comprehensible.", "Arithmetic is where numbers fly like pigeons in …

Member Avatar
Member Avatar
+0 forum 5

Hi, I have a range of *start* and *end* dates return from database in while loop i need to find, how many of them are continuing. The example return data; Array ( [start_date] => 2014-09-22 [end_date] => 2014-09-28 ) Array ( [start_date] => 2014-09-15 [end_date] => 2014-09-21 ) Array ( [start_date] => 2014-09-08 [end_date] => 2014-09-14 ) Array ( [start_date] => 2015-04-06 [end_date] => 2015-04-12 ) Array ( [start_date] => 2015-03-30 [end_date] => 2015-04-05 ) Array ( [start_date] => 2015-04-01 [end_date] => 2015-04-06 ) Array ( [start_date] => 2015-04-01 [end_date] => 2015-04-07 ) Array ( [start_date] => 2015-04-01 [end_date] => …

Member Avatar
Member Avatar
+0 forum 2

I am trying to compile the following code and I keep getting a reference error for my output file through a function. The purpose of the program is to read a file, sort through arrays, and output into a certain form. I am sure it is something small, but I do not understand what I am doing wrong. Thanks in advanced for any help. #include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std; const int runners = 5; const int days = 7; void readFile(ifstream& infile, string names[], double miles[runners][days]); void fileOutput(ofstream& outfile, string names[], double miles[days], double …

Member Avatar
Member Avatar
+0 forum 4

So i am back again, working with arrays this time. I can get it to run in the main but i am not sure how to make this code into a void function . #include <iostream> #include <iomanip> #include <string> using namespace std; int main () { // Declare variables and initialize const int monkeytot = 3; const int Wdays = 7; int monkeys; int days; int most = 0; int least = 0; int total = 0; double average = 0; double totaleaten; double food [monkeytot][Wdays]; // start program // Fill array with numbers for (monkeys = 0; monkeys …

Member Avatar
Member Avatar
+0 forum 6

I have a class called Car, 6 other classes (Van,Cab,Truck, Taxi, Sedan and Motorbike) that implement this class. Each of the subclasses has its own mnethods and attributes. How would I go about creating an array of these vehicles with the type of car being randomly selected. that is I would like to have an array that looks like this ArrayLaneSouth = {Van,Cab, Taxi, Sedan} ArrayLaneNorth = {Van,Cab, Taxi, Sedan} ArrayLaneWest = {Van,Cab, Taxi, Sedan} ArrayLaneEast = {Van,Cab, Taxi, Sedan} the elements in the arrays are types of cars and the type be selected randomly.

Member Avatar
Member Avatar
+0 forum 3

Hey guys, I just learned the very basics of arrays and I have to write this program of a tic-tac-toe game. The requirements are this: Write a modular program that allows two players to play a game of tic-tac-toe. Use a two-dimensional char array with 3 rows and 3 columns as the game board. Each element of the array should be initialized with an asterisk(*). The program should display the initial board configuration and then start a loop that does the following: Allow player 1 to select a location on the board for an X by entering a row and …

Member Avatar
Member Avatar
+0 forum 8

Hello, If I have an array structured like the following: '0' ... '0' ... '1' ... '2' ... '1' ... '0' => "Mike" '1' => "1892" '2' => "1" '2' ... '0' => "Paul" '1' => "1672" '2' => "1" '3' ... '0' => "Sam" '1' => "1872" '2' => "1" '4' ... '0' => "David" '1' => "2090" '2' => "1" '5' ... '0' => "Daniel" '1' => "1652" '2' => "1" '6' ... '0' => "Frank" '1' => "2192" '2' => "0" '7' ... '0' => "Louis" '1' => "1892" '2' => "1" '8' ... '0' => "Michael" …

Member Avatar
Member Avatar
+0 forum 5

Hello, I have the following string [null,null,null],["Paul","2293",1],["eric","2099",0] which I will define as: var dataparsed ='[null,null,null],["Paul","2293",1],["eric","2099",0]'; and would like to construct three different arrays in the following format: var opponentName = new Array(null, "Paul","eric"); var numberVal =new Array(null, 2293,2099); var outComeVal = new Array(null, 1,0); Any ideas on how this can be done in Javascript? I appreciate any thoughts on this. Mossa--

Member Avatar
Member Avatar
+0 forum 7

double fileSizeKB = (fileByteArray.length) / 1024; double transferTime = timer.getTimeElapsed() / 1000; double fileSizeMB = fileSizeKB/1000; double throughput = fileSizeMB/transferTime; System.out.println("The size of the File was "+fileSizeMB+ " MegaBytes"); System.out.println("Time for transfer was " +timer.getTimeElapsed()/1000+ " Seconds"); System.out.printf("Throughput was %.2f MB Per Second\n",+throughput); System.out.println("Number of retransmissions: " + retransmissionCounter); byte[] statMessage = new byte[32]; statMessage[0]= (byte) throughput; statMessage[1]=(byte) fileSizeMB; statMessage[2]=(byte) transferTime; DatagramPacket statPacket = new DatagramPacket(statMessage,statMessage.length,address,port); socket.send(statPacket); System.out.println(statMessage[0]); System.out.println(statMessage[1]); System.out.println(statMessage[2]); socket.close();

Member Avatar
Member Avatar
+0 forum 2

When reading any beginning manual on C++ an array is introduced as follows: float A[10]; That format is valid, in that it compiles and seems to work just fine -- for a while. Later on in the manual we learn to allocate/release memory using the new and delete keywords. So, the same array would be: float * A = new float[10]; some code; delete[] A; Now, the question is: When does it become necessary to allocate memory for an array? I've seen code snipets of some fairly complicated algorithms, that make use of the simpler version of array declaration. But …

Member Avatar
Member Avatar
+0 forum 5

I have two arrays arr1 is 2015,03,12 and arr2 is 2015,03,12 how to compare i tryied like this **first method** if(arr1==arr2) { alert("same");} else { alert("not same");} i got not same. please help me anybody. ======================================== **second method** var dd1 = arr1[2]; var mm1 = arr1[1]; var yy1 = arr1[0]; var dd2 = arr2[2]; var mm2 = arr2[1]; var yy2 = arr2[0]; if(dd2==dd1 && mm2==mmm1 && yy2==yy1){alert("same");} both methods not working . any body help me

Member Avatar
Member Avatar
+0 forum 5

Hello, Code Masters, Here I am again today going to seek help and guidance from you. I have here a manually assigned values to arrays 0 - 19 now my question is, how can I assign values to each array coming from the SQL database? The catch is, it is a different SQL statement (specifically a different where clause) for each array value. For example: Dim answers(19) As String answers(0) = RbAnswers1.SelectedValue answers(1) = RbAnswers2.SelectedValue answers(2) = RbAnswers3.SelectedValue answers(3) = RbAnswers4.SelectedValue answers(4) = RbAnswers5.SelectedValue answers(5) = RbAnswers6.SelectedValue answers(6) = RbAnswers7.SelectedValue answers(7) = RbAnswers8.SelectedValue answers(8) = RbAnswers9.SelectedValue answers(9) = RbAnswers10.SelectedValue answers(10) …

Member Avatar
Member Avatar
+0 forum 1

I have a soap call which returns an object which has a xml string. an example is shown below: <?xml version="1.0" encoding="utf-16"?> <LoginResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <StatusCode>1</StatusCode> <StatusMessage>Login Successful</StatusMessage> <AuthKey>b2365767-ae42-1a44a6436575</AuthKey> </LoginResponse> I would like it to convert it into an associative array which will be similar to: array( "LoginResponse"=>array( "StatusCode"=>1, "StatusMessage"=>"Login Successful" "AuthKey"=>"b2365767-ae42-1a44a6436575" ) ); Hope this makes sense I have tried simplexml_load_string() xml2array() nothing works

Member Avatar
Member Avatar
+0 forum 5

Hi, I have been creating a round robin. This is similar idea to speed dating except everyone has to talk to everyone. Whilst I have been able to create this, there is a lot of repetition in my code and I wondering if any of you have recommendations for removing some of that, particularly around the push and pops. The code below I tested within the js.do website. I will add the output below the code, so you get an idea of what this looks like. Any help will be appreciated. <p style="line-height: 18px; font-size: 18px; font-family: times;"> <br> Round …

Member Avatar
Member Avatar
+0 forum 3

I know that the main difference between an array and a list is that a list size changes dynamically as items are added or removed. Because of this, if we copy an array to a list does that mean that the list must have a static size of the array's capacity?

Member Avatar
Member Avatar
+0 forum 3

I have this assignment due this weekend and I was able to figure it out but for some reason the last part of my output is going up to 38 and I have no clue to way it would be doing that any thoughts to way. my output: output: PRINTING CONTENTS OF ARRAY ================================== ABCDEFGHIJKLMNOPQRSTUVWXYZ This is the title to your Program related to the alphabet. Select the number that coincides with the alphabet. For example, the number 7 should display the letter G. Enter a number between 1 and 26: 2 The number you selected: 2 The letter related …

Member Avatar
Member Avatar
+0 forum 2

Hey guys, i'm a bit of a new programmer taking a class.So in my code what im trying to do is to select three random numbers, and see if it matches with the numbers that the lottery throws out. The problem is where the 1st number and 3rd number selected randomly show up fine, but i have no idea on how to get the 2nd number to show up. I know my error is right here at lotteryDigit2 int lotteryDigit1 = lottery / 100; int lotteryDigit2 = lottery * 1; int lotteryDigit3 = lottery % 10; int guessDigit1 = guess …

Member Avatar
Member Avatar
+0 forum 3

Okay I hope my title is not confusing. I have two checkboxes names Delete[] and Update[] followed by a textbox named Name[]. When I tick checkbox Delete[] and click Submit, I ran a query to delete the data based on that Checkbox's value (which I have set to be the primary key of the record) and it worked fine. My problem started when I tried to do the same thing with my Update[] checkbox. After looking thru some forums I found the explanation I've been looking for: "Remember that in the POST data all of the textboxes will always be …

Member Avatar
Member Avatar
-1 forum 4

i made union to two mysql tables select cashid, sum(amt) as ramt, NULL AS pamt from receipt where cashid in ('17', '23') GROUP BY cashid union all select cashid, NULL AS ramt, sum(amt) as pamt from payment where cashid in ('17', '23') GROUP BY cashid and now i want to make calculations between them. like-- balance = ramt - pamt can anyone suggest me how can i do that? thanks in advance

Member Avatar
Member Avatar
+0 forum 6

The End.