Jump to content

Is this okay?


claro

Recommended Posts

not really... since you're searching for a specific course_id in your database, I'm assuming $_POST['course'] is just a number (or a reference) and therefor, does not need to be converted into an array.

 

if(isset($_POST['course']){
   $course = trim($_POST['course']);
   mysql_query ("SELECT * FROM tbl_course WHERE course_Id = '$course'") or die (mysql_error());
   //... rest of database request
}else{
   echo 'No course selected.';
}

Link to comment
Share on other sites

I'm so sorry, I think I didnt explain myself well.

 

It should not be course_Id, course_Title instead, I want to select all files FRom tb_course where course_Title is the selected arrays..what if I have two or more course_Title selected. THank you for your response by the way.

 

Link to comment
Share on other sites

in that case, you need something like this:

 

// this grabs each title and creates a string with each one wrapped in single quotes
$titles = "'".implode("','",$_POST['course'])."'";
// use the mysql IN command to check all the titles at once. Change course_title to your REAL field name
mysql_query ("SELECT * FROM tbl_course WHERE course_title IN ($titles)");

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.