Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Quick MySQL Lookup

 

 


Perchpole
User

Dec 6, 2011, 3:11 PM

Post #1 of 4 (573 views)
Shortcut
Quick MySQL Lookup Can't Post

 
This seems so silly but I can't get my head around it...

I'm using a list field to pull data from a bunch of other records in another table.

In this case the value is the record $num and the label is the record $title - or at least it should be.

In order to make it easier for the user to find the the right record in the list, I'm using the breadcrumb option.

So whenever I return the label of this field, what I actually get is the entire breadcrumb trail : etc : etc!

All I actually need is the record $title.

I think I need to perform some sort of mini mysql look-up which would work something like this:


Code
look-up this table and return the $title which matches this $num


...or something like that.

Can anyone help, please?

:o)

Perch


gkornbluth
Veteran

Dec 6, 2011, 7:45 PM

Post #2 of 4 (562 views)
Shortcut
Re: [Perchpole] Quick MySQL Lookup [In reply to] Can't Post

Hi Perch,

Don't have any idea if this will help. but I used it to limit the values returned.

You might be able to use the same approach and echo the $title

foreach ($master_subscription_pagesRecords as $record): ?>
<?php if ($record['createdByUserNum']== @$CURRENT_USER['num']): ?>

more code...

Just a thought...

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!
http://www.thecmsbcookbook.com


Jason
Staff / Moderator


Dec 7, 2011, 10:22 AM

Post #3 of 4 (553 views)
Shortcut
Re: [Perchpole] Quick MySQL Lookup [In reply to] Can't Post

Hi Perch,

If you're using CMS Builder version 2.08 or higher, you can use something like this:

Since you're using breadcrumb as an option, I'm assuming that this is pulling from a category section. Assuming that this section is named "categories" and the field in your record is called "category", you can get the corresponding record like this:


Code
<?php 
$category = mysql_get('categories', $record['category']);
echo $category['title'];
?>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/ 


Perchpole
User

Dec 7, 2011, 11:55 AM

Post #4 of 4 (551 views)
Shortcut
Re: [Jason] Quick MySQL Lookup [In reply to] Can't Post

Jason -

Perfect. Exactly what I was looking for.

:0)

Perch

PS. Thanks for chipping in Gerry.