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

  • SEARCH
  • Home
  • 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 8769681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:24:04+00:00 2026-06-13T17:24:04+00:00

I’m trying to retrieve information from my database, and output it to my page.

  • 0

I’m trying to retrieve information from my database, and output it to my page. I’m able to hardcore it, so to show exactly what I want to be able to do is located here:

I’m not having any console errors in the javascript, but I am unable to append data to the list once it is clicked.

HTML & JS:

<!doctype html><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="../img/sd.ico" />
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>  
</head>
<body>
<div id="body">
<div id="header"><h1><a href="#">Bookmarks</a></h1></div><!-- header -->
<iframe id="iFrame" name="iFrame"></iframe>
<div id="links"><ul id="accordion">

<li><div class="bookmarkTitle"><p><h4>CareerResources</h4></p></div></li><ul id="CareerResources">

</ul><li><div class="bookmarkTitle"><p><h4>CSS</h4></p></div></li><ul id="CSS">

</ul><li><div class="bookmarkTitle"><p><h4>JS</h4></p></div></li><ul id="JS">

</ul><li><div class="bookmarkTitle"><p><h4>JS: Jquery</h4></p></div></li><ul id="JS: jQuery">

</ul></div><!-- links end -->
</div><!-- body end -->
<script type="text/javascript">
$(document).ready(function(){       
    $("#accordion > li").click(function(e){
        var catName=$(e.target).text();
        $.getJSON("get.php?catName=" + catName, function(data){ 
            if (data.data){ 
                $.each(data.data,function(index,value){ 
                    var url = value.URL; 
                    var title = value.title; 
                    var desc = value.desc; 
                    alert(catName);
                    $("#"+catName).append('<a href="'+url+'" target="iFrame"><div class="bookmark"><p><h3>'+title+'</h3><br />'+desc+'</p></div></a>'); 
                }); 
            } 
        });
    }); 
}); 
</script>
</body>
</html>

PHP:

// retval: 0 - login ok, 1 - login failed, 2 - internal error
$json = array("retval" => 2, "data" => NULL, "debug" => "");

$catName=mysql_real_escape_string($_REQUEST['catName']);


$sql="SELECT * FROM linktb WHERE catName='$catName'";

$json['debug'] .= "SQL query was: ".$sql."\n";
$result=mysql_query($sql);
if (!$result) {
    $json['debug'] .= "SQL query failed\n";
    $json['debug'] .= "Other output: ". ob_get_contents();
    ob_end_clean();
    die(json_encode($json));
}
$count=mysql_num_rows($result);

if($count > 0){ 
$json['retval'] = 0; 
$json['data'] = array(); 
while ($row = mysql_fetch_assoc($result)){ 
$json['data'][] = $row; 
} 
} else { 
$json['retval'] = 1; 
}

$json['debug'] .= "Other output: ". ob_get_contents();
ob_end_clean();
echo json_encode($json);
  • 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-13T17:24:05+00:00Added an answer on June 13, 2026 at 5:24 pm

    var catID=e.target.text(); Should be var catID=$(e.target).text(); as .text() is a jQuery method.

    If you want to iterate through the returned data you’ll have to do it in the success function. Also from your php script you only output one row from your database.

    if($count > 0){ 
        $json['retval'] = 0; 
        $json['data'] = array(); 
        while ($row = mysql_fetch_assoc($result)){ 
            $json['data'][] = $row; 
        } 
    } 
    else { 
        $json['retval'] = 1; 
    }
    
    $.getJSON("get.php?catID=" + catID, function(data){ 
        if (data.data){ 
            $.each(data.data,function(index,value){ 
                var url = value.URL; 
                var title = value.title; 
                var desc = value.desc; 
                $("#"+catID).appendText('<a href="'+url+'" target="iFrame"><div class="bookmark"><p><h3>'+title+'</h3><br />'+desc+'</p></div></a>'); 
            }); 
        } 
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a view passing on information from a database: def serve_article(request, id): served_article
Basically, what I'm trying to create is a page of div tags, each has
I want to show the soap response to UIWebview.. my soap response is, <p><img
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

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.