This topic is locked

Inserting php/mysql code in Visual Editor

4/18/2007 11:39:03 PM
PHPRunner General questions
D
dani author

Hello
On every row of the list screen I'd like it to show how many detail records are for that particular master record. I have the code I'd like to insert, but I don't know how to make the Visual Editor (in HTML text mode, of course) recognize what I enter as valid code.
The idea of entering in the Visual Editor instead of modifying the built code is to avoid the build to scrap them every time.
What I've tried:

<TD align=middle><A

href="orderdetails_list.php?{$row.1orderdetails_masterkeys}">orderdetails</A>

<?php

$query2 = "SELECT count(*) as num FROM orderdetails where orderid = '$row.1orderid_value' ";

$query3 = mysql_query($query2);

$record_count = mysql_fetch_assoc($query3); echo $record_count['num'];

?>

</TD>


But it doesn't seem to work.... <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=5048&image=1&table=forumtopics' class='bbc_emoticon' alt=':(' />
It's tricky because there are 4 layers (PHPRunner,HTML,php and MySQL) and each one needs to understand/process/parse some parts of the code, take others as literal, and pass the data to the next stage.
Any ideas?
Thanks!
Dani

Alexey admin 4/19/2007

Hi,
you can not add PHP code to visual files.
The easiest way to add a detail table records count is modifying SQL query.

Add a subqery there:

select

...

*(select count() from orderdetails where orderid=orders.id) as detailscount**

from ...


Then open List page in Visual Editor and move detailscount field to a proper place.
Please note that subqueries are supported by MySQL 5 only.

If you use MySQL 4 contact me by support@xlinesoft.com and I'll help you to create a code snippet.