13 Posts
smivan85
8 years ago
Topic

Hi all!
Need help. I need to show in one field in the "Site form" value from the database. I love SQL. But I don't know PHP syntax.
You will help me, if you show me an example of using "Core 42".
1. Displaying values from a custom database table.
2. Use in a SQL query the values from the form fields ("SELECT n1 FROM table1 WHERE n2 = user_input_value").
3. Special case. The Content Type contains a date in format "YYYY-mm-dd" (this field is already filled in "Site form"). I have to ask the database: "Dear MySQL, please show me what was in 'YYYY' year! Much obliged."
And also thank you!
(Joomla and Seblod latest version)

Get a VIP membership
8 years ago
1
Level 1

Hello smivan85,
after reading your post, I think you are not on the good way for using SEBLOD. (perhaps I'm wrong, but..)

Can you explain more what you are trying to do?
On which wiew are you? (Content view, search view,...)

Regards.
Lionel

13 Posts
smivan85
8 years ago
0
Level 2

Thank you for responding!
My site will be a service for reporting. The user sends me the information. Every day. The form I already have. Left to do something:
The user enters data on the amount of milk production. On the page the user sees: "My milk behind schedule!".
How to do it:
• Table "a" contains information about milk, added by the user (The content of the table: username, date reporting period, report data).
• Table "b" contains a plan in 2015 year for each user.
During data entry, as well as when you view the article, data from tables "a" and "b" are shown together.

8 years ago
1
Level 1

Hello smivan85,

so in your case I think you can use an override of position in the content view of your article.

In this view you have all fields from one content, so it stay to request the database to get fields from the other content and then generate your html.


Regards.

Lionel

13 Posts
smivan85
8 years ago
0
Level 2

Hello Lionel!

I'm sorry. The task is simple, but I am not able to explain properly.
Table "a" is a seblod article.
But let's leave it all.
I want a full example of the output values from the database using sql in core 42.
Examples on the forum, but the descriptions given are not completely.
This is what I found:

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('sowed_total');
$query->from('#__svod_plant05');
$db->setQuery($query);
$value = $db->loadResult();


I cant understand: that in which field to insert, to query start work. Options: I have just output a single value (not array). I don't need to save the value in database. That's all.
Thank you!

13 Posts
smivan85
8 years ago
0
Level 1

The answer to question 1: In PrepareForm:

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('sowed_total');
$query->from('#__svod_plan05');
$db->setQuery($query);
$value = $db->loadResult();

$form = "<input type=\"text\" id=\"05_p_sowed_total\" name=\"ddd\" value=\"$value\" />";


05_p_sowed_total — name field in Content type.
sowed_total — name field in database.
#__svod_plan05 — name database.
PrepareContent and PrepareStore is emty.

The answer to question 2. Insert values from other form fields looks like this:
$value = $cck->renderField('fieldName');
The answer to question 3. It's just. In CT to create another calendar with the format "YYYY". Or something like that.
P. S. I know SQL, css/html, delphi, regexp and other such nonsense. I created a simple Joomla!-sites since 2007. But I have almost no knowledge of php. The Seblod project need a good manual.

Thank you all.

13 Posts
smivan85
8 years ago
0
Level 1

Hi all!
This code works. "Prepare form", SQL in "core 42":

$n = '\'_01\'';
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('sowed_total');
$query->from('#__svod_plan05');
$query->where('region LIKE' . $n);
$db->setQuery($query);
$value = $db->loadResult();

$form = "";


But failed to insert the value of "Dynamic". (instead of \'_01\')
I hope to help.
Thank you!

13 Posts
smivan85
8 years ago
0
Level 1

Hi all!

In the end, we have this question:
Is there a way to get the field value from the form? "Core 42", "Prepare Form".

My project... he faces oblivion.

Sorry, i added the title of the topic.
Thanks for the hope!

13 Posts
smivan85
8 years ago
1
Level 1

Hi all!
Did it!
I must in the "core 42" use "live value"->"Profile-Adv":
this magic to give the value from the DB, from table advanced profile.
For my task, it's good. (42 outputs the values from the database in accordance with the address of residence of the current user)
This solution was already on the forum, I saw him, but did not understand:
http://www.seblod.com/v2/forum/105-General-Discussions/31984-Field-Core-42-PHP-code-is-not-working.html#32078

PrepareForm:

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('sowed_total');
$query->from('#__svod_plan05');
$query->where('region='.$value);
$db->setQuery($query);
$value = $db->loadResult();

$form = "<input type=\"text\" size=\"10\" id=\"05_p_sowed_total\" name=\"1\" value=\"$value\" />";

Thank you!

7 Posts
Xicaum
6 years ago
0
Level 2

Version 2 of the Seblod forum no longer exists. 

Where do I find the information on the core 42?

Get a VIP membership