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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:01:35+00:00 2026-05-30T18:01:35+00:00

I’m a complete beginner with jQuery and I have this bit of script here

  • 0

I’m a complete beginner with jQuery and I have this bit of script here and I want to mix jQuery with PHP. I have Courses and in those Courses are Lessons. A Teacher is assigned to teach a Course. What I want is a link where if I press it a popup appears and in it shows the Lesson details or Course details. My problem is that I will be having multiple links and thus dialogs/modal windows in a page such that $l[‘id’] and $c[‘id’] will be different. How can I therefore use $l[‘id’] and $c[‘id’] in or with jQuery given that the jQuery script is inside the view file and I’m creating the actual content itself in the controller and passing it onto view. Sorry if I don’t make sense cause I’m still quite confused about all this myself.

view.php
<script type="text/javascript">
$(function(){
        // setup ul.tabs to work as tabs for each div directly under div.panes
        $("#tabs").tabs();   
        $('#dialog').dialog({   
                             modal: true
                            });          
})
</script>
<h1>Student Hub: Courses for <?php echo $studentName;?></h1>

<div id="tabs">
    <?php echo $content;?>
</div>



controller.php  
This is in a foreach loop
<div class="lessonDetails">
    <p><a href="#lessonInfo'.$l['id'].'">Lesson Details:</a><p>
    <div id="lessonDialog'.$l['id'].'" title="Lesson Details">
    '.$l['name'].'
    </div>
</div>  

<div class="courseDetails">
    <p><a href="#courseInfo'.$c['id'].'">Course Timetable & Resources</a><p>
    <div id="courseDialog'.$c['id'].'" title="Course Details">
    <p>'.$c['fullname'].'</p>
    <p>'.$c['summary'].'</p>
    <p>Upcoming Lessons: </p>
</div>                                                                  
  • 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-05-30T18:01:37+00:00Added an answer on May 30, 2026 at 6:01 pm

    Technical answer is you don’t as one is a server-side language and one is a client-side language; you can’t access PHP variables via JavaScript (jQuery). You can, however, drop your PHP variables into your HTML page on generation, and then pick them up with JavaScript or jQuery.

    Reading your scenario, I think your over-complicating things. Think of your application; don’t think of the technical aspects, but more the way it should be laid out. I’m guessing you have a students controller, a lessons controller, and a courses controller. Those controllers will have actions, called view or similar, and then these actions will take an ID to display a particular student/course/lesson.

    In your HTML page/view/template, you should have just vanilla URLs. JavaScript should then be used to enhance the website. So in your case, I would have mark-up it up similar to as follows:

    <ul class="courses">
    <?php foreach ($courses as $course): ?>
      <li><a href="/courses/view/<?php echo $course->id; ?>"><?php echo $course->title; ?></a></li>
    <?php endforeach; ?>
    </ul>
    

    I’d then, in an external JavaScript file, have a function that listens for a click on the <a> tag and instead of navigating to that URL, instead displays the page content in a pop-up/modal window.

    <script>
        $('.courses a').click(function(e) {
            e.preventDefault();
            // load external page and display it in a modal
        });
    </script>
    

    This way, if for some reason JavaScript’s not available then the user will be taken to the course details page. If they do have JavaScript, then they’ll get a fancy modal pop-up.

    Hope this helps. If you need anything clearing up then let me know, as I have wrote this in the early hours after a few JD and Cokes!

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have this code to decode numeric html entities to the UTF8 equivalent character.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.