RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-204193

lounah's questions

Martin Hope
lounah
Asked: 2020-07-14 22:25:19 +0000 UTC

单击按钮时动态添加 html 元素

  • 0

你好。有一个简单的 html 表单。单击“提交”按钮时,我想在此表单中添加另一个“聊天自我”元素。我怎样才能做到这一点?我刚开始研究这个。如果有任何链接,我将不胜感激。

<!DOCTYPE html>
<html>
<head>
	<title>ПростоЧат</title>
	<link rel="stylesheet" type="text/css" href="style.css">
	<meta charset="utf-8">
</head>

<body>

	<div class="chatWindow">
		<div class="chatLog">
		
			<div class="chat friend">
				<p class="message-time">11:42</p>
				<p class="name">#1</p>
				<p class="chat-message">Сообщение #1</p>
			</div>
			
			<div class="chat self">
				<p class="message-time">11:43</p>
				<p class="name">#2</p>
				<p class="chat-message">Сообщение #2</p>
			</div>
			
			<div class="chat friend">
				<p class="message-time">11:45</p>
				<p class="name">#1</p>
				<p class="chat-message">Сообщение #3</p>
			</div>
			
			<div class="chat self">
				<p class="message-time">11:47</p>
				<p class="name">#2</p>
				<p class="chat-message">Сообщение #4</p>
			</div>
			

		</div>
		
		<div class="chat-form">
			<textarea></textarea>
			<button>Отправить</button>
		</div>
		
	</div>

</body>

</html>

javascript
  • 2 个回答
  • 10 Views
Martin Hope
lounah
Asked: 2020-02-08 22:41:52 +0000 UTC

为一个简单的程序编写测试计划

  • 1

你好。该程序以三角形的三个边作为输入,并根据它们确定该三角形的类型。编写测试计划

тестирование
  • 1 个回答
  • 10 Views
Martin Hope
lounah
Asked: 2020-01-07 19:02:23 +0000 UTC

PHP,解析JSON

  • 0

你好

我有看起来像这样的 JSON:

{
"response": {
"count": 10,
"items": [{...}, {...}, {...}, {...}]
}
}

items数组的每个元素包含或不包含copy_history数组。 通常,items 数组如下所示:

"items": [{
"id": 111,
"from_id": -119473366,
"owner_id": -119473366,
"date": 1483779506,
"marked_as_ads": 0,
"post_type": "post",
"text": "",
"copy_history": [{
"id": 30679,
"owner_id": -96126130,
"from_id": -96126130,
"date": 1483772560,
"post_type": "post",
"text": "",
"attachments": [{
"type": "photo",
"photo": {
"id": 456240780,
"album_id": -7,
"owner_id": -96126130,
"user_id": 100,
"photo_75": "https://pp.vk.me/...a3e/0zDlnwXV97M.jpg",
"photo_130": "https://pp.vk.me/...a3f/is7lDvyh3JE.jpg",
"photo_604": "https://pp.vk.me/...a40/Z6vXcOY-cf4.jpg",
"photo_807": "https://pp.vk.me/...a41/g9QedfvZoZg.jpg",
"width": 640,
"height": 521,
"text": "",
"date": 1483140936,
"post_id": 29964,
"access_key": ""
}
}]

有必要遍历每个 items 元素,从中获取 id 字段的值,并找出它是否包含copy_history数组。

请帮帮我。提前致谢

php
  • 1 个回答
  • 10 Views
Martin Hope
lounah
Asked: 2020-01-07 17:31:28 +0000 UTC

PHP,从JSON中获取数组元素的数量

  • 0

你好。我有这样的 JSON:

{
"response":{
"count":10,
"items":[],
"profiles":[],
"groups":[]
}
}

如何从中获取组中包含的元素个数?

php
  • 1 个回答
  • 10 Views
Martin Hope
lounah
Asked: 2020-12-24 22:56:41 +0000 UTC

安卓、服务、屏幕解锁检测

  • 1

你好!我正在编写一个应用程序来检测设备上的屏幕解锁。屏幕一解锁,应用程序就会向服务器发送一个信号。那么,如何检测屏幕解锁呢?

android
  • 1 个回答
  • 10 Views
Martin Hope
lounah
Asked: 2020-11-25 23:17:33 +0000 UTC

Json.简单解析数组

  • 1

你好。

我从服务器得到一个 json 响应,如下所示:

[{"password":"xxxxxxx"}]

如何使用 json simple 获取 'a 的值password?

java
  • 1 个回答
  • 10 Views
Martin Hope
lounah
Asked: 2020-10-23 17:44:18 +0000 UTC

一个 ListView 的不同布局

  • 0

你好。有一个聊天活动,其中包含ListView消息。对于ListViewitem'a,有两种样式:左侧的消息(来自对话者),右侧的消息(您的)。

有一段代码,在给定的 URI 处,从服务器接收 JSON,它被解析为消息,然后解析为ListView项目。

JSON 看起来像这样:author:"author",reciever:"reciever",time:"time",content:"content"

所以,我需要根据谁拥有消息,它在ListView. 那些。如果我们收到消息,则ListViewitem'a 的样式在左侧,如果我们发送消息,则在右侧。(与所有使者一样)。

private class ListViewLoaderTask extends AsyncTask<String, Void, SimpleAdapter> {

    JSONObject jObject;

    @Override
    protected SimpleAdapter doInBackground(String... strJson) {
        try {
            jObject = new JSONObject(strJson[0]);
            parse(jObject);
        } catch (Exception e) {
            Log.d("JSON Exception1", e.toString());
        }


        List<HashMap<String, Object>> messages = null;

        try {
            messages = parse(jObject);
        } catch (Exception e) {
            Log.d("Exception", e.toString());
        }

        String[] from = {"content", "time", "author"};
        int[] to = {R.id.contentMSG, R.id.timeMSG, R.id.usernameMSG};

        /*
            Вот здесь нужно исходя из того, кто автор сообщения,
            выбрать layout

         */
        SimpleAdapter adapter = new SimpleAdapter(getBaseContext(), messages, R.layout.one_msg_item, from, to);
        adapter.notifyDataSetChanged();

        return adapter;
    }


}


public List<HashMap<String, Object>> parse(JSONObject jObject) {

    JSONArray jMessages = null;
    try {
        jMessages = jObject.getJSONArray("Messages");
    } catch (JSONException | NullPointerException e) {
        e.printStackTrace();
    }

    return getMessages(jMessages);
}

private List<HashMap<String, Object>> getMessages(JSONArray jMessages) {
    List<HashMap<String, Object>> messagesList = new ArrayList<HashMap<String, Object>>();
    HashMap<String, Object> message = null;

    for (int i = 0; i < jMessages.length(); i++) {
        try {
            message = getMessage((JSONObject) jMessages.get(i));
            messagesList.add(message);

        } catch (JSONException | NullPointerException e) {
            e.printStackTrace();
        }
    }
    return messagesList;
}


private HashMap<String, Object> getMessage(JSONObject jMessage) {
    HashMap<String, Object> message = new HashMap<String, Object>();
    String author = "";
    String client = "";
    String time = "";
    String content = "";
    try {
        author = jMessage.getString("author");
        client = jMessage.getString("client");
        time = jMessage.getString("time");
        content = jMessage.getString("content");

        message.put("author", author);
        message.put("client", client);
        message.put("time", time);
        message.put("content", content);

    } catch (JSONException e) {
        e.printStackTrace();
    }
    return message;
}
android
  • 1 个回答
  • 10 Views
Martin Hope
lounah
Asked: 2020-10-11 16:08:57 +0000 UTC

用于 mysql 民意调查的数据库

  • 0

你好。有必要为轮询系统实现一个数据库。应该有以下列:民意调查 ID、民意调查名称、民意调查答案选项、投票给这个或那个答案选项的人数。如何实施?我会很感激一个想法

mysql
  • 1 个回答
  • 10 Views
Martin Hope
lounah
Asked: 2020-09-07 03:11:50 +0000 UTC

Java,ArrayIndexOutOfBoundsException:3

  • 2

你好。需要实现矩阵乘法,代码如下:

public class MatrixMultiplier {

    private  int[][] transportMatrix(int[][] a) {
        int[][] b = new int[a.length][a.length];
        for (int i = 0; i < a.length; ++i)
            for (int j = 0; j < a.length; ++j) {
                b[i][j] = a[j][i];
            }
        return b;
    }

    public int[][] multiply(int[][] mA, int[][] mB) {
        int mSize = mA.length;
        mB = transportMatrix(mB);
        int nSize = mB[0].length;
        int o = mB.length;
        int[][] mResult = new int[mSize][nSize];

        for (int i = 0; i < mSize; i++) {
            for (int j = 0; j < nSize; j++) {
                for (int k = 0; k < o; k++) {
                    System.out.print(i + " " + j);
                    mResult[i][j] += mA[i][k] * mB[k][j];
                }
            }
        }

        for (int i = 0; i < mResult.length; i++) {
            for (int j = 0; j < mResult[0].length; j++) {
                System.out.format("%6d ", mResult[i][j]);
            }
            System.out.println();
        }

        return mResult;
    }
}

public class MatrixMultiply {

    private static int[][] mA;
    private static int[][] mB;
    private static int[][] mResult;

    public static void main(String[] args) {
        MatrixMultiplier matrixMultiplier = new MatrixMultiplier();
         mA = new int[][] {{5,3,2},
                          {3,1,0},
                          {1,4,1},
                          {8,2,1}};

         mB = new int[][] {{5,6,2},
                          {3,1,0},
                          {1,4,1},
                          {8,2,1},
                          {3,1,1}};

        mResult = new int[mA.length][mB[0].length];
        mResult = matrixMultiplier.multiply(mA, mB);
    }

}

结果异常:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at matrix.MatrixMultiplier.transportMatrix(MatrixMultiplier.java:8)
at matrix.MatrixMultiplier.multiply(MatrixMultiplier.java:15)
at matrix.MatrixMultiply.main(MatrixMultiply.java:23)

为什么?

java
  • 1 个回答
  • 10 Views
Martin Hope
lounah
Asked: 2020-08-23 15:28:23 +0000 UTC

获取最新记录的 SQL 查询

  • 3

我有一个messages看起来像这样的表:_id (prim key), author, client, time, content.

让它具有以下值:

 _id | author | client | time  | content
--------------------------------------
   1 |  user  |  you   | 21:52 | hi   
   2 |  user  |  you   | 20:43 | wassup   
   3 |  user2 |  you   | 17:45 | привет   
   4 |  user2 |  you   | 18:20 | :(   

从这个表中,您需要从每个作者那里得到一条(最后一条)消息,其中client = you.

那些。查询应返回 ID 为 1 和 4(hi和:()的消息。我怎样才能做到这一点?

mysql
  • 2 个回答
  • 10 Views
Martin Hope
lounah
Asked: 2020-08-22 02:43:00 +0000 UTC

MySQL数据库存储优化

  • 2

你好。MySQL 中有一张表,用于存储用户消息。(_id, from_id, to_id, 日期, 内容 ) 来自所有通信的所有消息都将存储在该表中。我明白这是完全不合理和错误的,因为从服务器下载信件是通过一个简单的 SELECT by from_id 并按日期排序来实现的。那么,如何合理地建表存储用户对应关系,使得数据库查询不至于消息量过大而过长呢?

mysql
  • 1 个回答
  • 10 Views
Martin Hope
lounah
Asked: 2020-07-30 00:49:49 +0000 UTC

响应代码

  • 1

你好。我正在为 Android 上一个非常简单的客户端-服务器应用程序编写用户授权测试模型。实现如下:用户在设备上输入登录名和密码 -> 它们被发送到服务器,在服务器上使用 mysql select'a 搜索登录名和密码。如果mysql_num_rows() = 0(没有用户使用这样的登录名和密码),我调用http_response_code(401)方法。 该响应代码由应用程序使用connection.getResponseCode()方法接收

所以,问题是:每次,无论登录名和密码是否正确,connection.getResponseCode() 都会返回 200。

可能是什么问题或我做错了什么?这是代码(提前对它的糟糕表示歉意)

<?php

$mysql_host = "localhost";
$mysql_user = "db";
$mysql_password = "db";
$mysql_database = "db";

mysql_connect($mysql_host, $mysql_user, $mysql_password);
mysql_select_db($mysql_database);
mysql_set_charset('utf8');

if (isset($_GET["action"])) {
    $action = $_GET['action'];
}

if (isset($_GET["username"])) {
    $username = $_GET['username'];
}

if (isset($_GET["password"])) {
    $password = $_GET['password'];
}

if ($action == authentication) {
    $query = "SELECT username, password FROM users WHERE username='$username' AND password='$password'";
    $result = mysql_query($query);
    $rows = mysql_num_rows($result);
    if ($rows = 0) {
        http_response_code(401);
        exit;
    }
}

?>
php
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5