Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
Assign different php value after every click

I know this is a hack, but I really need it.

I have following code:

<thead>
   <?php 
     if(isset($_COOKIE['gautasId'])) {
      $wishes = $conn->query("SELECT sa.id, sa.aprasymas, sa.poreikiai, sa.miestas, s.statusas FROM svajoniu_aprasymas sa join svajoniu_statusai s on s.id = sa.statusas where sa.senolio_id = " . $_COOKIE['gautasId']);
     }                     
     if ($wishes->num_rows == 0) {
     ?>
     <tr>
        <th>No data</th>
     </tr>
</thead>
   <?php } else { ?>
        <tr>
            <th>Id</th>
            <th>...</th>
            <th>...</th>
        </tr>
</thead>

I set that cookie value:

echo "<tr><td><span onclick=setValue('$eldId') class='fa fa-chevron-right fa-fw'></span> </span></td>";
function setValue(id) {
  document.cookie = "gautasId = " + id;
}

and this function is hit everytime I click it, but query values do not change. Is it possible to do this somehow?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This is pretty awfull code, so, consider removing the JavaScript element entirely by changing $_COOKIE to $_GET, and adding the ID to the url using a href tag.

echo "<a href=‘?id=$eldId' class='fa fa-chevron-right fa-fw'> ";

Then use $_GET[id] to pickup the value from the url

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!