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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:46:45+00:00 2026-06-16T02:46:45+00:00

Below I have a mysqli query which does successfully work; $courseid = (isset($_POST[‘courses’])) ?

  • 0

Below I have a mysqli query which does successfully work;

$courseid = (isset($_POST['courses'])) ? $_POST['courses'] : ''; 
$moduleid = (isset($_POST['moduleid'])) ? $_POST['moduleid'] : '';  
$moduleno = (isset($_POST['moduleno'])) ? $_POST['moduleno'] : '';  
$modulename = (isset($_POST['modulename'])) ? $_POST['modulename'] : '';

$query = "SELECT cm.CourseId, CourseNo, CourseName, cm.ModuleId 
FROM  Course c 
INNER JOIN Course_Module cm 
ON
c.CourseId = cm.CourseId
JOIN Module m
ON
cm.ModuleId = m.ModuleId
WHERE cm.CourseId = ? AND cm.ModuleId = ?";
// prepare query
$stmt=$mysqli->prepare($query);
// You only need to call bind_param once
$stmt->bind_param("ii", $courseid, $moduleid);
// execute query
$stmt->execute(); 
// get result and assign variables (prefix with db)
$stmt->bind_result($dbCourseId, $dbCourseNo, $dbCourseName, $dbModuleId);
//get number of rows
$stmt->store_result();
$numrows = $stmt->num_rows();

The problem I am getting though is in my success message. It is able to output the $moduleno and $modulename variables but it does not output the $dbCourseNo and $dbCourseName variables in the success message. Why is this?

if ($numrows == 1){

echo "<span style='color: green'>The following Module has been added into Course:" . $dbCourseNo . " - " . $dbCourseName . ":<br/>" . $moduleno . " - " . $modulename . "</span>";

}
  • 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-16T02:46:46+00:00Added an answer on June 16, 2026 at 2:46 am

    You never actually fetched the result, and I suspect the variables that do show are stale from a previous operation.

    $stmt->execute(); 
    // get result and assign variables (prefix with db)
    $stmt->bind_result($dbCourseId, $dbCourseNo, $dbCourseName, $dbModuleId);
    
    // Can't remember, but you may need to call store_result() before bind_result() ??
    // maybe not...
    $stmt->store_result();
    $numrows = $stmt->num_rows();
    // Fetch the row...
    $stmt->fetch();
    // Now your variables are populated.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the query below which works great. SELECT `Despatch`.`DespatchNumber` , `Despatch`.`Product` , `Stock`.`ProductNumber`
Using the MySQL query below, I have created a pivot table which is pretty
I have a query which is returning the below explain: id select_type table type
Possible Duplicate: php/Mysql query with inserting date fails I have a datepicker code below:
I have written this query for retrieving data from mysql as below select FeedbackCode,EMailID,FeedbackDetail,
I have a jquery code below which is displayed in the editsessionadmin.php page. Now
I have created a subversion hook which does various things including sending out emails
I have the following mysql query which is taking about 3 minutes to run.
I have code which is essentially $query = mysql_query('SELECT `foo` FROM `Bar` WHERE id=1',
I have a script below which reads on displayed information from my mysql database

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.