This topic is locked
[SOLVED]

 Export xml - After Save data and silent

2/16/2012 11:12:53 AM
PHPRunner General questions
M
mickna author

Hi there,
is there a way to trigger export after some data is saved in a table AND do this silent (no choosing if XML, Word, etc. It is XML and no brwosing where to save)
Background:

I try to connect some XML-files from some tables with a flash-file (flashplayer pulls out data from xml and shows them)

So if a user changes some values in a table and press save, a new (updated) xml file has to be written over the old one. This should be done automatic (I'll guess snipped in "After record updated") and silent in the background...
any help?

thx,

mickna

Sergey Kornilov admin 2/16/2012

Yes, this definitely can be done assuming that XML files reside on the same server. 'After record updated' is the right place to perform such a job.

M
mickna author 2/16/2012

@Sergey :
Thank you. But how can I do this? Can I use the export.php? I do not think so...

So I have to write my own php for this?
thx,

Mickna

Sergey Kornilov admin 2/16/2012

You have to write your own PHP code for this purpose. Here is a very basic example of displaying database data as XML. You will need to remove the connection part and save XML to file instead of sending it to the browser.

<?php

//XML output of an existing MySql database

header("Content-type: text/xml");
//to create connection to database

$connection = mysql_connect("127.0.0.1","username", "password")

or die ("could not connect to database");
//to select the database here test is the sample database come with mysql

$db = mysql_select_db("test",$connection)

or die ("Couldn't select database.");
$rs = mysql_query("select * from tablename",$connection)

or die ("invalid query");
//count the no. of columns in the table

$fcount = mysql_num_fields($rs);
//you can choose any name for the starting tag

echo ("<result>");

while($row = mysql_fetch_array( $rs ) )

{

echo ("<tablerow>");

for($i=0; $i< $fcount; $i++)

{

$tag = mysql_field_name( $rs, $i );

echo ("<$tag>". $row[$i]. "</$tag>");

}

echo ("</tablerow>");

}

echo ("</result>");

?>


Google shows many examples of doing that. I've picked the basic one.

M
mickna author 2/17/2012

Thank you.

I found another code which works after tweaking.
With your example I have had problems with mysql and mysqli (mysql_fetch_array throws out an error and mysqli_fetch_array did not exists as a syntax)
Anyway: Thank you, all is working now <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=64374&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />