[ic] + Predictive search box

Rick Bragg lists at gmnet.net
Mon Nov 26 20:12:24 UTC 2012


> I'm working with the predictive search box,
>
> I found the following example:
>
> http://scriptingmysql.wordpress.com/2011/10/28/using-mysql-perl-and-jquery-to-auto-populate-a-form-field-on-a-web-page/
>
>
>
> I tested it with Interchange database and works ok, but I would to use
> IC instead a unsecure perl cg, to search and format data ouput.
>
>
>
>> # obtain the results
>> while ( my $row = $query->fetchrow_hashref ){
>> push @query_output, $row;
>> }
>>
>> # close the database connection
>> $connect->disconnect();
>>
>> # print the json output to be returned to the HTML page
>> print JSON::to_json(\@query_output);
>
>
>
>
>
> I'm not a programmer :)
>
>
> Could a IC/Perl list guru, give me a little help??
>
>
> best regards
> Salvador Caballé
>

Hi Salvador,

Do you mean you would like to do this with IC ITL? (tags) instead of raw perl?  I
would use perl myself and avoid using tags where I can.  I'm not completely sure
what your question is, but the one thing that sticks out is the "print" function. 
Maybe set that to a tmp variable instead of printing it?

Maybe something like:

$Tag->tmpn('jsonoutput', JSON::to_json(\@query_output));

Then you should be able to [scratch jsonoutput] to use it on the page where you
need it...

What I see happening real quick is that the @query_output is an array of hash
references.  each hash in that array is one row in the database with the field name
as the key, and field content as the value.  Then you are sending a reference to
the array of hash refs to the JSON converter.  I have no idea if that helps but I
hope it does in some way ;)

Rick









More information about the interchange-users mailing list