assign php vairable to object

This section is for posting questions which are not directly related to WYSIWYG Web Builder.
Examples of off topics: web server configuration, hosting, programming related questions, third party scripts.

Note that these questions will generally not be answered by the administrators of this forum.
Post Reply
tristan
 
 
Posts: 20
Joined: Tue Dec 17, 2019 3:21 pm

assign php vairable to object

Post by tristan »

If I have a block of text with ID = text1 how do I assign $myphpvairable to it?
User avatar
Pablo
 
Posts: 21712
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: assign php vairable to object

Post by Pablo »

Where exactly do you want to assign the variable?
What are you trying to do?
tristan
 
 
Posts: 20
Joined: Tue Dec 17, 2019 3:21 pm

Re: assign php vairable to object

Post by tristan »

Thanks so much for getting back to me, it is excellent how much you back your product! (I have been a customer since version 9).

I am trying to set up a web page that is heavily reliant on a database, basically a management information system for farmers.

I am pretty good with sql queries and can do complex table joins etc but only know basic php (enough to get the data in and out).

I thought the best way to dispaly would be to set up a webpage and anywhere I wanted to display a field from my database put a text box. Then using the WYSIWG WB "Page HTML" menu item insert code (at the end of the page) that replaces the default text value with the result from the mysql query.

Maybe I am going about it all wrong?

I've tried the following (both failed), though this isn't quiet what I want (just a stepping stone), I thought once I worked out how this worked then I might be able drag and drop a text field on the page, format it how I want it to display and then put something like wb_text2 = $FarmNameResult in the object html after tag.

<html>
<div id="wb_Text2" style="position:absolute;left:300px;top:200px;width:83px;height:534px;z-index:2;">
<span style="color:#000000;font-family:Arial;font-size:12px;">Double click </span>Farm Name. $FarmNameResult
</div>
</html>

<html>
<div id="wb_Text2" style="position:absolute;left:300px;top:200px;width:83px;height:534px;z-index:2;">
<span style="color:#000000;font-family:Arial;font-size:12px;">Double click </span><?php echo FarmName .$FarmNameResult; ?>
</div>
</html>
Last edited by tristan on Mon Oct 31, 2022 9:52 am, edited 1 time in total.
User avatar
Pablo
 
Posts: 21712
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: assign php vairable to object

Post by Pablo »

In that case, you can try to place the variable directly inside the text.

Code: Select all

<?php echo $myphpvariable' ?>
Make sure you enable the option 'Do not encode HTML characters' in the properties of the text object.
tristan
 
 
Posts: 20
Joined: Tue Dec 17, 2019 3:21 pm

Re: assign php vairable to object

Post by tristan »

OMG that easy ... looks like it was the "do not encode" flag was the thing causing me all the problems :)

Thanks :)
tristan
 
 
Posts: 20
Joined: Tue Dec 17, 2019 3:21 pm

Re: assign php vairable to object

Post by tristan »

So for anyone else looking to do this ...

Query your database and fill your vairables using the <HTML> menu button (at the page level) and put your php code after the <body> tag.

For the text field put your <?php echo $myphpvairable ?> in the actual text box (not in html)

Works a treat :)
Post Reply