PDA

View Full Version : How to Insert Version Number in Footer


mokonzi
06 Sep 2010, 09:08
I'm looking into using the version number from one of my projects in the footer. I can cope with phrasing, and know how to edit the template to add what I need, but I'm stuck on how to extract the number from PT that I need.

How can I collect the latest version number, and then add it as a variable to the template?

Thanks for any help in advance... :)

PitchouneN64ngc
10 Sep 2010, 10:05
You need to use a query like:

SELECT version FROM product WHERE productid = 'vbprojecttools';

mokonzi
11 Sep 2010, 08:02
Thanks for the help. So far, I've been able to get this query to work:

$version = $db->query_first("
SELECT 'versioname'
FROM mytable_pt_projectversion
WHERE projectid = 2 AND projectversiongroupid = 1 AND displayorder = 10;
");

vB_Template::preRegister('footer',array('txuversion' => $version));

But all that displays when I include the variable is array.

Am I missing something obvious?

Thanks again for the help, I'm a total noobie when it comes to programming... :)

Mosh
11 Sep 2010, 08:43
Thanks for the help. So far, I've been able to get this query to work:

$version = $db->query_first("
SELECT 'versioname'
FROM mytable_pt_projectversion
WHERE projectid = 2 AND projectversiongroupid = 1 AND displayorder = 10;
");

vB_Template::preRegister('footer',array('txuversion' => $version));

But all that displays when I include the variable is array.

Am I missing something obvious?

Thanks again for the help, I'm a total noobie when it comes to programming... :)
It is because it is an array of fields (in this case 1 field) you are getting back from your query.... you need to register the field, not the array, so your register line should probably look something like this:
vB_Template::preRegister('footer',array('txuversion' => $version['versioname']));

mokonzi
11 Sep 2010, 11:13
I got it working by doing this:

$version = $db->query_first("
SELECT versionname
FROM mytable_pt_projectversion
WHERE projectid = 2 AND projectversiongroupid = 1 AND displayorder = 10;
");

vB_Template::preRegister('footer',array('version' => $version['versionname']));

I'd made one mistake, that is adding 'versioname' in ' and then versionname was spelt with one n... :)

Now just to select the right row... :D

PS, thanks for the help :)