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 8053445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:50:45+00:00 2026-06-05T07:50:45+00:00

I have the following code… and I am trying to pass in a parameter

  • 0

I have the following code… and I am trying to pass in a parameter to replace “id = 0”, with a value. Is there a way to do that, or a better way to do it?

DB Call

include 'db.php';
$con = mysql_connect($host,$user,$pass);
$dbs = mysql_select_db($databaseName, $con);

$result = mysql_query("SELECT * FROM myTable where id = 0;");

JSON call:

$(function(){
    var items="";
    $.getJSON("mypage.php",function(data){
        $.each(data,function(index,item) {
        items+="<option value='"+item.id+"'>"+item.title+"</option>";
        });
        // .... some stuff
    });
});
  • 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-05T07:50:46+00:00Added an answer on June 5, 2026 at 7:50 am

    you can parse variables throw your getJSON request.

    Do the following:

    $.getJSON("mypage.php", {id : 2}, function(data){
        // .... some stuff
    });
    

    Php receives the variable via GET:

    include 'db.php';
    $con = mysql_connect($host,$user,$pass);
    $dbs = mysql_select_db($databaseName, $con);
    
    $id = $_GET["id"]; 
    
    $result = mysql_query("SELECT * FROM myTable where id = ".mysql_real_escape_string($id).";");
    

    Make sure that you use mysql_real_escape_string() to prevent mysql injections…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code for initializing bean values depending upon url parameter. <f:metadata> <f:viewParam
I have following code: public abstract class Operand<T> { public T Value { get;
I have following code that displays an Image with letters, public class MainActivity extends
I have following code that creates Linq query. I've never used Linq until today
I have following code which call a task after every 20 min and its
I have following code: $boxId = 1; $explainationBox='<input type=button id=<?php echo $boxId; ?> value=send
I have following code that determines the user's language. if (locale.equalsIgnoreCase(eng)) { .... }
I have following code in JavaScript function checkEntries() { if(document.getElementById(username)== && document.getElementById(password).value==) { alert(Please
I have following code: #include <stdio.h> // For printf() #include <sys/stat.h> // For struct
i have following code for loop for ($i=0; $i<=(count($subusers)-1); ++$i) { is there a

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.