Home | Products | Consulting | Forums | Support | Order | 1-800-752-0455
  Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
$options['where']

 

 


brownleather
User

Feb 19, 2008, 10:29 AM

Post #1 of 5 (496 views)
Shortcut
$options['where'] Can't Post

Example: 'fieldname = "value"'

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


(This post was edited by brownleather on Feb 19, 2008, 10:37 AM)


Dave
Staff / Moderator


Feb 19, 2008, 11:10 AM

Post #2 of 5 (489 views)
Shortcut
Re: [brownleather] $options['where'] [In reply to] Can't Post

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


mawebplus
User

Mar 28, 2008, 12:47 PM

Post #3 of 5 (378 views)
Shortcut
Re: [Dave] $options['where'] [In reply to] Can't Post

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
?>
<?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 = '$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


Dave
Staff / Moderator


Mar 28, 2008, 12:56 PM

Post #4 of 5 (376 views)
Shortcut
Re: [mawebplus] $options['where'] [In reply to] Can't Post

Hi mawebplus,

Double check your second block of code. If you're calling your options $options2 you want to make sure you're passing that to getRecord as well:


Code
$record = getRecord($options2);


Also, you might want to name your $record variables something else so they don't overwrite each other. For example, $cajasRecord.

Let me know if that helps!

Dave Edis - Senior Developer
interactivetools.com


mawebplus
User

Mar 28, 2008, 1:10 PM

Post #5 of 5 (375 views)
Shortcut
Re: [Dave] $options['where'] [In reply to] Can't Post

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

 
 
 


Search for (options)
Products
CMS Builder
Article Manager
Realty Manager
Listings Manager
Order Now
Services
Priority Consulting
Support
Online Documentation
Support Forums
Support Homepage
Company Info
12 reasons to choose us!
Meet the team
Monthly newsletter
Contact Us
Toll Free: 1-800-752-0455
Phone: (604) 689-3347
Sales | Support
Conditions of Use | Privacy Policy | Copyright © interactivetools.com 2008
#201 - 2730 Commercial Drive, Vancouver BC Canada V5N 5P4