ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

problems with php in code not working in EE

June 21, 2007 1:14am

Subscribe [1]
  • #1 / Jun 21, 2007 1:14am

    ummedia

    465 posts

    Hi I am having problems using php and could do with someone showing me the way all I want to do is set a variable with php and then echo it in the exp call, I actually want to set a variable then get it incremented each time a new entry is used but need to get it working to start off with. In the original template this works and when I run it through EE it doesnt any idea or pointers please

    <br /> <?php<br /> $categorycount = 0;<br /> ?><br /> <table><tr><br /> {exp:query sql="SELECT count( exp_category_posts.entry_id ) AS count,<br /> exp_category_posts.cat_id, exp_categories.cat_name<br /> FROM exp_categories, exp_category_posts<br /> WHERE exp_category_posts.cat_id = exp_categories.cat_id<br /> GROUP BY exp_categories.cat_name"}<br /> <td width=169 height=93 valign=top><a href="http://{path=intelart/category}C{cat_id}/">http://www.ummedia.com/MY_SITES/fatlava/Resources/suitcase.gif</a><br /> {cat_name} ({count})(<?php echo $categorycount; ?>)</td><br /> {/exp:query}<br /> </tr></table> <br />

    many thanks adan

  • #2 / Jun 21, 2007 1:28am

    ummedia

    465 posts

    please ignore parsing was turned off in my templates, I just cant now get the count to increment by one this is the code

    <br /> <?php<br /> $categorycount = 0;<br /> ?><br /> <table><tr><br /> {exp:query sql="SELECT count( exp_category_posts.entry_id ) AS count,<br /> exp_category_posts.cat_id, exp_categories.cat_name<br /> FROM exp_categories, exp_category_posts<br /> WHERE exp_category_posts.cat_id = exp_categories.cat_id<br /> GROUP BY exp_categories.cat_name"}<br /> <?php $categorycount++;?><br /> <td width=169 height=93 valign=top><a href="http://{path=intelart/category}C{cat_id}/">http://www.ummedia.com/MY_SITES/fatlava/Resources/suitcase.gif</a><br /> {cat_name} ({count})(<?php echo $categorycount; ?>)</td><br /> {/exp:query}<br /> </tr></table> <br />

    I am not a coder so it must be something I am doing when the exp loops does it not know that it is being incremented. It always returns the count of one please help me before I go insane with something the should be sooo easy

    many thanks

    Adam

    regards Adam

  • #3 / Jun 21, 2007 8:48am

    ummedia

    465 posts

    please could someone help. at least tell me I have no idea what I am doing and give me some direction.

    many thanks

    Adam

  • #4 / Jun 21, 2007 9:02am

    ummedia

    465 posts

    sorted it I just had to change the count in the query to count_1 and all was well

    Adam

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases