Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp With Some Easy JavaScript and PHP
    primarykey
    data
    text
    <p>I really need help on this one. I have two text with a submit button. Say "Sam" and "Ram" with a submit button next to each one of them. </p> <p>Now I check my database if the name is present, and if the query is true, I run a for loop to display the two buttons. On the click of any of the buttons, I am storing the number "1" in the db against the name and hiding the element and diplaying another text like "Thanks".</p> <p>The thing works fine, but when I have two or more text with buttons, only one is being chnaged while the other remains as it is.</p> <p>Code - </p> <pre><code>$sql = "SELECT * FROM revbut WHERE onuser='$u'"; $g = mysqli_query($connect,$sql) or die(mysqli_error($connect)); $geez = mysqli_fetch_array($g); mysqli_select_db($connect,"users"); //using for the display of the offer box $db = "SELECT * FROM but WHERE sessionusername='$u'"; $s = mysqli_query($connect,$db) or die(mysqli_error($connect)); $user = mysqli_fetch_assoc($s); $number = mysqli_num_rows($g); for($i = 0; $i&lt;$number;$i++) { if($geez['onuser']) { $globalname = $geez['sessionusername']; require('djser.php'); } else if($user['sessionusername']) { include('djser2.php'); } </code></pre> <p>}</p> <p>INSIDE the DJER.PHP</p> <p>JAVASCRIPT</p> <pre><code>if(&lt;?php echo json_encode($re=='reject'); ?&gt;){ //if response is reject document.getElementById('hide').style.display = "none"; document.getElementById('onapprove').style.display = "none"; document.getElementById('onreject').style.display="block"; } else if(&lt;?php echo json_encode($re=='approve'); ?&gt;){ //if response is approve document.getElementById('hide').style.display = "none"; document.getElementById('onapprove').style.display = "block"; } </code></pre> <p>it works fine for one. when two are involved, only the upper one is changed. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload