1 answer

I want to know what is wrong with my code which was the question to Add...

Question:

I want to know what is wrong with my code which was the question to Add a form to your php file that has a user put in a Username with the method post. If the name exists in the array, do nothing. If the name does not, add an element to the array with the Username and all other values set to 0. Print out the new array. (PHP)

$array=array(array('username' =>"joeDoe",'tweets'=> 2000,"Followers"=>45,"Following"=>8),

array('username' =>"JohnD", 'tweets'=>62000,"Followers"=>123,"Following"=>160),

array('username' =>"computerSavy",'tweets'=>75,"Followers"=>1,"Following"=>25),

array('username' =>"myTwitterAccount",'tweets'=>1800,"Followers"=>15,"Following"=>6));

echo "

Add New name

";

echo "

" ;

echo "";

echo "

" ;

if (isset($_POST['x']))

{

$new=$_POST['x'];

$check=false;

foreach($array as $key=> $value)

{

if($value['username']==$new )

{

$check=false;

break;

}

if(!$check)

$array=array('username'=>$new, 'tweets'=>0, 'Followers'=>0,'Following'=>0);

}

echo "";

foreach($array as $key =>$value)

{

echo "

";

}

echo"

Handle(Username) Tweets Number of Follwers Following
".$value['username']." ".$value['tweets']." ".$value['Followers']." ".$value["Following"]."

";

}


Answers

please check out the code with changes

<?

$array=array(array('username' =>"joeDoe",'tweets'=> 2000,"Followers"=>45,"Following"=>8),

array('username' =>"JohnD", 'tweets'=>62000,"Followers"=>123,"Following"=>160),

array('username' =>"computerSavy",'tweets'=>75,"Followers"=>1,"Following"=>25),

array('username' =>"myTwitterAccount",'tweets'=>1800,"Followers"=>15,"Following"=>6));

echo "Add New name";

echo "

" ;

echo "";

echo "

" ;

if (isset($_POST['x']))

{

$new=$_POST['x'];

$check=false;

foreach($array as $key=> $value)

{

if($value['username']==$new )

{

$check=true;

break;

}

if($check)

$array=array('username'=>$new, 'tweets'=>0, 'Followers'=>0,'Following'=>0);

}

echo "";

foreach($array as $key =>$value)

{

echo "

";

}

echo"

Handle(Username) Tweets Number of Follwers Following

".$value['username']." ".$value['tweets']." ".$value['Followers']." ".$value["Following"]."

";

}

?>

.

Similar Solved Questions

