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
https://forums.phpfreaks.com/topic/249692-is-this-okay/#findComment-1281730
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
https://forums.phpfreaks.com/topic/249692-is-this-okay/#findComment-1281732
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
https://forums.phpfreaks.com/topic/249692-is-this-okay/#findComment-1281733
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.