Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9120075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:32:52+00:00 2026-06-17T05:32:52+00:00

I have an PHP Switch case. How do I swt the value of n

  • 0

I have an PHP Switch case. How do I swt the value of “n” using the onclick of a button?

    switch (n)
     {
     case 1:
       $result = mysql_query("select * from tblRestaurants order by RestName ASC");
       break;
     case 2:
       $result = mysql_query("select * from tblCuisines order by RestName ASC");
       break;
     case 3:
       $result = mysql_query("select * from tblLocations order by RestName ASC");
       break;
      case 4:
       $result = mysql_query("select * from tblLocations order by RestName ASC");
       break;
     case 5:
       $result = mysql_query("select * from tblLocations order by RestName ASC");
       break;
     } 

onclick = (switch)n=1

Just guessing

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:32:53+00:00Added an answer on June 17, 2026 at 5:32 am

    The only way you can set a PHP variable after the page has loaded with a request for a JSON data return… All PHP code is executed before all of the HTML so if you submit a button you can call a java-script function but you can only use java-script functions from that onClick call.
    If you insist on not having your page refresh you would have to use a lot of AJAX and get a JSON data return document. But if you are fine with a page redirect you could just have a form submit to the same page and then at the top of the page check if you posted and if so then execute your queries.
    Top of Page:

    <?php
    if(isset($_POST['form_submit'])){
    //do your queries
    }
    ?>
    

    In your form:

    <form action='' method='POST'>
    <input type='submit' name='form_submit' value='Go'>
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this PHP case statement switch ($parts[count($parts) - 1]) { case 'restaurant_pos': include($_SERVER['DOCUMENT_ROOT']
I have a php file that contains switch/case which is in JSON I believe.
I have installed PDT 2.1 but i can't switch to the PHP Perspective, any
I have a PHP script that is using get_dns_record to retrieve and display specific
<?php $var = 0; switch($var) { case a: echo I think var is a;
I have the following PHP code: //switch if (isset($_GET['pg'])) $pg = $_GET['pg']; else{ $pg
I have a lot of php file. To access each php I am using
I have gallery.php that loads images with src path from a database. I also
We have a PHP system on which we're using Micah Carrick's PHP Paypal IPN
My index.php switch ($action){ case calendar: echo <script language=\javascript\>\n; echo document.write('Hello World!'); echo </script>;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.