从mysql查询中读取PHP数组作为c#中的字符串
I have a PHP file and a C# app. In the php file it returns a Array of the rows that i selected from a mysql table. I want to read that Array and deserialize it so the result of a row can be parsed inside a textBlock. My PHP script:
<?php
mysql_connect("-----", "------", "-----") or
die("Could not connect: " . mysql_error());
mysql_select_db("------");
$list = array();
$query = "SELECT SongName,ArtistName,Thumbnail,MediaLink FROM Library";
$resource = mysql_query($query);
while($row = mysql_fetch_assoc($resource))
{
$list['SongName' . (1 + count($list))] = $row['SongName'];
}
$list = array('row' => count($list)) + $list;
echo json_encode(array($list));
?>
How do i get the ArtistName, Thumbnail and medialink inside the array? How do i read this in C# so my textblock will show: ArtistName. Technologies: Windows 10 Store apps(C#, XAML)
If somebody could help that'd be great,
Christos K
我有一个PHP文件和一个C#应用程序。 在php文件中它返回一个行数组 从mysql表中选择。 我想读取该数组并对其进行反序列化,以便可以在textBlock中解析行的结果。 我的PHP脚本: p>
&lt; ?php
mysql_connect(“-----”,“------”,“-----”)或
die(“无法连接:”。mysql_error());
mysql_select_db( “------”);
$ list = array();
$ query =“SELECT SongName,ArtistName,Thumbnail,MediaLink FROM Library”;
$ resource = mysql_query($ query);
while($ row = mysql_fetch_assoc($ resource))
{
$ list ['SongName'。 (1 + count($ list))] = $ row ['SongName'];
}
$ list = array('row'=&gt; count($ list))+ $ list;
echo json_encode(array ($列表));吗?
&GT;
code> pre>
如何在数组中获取ArtistName,Thumbnail和medialink?
如何在C#中阅读此内容,以便我的文本块显示:ArtistName。
技术:
Windows 10商店应用程序(C#,XAML) p>
如果有人可以提供帮助,那就很好了, p>
Christos K p>
DIV>
Simple, you pull all the required data from the database and return it as an array, just put the whole $row into the array you are about to return
<?php
mysql_connect("-----", "------", "-----") or
die("Could not connect: " . mysql_error());
mysql_select_db("------");
$list = array();
$query = "SELECT SongName,ArtistName,Thumbnail,MediaLink FROM Library";
$resource = mysql_query($query);
while($row = mysql_fetch_assoc($resource))
{
$list[] = $row;
}
echo json_encode($list);
?>
Now you should receive all the data you want in the javascript. Just use the javascript debugger to see what it looks like