1 answer
8. +-10 points My Notes Ask Your Teache An appliance dealer sells three different models of...
8. +-10 points My Notes Ask Your Teache An appliance dealer sells three different models of upright freezers having 13.5, 15.9, and 19.1 cubic feet of storage space, respectively. Let X = the amount of storage space purchased by the next customer to buy a freezer. Suppose that X has the following pm...
1 answer
How do I find the arc length of the curve #y=ln(sec x)# from #(0,0)# to #(pi/ 4, ln(2)/2)#?
How do I find the arc length of the curve #y=ln(sec x)# from #(0,0)# to #(pi/ 4, ln(2)/2)#?...
1 answer
(1 point) 4 Please calculate the power dissipated in all of the resistors. K = 5...
(1 point) 4 Please calculate the power dissipated in all of the resistors. K = 5 kQ, R2 = 300 Ω, and the open-loop voltage gain, A = 10 5V R1 -5V 100Ω 250Ω 5V 0.5 R2 -5V (a) PRI1.25E-9 (b) P100Ω- 2.5E-11 (c) PR2 - 7.5E-11 (d) P2500-...
1 answer
Chlorine gas can be prepared in the laboratory by the reaction of hydrochloric acid with manganese(IV)...
Chlorine gas can be prepared in the laboratory by the reaction of hydrochloric acid with manganese(IV) oxide. 4HCl(aq)+MnO2(s)⟶MnCl2(aq)+2H2O(l)+Cl2(g) A sample of 36.7 g MnO2 is added to a solution containing 48.9 g HCl. What is the limiting reactant? MnO2 HCl What is the theoretical yield o...
1 answer
Problem 4.14 The circuit shown in figure(Figure 1)is a dc model of a residential power distribution...
Problem 4.14 The circuit shown in figure(Figure 1)is a dc model of a residential power distribution circuit. Use the node- voltage method to find the branch currents ij - in if R1 = 2.022, R2 = 4.022, R3 = 2.012, R4 = 12.02, Rs = 24.0 2, R6 = 48.0 22 Part A Find the value of j. Express your answer w...
1 answer
Fassst please!!! Read the Ethical Dilemma, Anything for a BUC, and share your thoughts by answering...
fassst please!!! Read the Ethical Dilemma, Anything for a BUC, and share your thoughts by answering the following ethical question also posed at the end of the story. What should you do? When answering the question elaborate, expand upon, and support your thoughts. Anything for (a) BUC The bank o...
1 answer
Can someone break this down and explain to me why the answers are the way they...
Can someone break this down and explain to me why the answers are the way they are? I can’t seem to get those answers. Consider the following pipelined circuit, what is the latency? Selected Answer: 24ns 2 ns 7 ns 20 ns G 24 ns Answers: Question 9 Consider the following pipelined circuit. W...
1 answer
How do you find the length of the line segment between the points (5,1) and (5,6)?
How do you find the length of the line segment between the points (5,1) and (5,6)?...
1 answer
The Pauli Exclusion Principle tells us that no two electrons in an atom can have the same four quantum numbers. For an...
The Pauli Exclusion Principle tells us that no two electrons in an atom can have the same four quantum numbers. For an electron in the 2p orbital shown above, enter a possible value for each quantum number. n= mı = Give ONE example. mg = Give ONE example. Though a given electron only has one va...
1 answer
Job 243 was recently completed. The following data have been recorded on its job cost sheet...
Job 243 was recently completed. The following data have been recorded on its job cost sheet $57,870 Direct materials Direct labor-hours Direct labor wage rate Machine-hours Number of units completed 495 labor-hours 11 per labor-hour 576 machine-hours 4,500 units The company applies manufacturing ove...
1 answer
Derek will deposit $4,188.00 per year for 13.00 years into an account that earns 14.00%. Assuming...
Derek will deposit $4,188.00 per year for 13.00 years into an account that earns 14.00%. Assuming the first deposit is made 5.00 years from today, how much will be in the account 33.00 years from today? Suppose you deposit $2,174.00 into an account today that earns 11.00%. In 15.00 years the account...
1 answer
Ning is suggested by Match the Meaning Synony toward the river For coch item below. choose...
ning is suggested by Match the Meaning Synony toward the river For coch item below. choose the word whose meaning is sugges the clue given. Then write the word in the space provided. d. haul For each it meaning on the lir 1. A forest fire made the frightened herd a demonstrate be stampede c. pledge ...
1 answer
A pitot tube is used to measure the velocity of an air stream. The air has...
A pitot tube is used to measure the velocity of an air stream. The air has a temperature of 18°C and a pressure of 105 kPa 12 mm Hg If the differential height in a mercury manometer is 12 mm and the air is incompressible, the air velocity is most nearly (A) 38 m/'s o (B) 43 m/s (C) 48 ms (D)...
1 answer
1. Give a real-life example (either you or someone you know or an example you found...
1. Give a real-life example (either you or someone you know or an example you found online) of the alarm stage of GAS. 2. Give a real-life example of the resistance stage of GAS. 3. Define what the exhaustion stage of GAS could look like and use a real-life example....
1 answer
Saved Consider the following two scenarios for the economy and the expected returns in each scenario...
Saved Consider the following two scenarios for the economy and the expected returns in each scenario for the market portfolio, an aggressive stock A, and a defensive stock D. Scenario Bust Boom Rate of Return Aggressive Defensive Market Stock A Stock D -8% -13% -6% 26 35 19 Required: a. Find the bet...
1 answer
Assume that Guatemala produces either 1000 pounds of coffee or 3000 pounds of sugar in a...
Assume that Guatemala produces either 1000 pounds of coffee or 3000 pounds of sugar in a year. Describe in words what the graph of the PPC would look like. (If you have the capability to upload a graph that you drew feel free to do so)...
1 answer
4. Your friend Jacob has noticed that you appear to be feeling better and have more...
4. Your friend Jacob has noticed that you appear to be feeling better and have more energy since you've been taking this class. You tell him you think this is because you have made some small changes to your diet and are not eating more nutritious meals. He is considering trying the ketogenic di...