Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
133 views
in Technique[技术] by (71.8m points)

php - 在PHP数组上更改值(Chaning the values on a PHP array)

What I want is when the user enters some text on an alert input to be shown as in the picture below on a php created array: https://imgur.com/a/tNVNAqF

(我想要的是用户在警报输入上输入一些文本时,如下所示在php创建的数组上显示的内容: https : //imgur.com/a/tNVNAqF)

What I made so far is exactly this except it enters the value on the whole array like the picture below:

(到目前为止,我所做的正是这一点,除了它在整个数组上输入值,如下图所示:)

https://imgur.com/a/Oe4nJi2

(https://imgur.com/a/Oe4nJi2)

My code with comment's explanation :

(我的代码加上注释的解释:)

popUp.php

(popUp.php)

 <html> <head> <title>Two-dimensional Arrays</title> <style> td {height: 40px;} table {width: 40%; border: 3px solid blue;} table tbody tr:nth-child(odd) { background-color: red; } table tbody tr:nth-child(even) { background-color: green; } </style> </head> <body> <!-- GETS FROM THE USER THE INPUT VALUE WHEN PRESSING THE BUTTON--> <input action="" method="get" name="button" type="button" id="inputChar" onclick="Click();"value="CLICK HERE"> <?php echo "<table border =\"1\" >"; for ($row=1; $row <= 10; $row++) { echo "<tr> \n"; for ($col=1; $col <= 10; $col++) { echo "<td id='inputChar'> </td> \n"; } echo "</tr>"; } echo "</table>"; ?> <script> // A JAVASCRIPT FUNCTION ACTIVATED WHEN CLICKING THE BUTTON WHERE THE USER INPUTS THE VALUE function Click(){ var Vvalue = prompt("Please input the value"); window.location.href = "main.php?Vvalue=" + Vvalue; } </script> </body> </html> 

main.php

(main.php)

 <html> <head> <title>Two-dimensional Arrays</title> <style> td {height: 40px;} table {width: 40%; border: 3px solid blue;} table tbody tr:nth-child(odd) { background-color: red; } table tbody tr:nth-child(even) { background-color: green; } </style> </head> <body> <?php $char = $_GET['Vvalue']; // GETS THE JAVASCRIPT USER INPUT VALUE FROM popUp.php echo "<table border =\"1\" >"; for ($row=1; $row <= 10; $row++) { echo "<tr> \n"; for ($col=1; $col <= 10; $col++) { echo "<td id='inputChar'> .$char.</td> \n"; } echo "</tr>"; } echo "</table>"; ?> </body> </html> 

Does anyone have any ideas how we can make this happen?

(有谁知道我们如何实现这一目标?)

( TLDR: I want to display the user input on the odd rows of the array)

((TLDR:我想在数组的奇数行上显示用户输入))

  ask by Costas_ translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...