2014-06-30 03:56
浏览 43


I have currently a php script as given below:

if (mysqli_connect_errno($con)) 
    echo "Failed to connect to MySQL: " . mysqli_connect_error(); 
$username = mysqli_real_escape_string($con, $_POST['username']); 
$result = mysqli_query($con,"SELECT imagename FROM table3 where username='$username'");

$rows = array();
while($r = mysqli_fetch_assoc($result)) 
    $rows[] = $r;
echo json_encode($rows);


The output which I get after running this script is in the form given below:


But I need a string in a format like this as my output:


That is, I should be able to add the string {"Android": to the beginning of my actual output and add the string } to the ending part of my actual output.

So what code should I need to add extra to obtain like the above format. Can someone please help me out.. Thanks in advance..

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题