$options['where']

5 posts by 3 authors in: Forums > CMS Builder
Last Post: March 28, 2008   (RSS)

By brownleather2 - February 19, 2008 - edited: February 19, 2008

Example: 'fieldname = "value"'

I’d like to call a variable for the value, what do I do? == Example: 'fieldname = "$var"' == dose not work

Re: [brownleather] $options['where']

By Dave - February 19, 2008

You're very close. In PHP variables are only replaced with their values (or "interpolated" as programmer types say) in "double quoted strings". So, basically instead of 'single quotes' use "double quotes" and it will work.

Also, don't forget to escape your variables before you use them in MySQL. Like this:

$escapedVar = escapeMysqlString($var);
$options['where'] = "fieldname = '$escapedVar'";

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] $options['where']

By mawebplus - March 28, 2008

hello, i was reading this post and have the same issue not working i have as follows:

require_once "............viewer_functions.php";
$options = array(); // NOTE: see online documentation for more details on these options
$options['tableName'] = 'vehiculos'; // (REQUIRED) MySQL tablename to list record from. Example: "article";
$options['recordNum'] = '9'; // (optional) Record number to display. Example: "1"; Defaults to number on end of url, then 1
$options['where'] = ''; // (ADVANCED) MySQL WHERE conditions to use INSTEAD of recordNum to look up record. Example: "fieldname = 'value'"
$record = getRecord($options);

would like it to be replaced with a value from another table in mysql so i did this:

require_once "............viewer_functions.php";
$options = array(); // NOTE: see online documentation for more details on these options
$options['tableName'] = 'cajas'; // (REQUIRED) MySQL tablename to list record from. Example: "article";
$options['recordNum'] = '1'; // (optional) Record number to display. Example: "1"; Defaults to number on end of url, then 1
$options['where'] = ''; // (ADVANCED) MySQL WHERE conditions to use INSTEAD of recordNum to look up record. Example: "fieldname = 'value'"
$record = getRecord($options);
$cajita = $record['caja1']; this is to have a value from one table[/#ff0000]
?>
<?php
require_once "............viewer_functions.php";
$options2 = array(); // NOTE: see online documentation for more details on these options
$options2['tableName'] = 'vehiculos'; // (REQUIRED) MySQL tablename to list record from. Example: "article";
$options2['recordNum'] = ''; // (optional) Record number to display. Example: "1"; Defaults to number on end of url, then 1
$escapedVar = escapeMysqlString($cajita);
$options2['where'] = "num[/#ff0000] = '$escapedVar'";
// (ADVANCED) MySQL WHERE conditions to use INSTEAD of recordNum to look up record. Example: "fieldname = 'value'"
$record = getRecord($options);

but for some reason itwont work dispaying $record['num'] as the number in $cajita

any help with this would be great

Re: [Dave] $options['where']

By mawebplus - March 28, 2008

you guys rock!

finally i madea page with 3 iframes calling 3 different things that the client simply changes on admin fields thnx!!

to share it:

http://www.awebolovendo.com/index.php

the three pics on top