close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

find individual comma separated values in database

Thread began 1/23/2010 10:02 pm by dave315749 | Last modified 4/24/2010 10:45 pm by dave315749 | 1722 views | 4 replies

tom250037Beta Tester

You could explode your comma separated string into an array, and then build a query that would pull the records for all those IDs, and then loop through that recordset on your page.

Right after your original recordset, you could have something like this.
This is assuming that your comma separated string is $row_Recordset1['related_course_ids']


$related_courses_query="WHERE 1=2";
if (isset($row_Recordset1['related_course_ids']) && $row_Recordset1['related_course_ids'] !=''){
$favorites_query="WHERE ";
$favorites_list_array=explode(",",$row_Recordset1['related_course_ids']);
foreach($id_list_array as $id){
if($id!='' && is_numeric($id)){
$id_query.="course_id=$id OR ";
$list=true;
}
}
if($list){
$id_query=substr($id_query,0,-3);
}else{
$id_query="WHERE 1=2";
}
}

//then for your courses query
mysql_select_db($database_dbc, $dbc);
$query_rsCourses = "SELECT * FROM courses $id_query";
$getPhotos = mysql_query($query_rsCourses, $dbc) or die(mysql_error());
$row_rsCourses = mysql_fetch_assoc($rsCourses);




Then you can loop though the rsCourses recordset, and provide a link to each related course.

Is that what you were looking for?

Tom

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...