mysql_get Advanced?

4 posts by 2 authors in: Forums > CMS Builder
Last Post: December 20, 2012   (RSS)

By Perchpole - December 19, 2012 - edited: December 19, 2012

Hello, All -

I'm looking for a small bit of code which will pull out a row from a table and which works a little like mysql_get.

mysql_get works like this:

mysql_get('table' match)


What I need is something more specific:

mysql_x('table' field, match)


Does such a thing exist?

:0)

Perch
Hi, Dave -

Thanks for this. What I am trying to do is call a row from a table based on the data created in a foreach loop.

The loop calls each category. What I'm trying to do is then call the first record (from the record table) which is assigned to that category. I asume it will work something like this:

<?php foreach($category as $thisCat): ?>

<?php $thisRow = mysql_x('record', $record['category'] == $thisCat['num']); ?>

<?php echo $thisRow['title'] ?>
<?php echo $thisRow['etc...'] ?>

<?php endforeach ?>


I need to pull out the entire row so that all of the data is accessible - even uploads.

Make sense?

:0)

Perch

By Dave - December 20, 2012

Hi Perch,

Try this (untested) code:

<?php foreach($category as $thisCat): ?>
  <?php $thisRow = mysql_get('recordTable', null, array('category' => $thisCat['num'])); ?>
  <?php addUploadsToRecord($thisRow); ?>

  <?php showme($thisRow); ?>

<?php endforeach ?>

Let me know if that works for you.  

Dave Edis - Senior Developer
interactivetools.com