colorada
08-06-2007, 03:18 PM
Hello,
I need help with finalizing on how to edit the data grid component. I am using PHP and MySQL. Basically I have created a form that writes to a database. I would like to have it set up where the datagrid can be updated and written to the database real time in case an update is required.
PHP
<?php
define( "DATABASE_SERVER", "localhost" );
define( "DATABASE_USERNAME", "root" );
define( "DATABASE_PASSWORD", "" );
define( "DATABASE_NAME", "sample" );
//connect to the database
$mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD);
mysql_select_db( DATABASE_NAME );
// Quote variable to make safe
function quote_smart($value)
{
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
// Quote if not integer
if (!is_numeric($value)) {
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}
if( $_POST["emailaddress"] AND $_POST["username"] AND $_POST["sitename"] AND $_POST["wott"] AND $_POST["date"] AND $_POST["resolution"]AND $_POST["complete"])
{
//add the user
$Query = sprintf("INSERT INTO users VALUES ('', %s, %s, %s, %s, %s, %s, %s)", quote_smart($_POST['username']), quote_smart($_POST['emailaddress']), quote_smart($_POST['sitename']), quote_smart($_POST['wott']), quote_smart($_POST['date']), quote_smart($_POST['resolution']), quote_smart($_POST['complete']));
$Result = mysql_query( $Query );
}
//return a list of all the users
$Query = "SELECT * from users";
$Result = mysql_query( $Query );
$Return = "<users>";
while ( $User = mysql_fetch_object( $Result ) )
{
$Return .= "<user><userid>".$User->userid."</userid><username>".$User->username."</username><emailaddress>".$User->emailaddress."</emailaddress><sitename>".$User->sitename."</sitename><wott>".$User->wott."</wott><date>".$User->date."</date><resolution>".$User->resolution."</resolution><complete>".$User->complete."</complete></user>";
}
$Return .= "</users>";
mysql_free_result( $Result );
print ($Return)
?>
//FLex 2 AS3 and MMXML
<?xml version="1.0"?>
<!-- Simple example to demonstrate the TabNavigator layout container. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" creationComplete="userRequest.send()">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.collections.*;
/*import mx.rpc.events.*;*/
[Bindable]
private var mySelectedIndex:int = 0;
public var techInfo:ArrayCollection;
private function bookHandler(evt:ResultEvent):void
{
}
]]>
</mx:Script>
<mx:HTTPService id="userRequest" url="http://localhost/technician/request.php" useProxy="false" method="POST">
<mx:request xmlns="">
<username>{username.text}</username>
<emailaddress>{emailaddress.text}</emailaddress>
<sitename>{sitename.text}</sitename>
<wott>{wott.text}</wott>
<date>{date.text}</date>
<resolution>{resolution.text}</resolution>
<complete>{complete.text}</complete>
</mx:request>
</mx:HTTPService>
<!--This is the data Provider XML File for Technicians-->
<mx:Model id="technician" source="techs.xml"/>
<!--This is the data Provider XML File for Site Information-->
<mx:Model id="siteInfo" source="sites.xml"/>
<mx:Panel title="T-Mobile Jacksonville Reporting" height="90%" width="90%"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10" x="86" y="-4">
<mx:TabNavigator id="tn" width="100%" height="100%" >
<!-- Define each panel using a VBox container. -->
<mx:VBox label="Landlink">
<mx:Label text="Landlink"/>
</mx:VBox>
<mx:VBox label="Site Source South">
<mx:Label text="Site Source South"/>
</mx:VBox>
<mx:VBox label="Field Ops" horizontalAlign="center">
<mx:Form width="100%" height="100%" >
<mx:HBox>
<mx:Label text="Username "/>
<mx:ComboBox id="username" dataProvider="{technician.tech}" width="170">
</mx:ComboBox>
</mx:HBox>
<mx:HBox>
<mx:Label text="Site ID "/>
<mx:ComboBox id="emailaddress" width="170" dataProvider="{siteInfo.SITE}" labelField="site_id" selectedIndex="{mySelectedIndex}" change="mySelectedIndex = ComboBox(event.target).selectedIndex">
</mx:ComboBox>
</mx:HBox>
<mx:HBox>
<mx:Label text="Site Name "/>
<mx:ComboBox id="sitename" width="170" dataProvider="{siteInfo.SITE}" labelField="site_name" selectedIndex="{mySelectedIndex}" change="mySelectedIndex = ComboBox(event.target).selectedIndex">
</mx:ComboBox>
</mx:HBox>
<mx:HBox>
<mx:Label text="WO / TT "/>
<mx:TextInput id="wott" textAlign="left" width="170"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="Date "/>
<mx:DateField id="date" width="170"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="Resolution " />
<mx:TextInput id="resolution" textAlign="left" width="170" height="50"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="Complete "/>
<mx:ComboBox id="complete">
<mx:ArrayCollection>
<mx:String>Yes</mx:String>
<mx:String>No</mx:String>
<mx:String>Sent to RF</mx:String>
<mx:String>Pending Vendor</mx:String>
</mx:ArrayCollection>
</mx:ComboBox>
</mx:HBox>
<mx:Button label="Submit" click="userRequest.send()"/>
</mx:Form>
<mx:Panel x="343" y="10" backgroundColor="#B3C0C6" title="Trouble Ticket Tracking" borderAlpha="0.4" borderThicknessBottom="10" width="100%" height="351" layout="absolute">
<mx:DataGrid id="dgUserRequest" x="218" y="10" dataProvider="{userRequest.lastResult.users.user}" width="100%" height="100%" editable="true" enabled="true" change="dgUserRequest">
<mx:columns>
<!-- <mx:DataGridColumn headerText="User ID" dataField="userid"/>-->
<mx:DataGridColumn headerText="Technician" dataField="username"/>
<mx:DataGridColumn headerText="Site ID" dataField="emailaddress"/>
<mx:DataGridColumn headerText="Site Name" dataField="sitename"/>
<mx:DataGridColumn headerText="WO / TT" dataField="wott"/>
<mx:DataGridColumn headerText="Date" dataField="date"/>
<mx:DataGridColumn headerText="Resolution" dataField="resolution" />
<mx:DataGridColumn headerText="Complete" dataField="complete"/>
</mx:columns>
</mx:DataGrid>
<mx:TextArea id="selectedemailaddress" text="{dgUserRequest.selectedItem.resolution}" width="200" height="298" x="10" y="10" wordWrap="true" editable="false" enabled="true"/>
</mx:Panel>
</mx:VBox>
<mx:Canvas label="Generator Fuel Log" width="100%" height="100%">
<mx:Label text="Generator Fuel Log"/>
</mx:Canvas>
</mx:TabNavigator>
<mx:HBox>
<mx:Button label="Landlink" click="tn.selectedIndex=0"/>
<mx:Button label="Site Source South" click="tn.selectedIndex=1"/>
<mx:Button label="Field Ops" click="tn.selectedIndex=2"/>
<mx:Button label="Generator Fuel Log" click="tn.selectedIndex=3"/>
</mx:HBox>
</mx:Panel>
</mx:Application>
thx,
colorada
I need help with finalizing on how to edit the data grid component. I am using PHP and MySQL. Basically I have created a form that writes to a database. I would like to have it set up where the datagrid can be updated and written to the database real time in case an update is required.
PHP
<?php
define( "DATABASE_SERVER", "localhost" );
define( "DATABASE_USERNAME", "root" );
define( "DATABASE_PASSWORD", "" );
define( "DATABASE_NAME", "sample" );
//connect to the database
$mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD);
mysql_select_db( DATABASE_NAME );
// Quote variable to make safe
function quote_smart($value)
{
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
// Quote if not integer
if (!is_numeric($value)) {
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}
if( $_POST["emailaddress"] AND $_POST["username"] AND $_POST["sitename"] AND $_POST["wott"] AND $_POST["date"] AND $_POST["resolution"]AND $_POST["complete"])
{
//add the user
$Query = sprintf("INSERT INTO users VALUES ('', %s, %s, %s, %s, %s, %s, %s)", quote_smart($_POST['username']), quote_smart($_POST['emailaddress']), quote_smart($_POST['sitename']), quote_smart($_POST['wott']), quote_smart($_POST['date']), quote_smart($_POST['resolution']), quote_smart($_POST['complete']));
$Result = mysql_query( $Query );
}
//return a list of all the users
$Query = "SELECT * from users";
$Result = mysql_query( $Query );
$Return = "<users>";
while ( $User = mysql_fetch_object( $Result ) )
{
$Return .= "<user><userid>".$User->userid."</userid><username>".$User->username."</username><emailaddress>".$User->emailaddress."</emailaddress><sitename>".$User->sitename."</sitename><wott>".$User->wott."</wott><date>".$User->date."</date><resolution>".$User->resolution."</resolution><complete>".$User->complete."</complete></user>";
}
$Return .= "</users>";
mysql_free_result( $Result );
print ($Return)
?>
//FLex 2 AS3 and MMXML
<?xml version="1.0"?>
<!-- Simple example to demonstrate the TabNavigator layout container. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" creationComplete="userRequest.send()">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.collections.*;
/*import mx.rpc.events.*;*/
[Bindable]
private var mySelectedIndex:int = 0;
public var techInfo:ArrayCollection;
private function bookHandler(evt:ResultEvent):void
{
}
]]>
</mx:Script>
<mx:HTTPService id="userRequest" url="http://localhost/technician/request.php" useProxy="false" method="POST">
<mx:request xmlns="">
<username>{username.text}</username>
<emailaddress>{emailaddress.text}</emailaddress>
<sitename>{sitename.text}</sitename>
<wott>{wott.text}</wott>
<date>{date.text}</date>
<resolution>{resolution.text}</resolution>
<complete>{complete.text}</complete>
</mx:request>
</mx:HTTPService>
<!--This is the data Provider XML File for Technicians-->
<mx:Model id="technician" source="techs.xml"/>
<!--This is the data Provider XML File for Site Information-->
<mx:Model id="siteInfo" source="sites.xml"/>
<mx:Panel title="T-Mobile Jacksonville Reporting" height="90%" width="90%"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10" x="86" y="-4">
<mx:TabNavigator id="tn" width="100%" height="100%" >
<!-- Define each panel using a VBox container. -->
<mx:VBox label="Landlink">
<mx:Label text="Landlink"/>
</mx:VBox>
<mx:VBox label="Site Source South">
<mx:Label text="Site Source South"/>
</mx:VBox>
<mx:VBox label="Field Ops" horizontalAlign="center">
<mx:Form width="100%" height="100%" >
<mx:HBox>
<mx:Label text="Username "/>
<mx:ComboBox id="username" dataProvider="{technician.tech}" width="170">
</mx:ComboBox>
</mx:HBox>
<mx:HBox>
<mx:Label text="Site ID "/>
<mx:ComboBox id="emailaddress" width="170" dataProvider="{siteInfo.SITE}" labelField="site_id" selectedIndex="{mySelectedIndex}" change="mySelectedIndex = ComboBox(event.target).selectedIndex">
</mx:ComboBox>
</mx:HBox>
<mx:HBox>
<mx:Label text="Site Name "/>
<mx:ComboBox id="sitename" width="170" dataProvider="{siteInfo.SITE}" labelField="site_name" selectedIndex="{mySelectedIndex}" change="mySelectedIndex = ComboBox(event.target).selectedIndex">
</mx:ComboBox>
</mx:HBox>
<mx:HBox>
<mx:Label text="WO / TT "/>
<mx:TextInput id="wott" textAlign="left" width="170"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="Date "/>
<mx:DateField id="date" width="170"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="Resolution " />
<mx:TextInput id="resolution" textAlign="left" width="170" height="50"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="Complete "/>
<mx:ComboBox id="complete">
<mx:ArrayCollection>
<mx:String>Yes</mx:String>
<mx:String>No</mx:String>
<mx:String>Sent to RF</mx:String>
<mx:String>Pending Vendor</mx:String>
</mx:ArrayCollection>
</mx:ComboBox>
</mx:HBox>
<mx:Button label="Submit" click="userRequest.send()"/>
</mx:Form>
<mx:Panel x="343" y="10" backgroundColor="#B3C0C6" title="Trouble Ticket Tracking" borderAlpha="0.4" borderThicknessBottom="10" width="100%" height="351" layout="absolute">
<mx:DataGrid id="dgUserRequest" x="218" y="10" dataProvider="{userRequest.lastResult.users.user}" width="100%" height="100%" editable="true" enabled="true" change="dgUserRequest">
<mx:columns>
<!-- <mx:DataGridColumn headerText="User ID" dataField="userid"/>-->
<mx:DataGridColumn headerText="Technician" dataField="username"/>
<mx:DataGridColumn headerText="Site ID" dataField="emailaddress"/>
<mx:DataGridColumn headerText="Site Name" dataField="sitename"/>
<mx:DataGridColumn headerText="WO / TT" dataField="wott"/>
<mx:DataGridColumn headerText="Date" dataField="date"/>
<mx:DataGridColumn headerText="Resolution" dataField="resolution" />
<mx:DataGridColumn headerText="Complete" dataField="complete"/>
</mx:columns>
</mx:DataGrid>
<mx:TextArea id="selectedemailaddress" text="{dgUserRequest.selectedItem.resolution}" width="200" height="298" x="10" y="10" wordWrap="true" editable="false" enabled="true"/>
</mx:Panel>
</mx:VBox>
<mx:Canvas label="Generator Fuel Log" width="100%" height="100%">
<mx:Label text="Generator Fuel Log"/>
</mx:Canvas>
</mx:TabNavigator>
<mx:HBox>
<mx:Button label="Landlink" click="tn.selectedIndex=0"/>
<mx:Button label="Site Source South" click="tn.selectedIndex=1"/>
<mx:Button label="Field Ops" click="tn.selectedIndex=2"/>
<mx:Button label="Generator Fuel Log" click="tn.selectedIndex=3"/>
</mx:HBox>
</mx:Panel>
</mx:Application>
thx,
colorada