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

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

Hi Perch,

So you just want a specific field only?

You can do it with two lines of code:
$record = mysql_get($tableName, null, array("username" => "dave")); // get first record where: username = dave
$city = @$record['city'];


Of you can use a help function we made called array_value() that lets you retrieve the value of a specific array element by name or number. Like this:
$city = array_value( mysql_get($tableName, null, array("username" => "dave")) , "city");

Let me know if either of those will work for you. Cheers!
Dave Edis - Senior Developer
interactivetools.com

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