Im making a small project in flex. The user can look up bookreviews. When types in the name of the book i get all the reviews back instead of the reviews of that particular book.
my code:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
>
<fx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
public function handleMenu(event:ResultEvent):void{
DescrBooks.dataProvider = event.result.menu.menuitem;
}
public function Start():void{
//favorieten.addEventListener(ResultEvent.RESULT,handleMenu);
favorieten.send();
}
public function ShowBooks(SelectedBooks:Object):String{
var descr:String = SelectedBooks.itemDesc;
var D:String = descr
return D;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here
-->
<s:HTTPService id="favorieten"
url="http://www.gertjanvanhove2012.dreamhosters.com/script/ReviewsTest.php" method="POST"
result="handleMenu(event)"
>
<s:request xmlns="" >
<voorwerp>{TextTI.text}</voorwerp>
</s:request>
</s:HTTPService>
</fx:Declarations>
<mx:VBox x="14" y="60" width="744" height="450">
<mx:Repeater id="DescrBooks" maxWidth="450">
<mx:HBox>
<mx:Text text="{ShowBooks(DescrBooks.currentItem)}" maxWidth="450" />
</mx:HBox>
</mx:Repeater>
</mx:VBox>
<s:Button x="14" y="25" label="Button" click="Start()"/>
<s:TextInput x="92" y="25" id="TextTI"/>
</s:Application>
My php script:
<?php
header("Content-type: text/xml");
header("Expires: Mon, 26 Jul 1990 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// cache wordt uitgeschakeld om zeker te zijn dat de gegevens uit de API gelezen worden en niet uit de cache van de webbrowser
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
//alle gegevens om connectie te leggen naar de databank
$host = "mysql.imd2012.dreamhosters.com";
$user = "*********";
$pass = "*********";
$database = "gertjanvanhove2012";
//connectie leggen naar de databank
$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");
//gegevens gaan halen uit de databank
if(!isset($_GET['voorwerp'])){
$query = "SELECT * FROM RMA_Review ";
}
else{
$_GET['voorwerp'] = $tit;
$query = "SELECT * FROM RMA_Review where Title='".$tit."'";
}
$menu_result = mysql_query($query, $linkID) or die("Data not found.");
//starten met de opbouw van de string die de XML code bevat
$xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
";
$xml_output .= "<menu>
";
//voor elk menu item de nodige gegevens neerschrijven
for($x = 0 ; $x < mysql_num_rows($menu_result) ; $x++){
$itemrow = mysql_fetch_assoc($menu_result);
$xml_output .= "\t<menuitem>
";
$xml_output .= "\t\t<itemID>" . $itemrow['ReviewId'] . "</itemID>
";
$xml_output .= "\t\t<itemLabel>" . $itemrow['Title'] . "</itemLabel>
";
$xml_output .= "\t\t<itemDesc>" . $itemrow['Review'] . "</itemDesc>
";
$xml_output .= "\t\t<itemAutheur>" . $itemrow['Autheur'] . "</itemAutheur>
";
$xml_output .= "\t</menuitem>
";
}
$xml_output .= "</menu>
";
//de volledige XML string in de response echo'n
echo $xml_output;?>
the table RMA_Reviews looks like this: (cant post a screenshot because i dont have enough rep)
http://oi39.tinypic.com/2cxtez5.jpg
So My question is: how can I only show the values of the Books that u typed in the textfield.