如何在观看消息旁边创建收件箱(how to creae inbox next to viewing message)
我刚刚创建了一个消息系统,但我想显示正在查看的消息旁边的收件箱,如facebook消息系统,但我可以让它在彼此旁边工作,我必须通过链接这样做,所以收件箱被查看index.php并查看你必须去的信息index.php?hash = VAULE我如何让他们并排工作,因为facebook确实如此
<?php if(isset($_GET['hash']) && !empty($_GET['hash'])){ $hash = $_GET['hash']; $message_query= mysql_query("SELECT from_id, message FROM messages WHERE group_hash='$hash'"); while($run_message = mysql_fetch_array($message_query)){ $from_id = $run_message['from_id']; $message = $run_message['message']; $staff_query = mysql_query("SELECT staff_username FROM staff_users WHERE id='$from_id'"); $run_staff = mysql_fetch_array($staff_query); $from_staff = $run_staff['staff_username']; echo "<p><b>$from_staff</b><br/>$message</p>"; } ?> <br/> <form method='POST'> <?php if(isset($_POST['message']) && !empty($_POST['message'])){ $new_message = $_POST['message']; mysql_query("INSERT INTO messages VALUES('','$hash','$my_id','$new_message')"); header('location: index.php?hash='.$hash); } ?> <div class="message_box"> Enter Message : <br/> <textarea name='message' placeholder="Write a reply" rows='6' cols="60"></textarea> <br/> <input type='submit' name="smb" value="Reply"/> </form> </div> <?php }else{ $get_con = mysql_query("SELECT hash, staff_one, staff_two FROM messages_hash WHERE staff_one='$my_id' OR staff_two='$my_id'"); while($run_con = mysql_fetch_array($get_con)){ $hash = $run_con['hash']; $staff_one = $run_con['staff_one']; $staff_two = $run_con['staff_two']; if($staff_one == $my_id){ $select_id = $staff_two; }else{ $select_id = $staff_one; } $staff_get = mysql_query("SELECT staff_username FROM staff_users WHERE id='$select_id'"); $run_staff = mysql_fetch_array($staff_get); $select_staff = $run_staff['staff_username']; echo "<p><a href='index.php?hash=$hash'>$select_staff</a></p>"; } } ?>
i have just created a message system but i would like to show the inbox next to the message being viewed like facebook messaging system does but i can get it to work next to each other i have to do it though links so the inbox is viewed on index.php and to view message you have to go to index.php?hash=VAULE how do i get them to work side by side as facebook does
<?php if(isset($_GET['hash']) && !empty($_GET['hash'])){ $hash = $_GET['hash']; $message_query= mysql_query("SELECT from_id, message FROM messages WHERE group_hash='$hash'"); while($run_message = mysql_fetch_array($message_query)){ $from_id = $run_message['from_id']; $message = $run_message['message']; $staff_query = mysql_query("SELECT staff_username FROM staff_users WHERE id='$from_id'"); $run_staff = mysql_fetch_array($staff_query); $from_staff = $run_staff['staff_username']; echo "<p><b>$from_staff</b><br/>$message</p>"; } ?> <br/> <form method='POST'> <?php if(isset($_POST['message']) && !empty($_POST['message'])){ $new_message = $_POST['message']; mysql_query("INSERT INTO messages VALUES('','$hash','$my_id','$new_message')"); header('location: index.php?hash='.$hash); } ?> <div class="message_box"> Enter Message : <br/> <textarea name='message' placeholder="Write a reply" rows='6' cols="60"></textarea> <br/> <input type='submit' name="smb" value="Reply"/> </form> </div> <?php }else{ $get_con = mysql_query("SELECT hash, staff_one, staff_two FROM messages_hash WHERE staff_one='$my_id' OR staff_two='$my_id'"); while($run_con = mysql_fetch_array($get_con)){ $hash = $run_con['hash']; $staff_one = $run_con['staff_one']; $staff_two = $run_con['staff_two']; if($staff_one == $my_id){ $select_id = $staff_two; }else{ $select_id = $staff_one; } $staff_get = mysql_query("SELECT staff_username FROM staff_users WHERE id='$select_id'"); $run_staff = mysql_fetch_array($staff_get); $select_staff = $run_staff['staff_username']; echo "<p><a href='index.php?hash=$hash'>$select_staff</a></p>"; } } ?>
原文:https://stackoverflow.com/questions/29457474
更新时间:2023-07-08 06:07
最满意答案
@Override public void delete(List<Integer> ids) { String sql = "update user set deleted=1 where user_id = ?"; jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { Integer userId = ids.get(i); ps.setLong(1, userId ); } @Override public int getBatchSize() { return ids.size(); } }); }
@Override public void delete(List<Integer> ids) { String sql = "update user set deleted=1 where user_id = ?"; jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { Integer userId = ids.get(i); ps.setLong(1, userId ); } @Override public int getBatchSize() { return ids.size(); } }); }
相关问答
更多-
spring jdbcTemplate 中的batchUpdate 返回结果[2023-06-29]
文档中说的是结果由特定的JDBC实现来完成, 每种数据库以及每个版本的JDBC都不尽相同, 参考一下你使用JDBC的文档, 官方的解答是最准确的. -
MERGE JDBCTemplate问题(MERGE JDBCTemplate issue)[2022-04-18]
正确的语法使用: MERGE INTO people AS t USING ( VALUES (5, 'Chuck', 'Norris'), (6, 'John', 'Smith'), (7, 'Abraham', 'Lincoln') -- maybe more rows ) AS s (id, name, surname) ON t.id = s.id WHEN ... -
使用ORACLE合并jdbc模板batchupdate插入重复项(Using ORACLE merge with jdbc template batchupdate inserting duplicates)[2022-05-24]
多个会话将执行此操作,也就是说,如果您没有适当的约束条件。 例 Session 1 SQL> create table t ( x int ); Table created. SQL> SQL> declare 2 incoming_value int := 1; 3 begin 4 MERGE INTO t USING dual ON (x = incoming_value ) 5 WHEN NOT MATCHED THEN INSERT (x) 6 ... -
@Override public void delete(List
ids) { String sql = "update user set deleted=1 where user_id = ?"; jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() { @Override public void setValues(Prep ... -
问题是我使用了jdbcTemplate.batchUpdate ,它以一种非常奇怪的方式工作。 我设置了rewriteBatchedStatements=true 。 第一次运行真的执行这样的声明 insert into TEMP1 (xxx,yyy) values(?,?),(?,?),(?,?),(?,?); 由于未知原因的下一个语句逐个执行语句 insert into TEMP1 (xxx,yyy) values(?,?); insert into TEMP1 (xxx,yyy) values(?, ...
-
通过jdbctemplate.batchupdate从sql批量插入获取标识(get Identity from sql batch insert via jdbctemplate.batchupdate)[2023-03-05]
没有,可能是因为JDBC规范不要求getGeneratedKeys与executeBatch() ,如此处所述。 如果您的驱动程序支持它,则需要使用普通的旧JDBC来访问结果集。 代码会是这样的: PreparedStatement ps = conn.prepareStatement("insert into ... values (?)", Statement.RETURN_GENERATED_KEYS); ps.setXXX(1, value1); ps.addBatch(); ps.setXXX(1 ... -
jdbcTemplate.batchUpdate用于插入列表不起作用(jdbcTemplate.batchUpdate for list of inserts doesn't work)[2022-03-31]
使用下面的catch块来检查异常 int[] updateCounts; try { updateCounts = getJdbcTemplate().batchUpdate("insert into test123 (id, value) values (?,?)", new BatchPreparedStatementSetter() { //// YOUR CODE HERE ... -
jdbcTemplate.batchUpdate()的大问题列表问题(Issue with jdbcTemplate.batchUpdate() for large list of queries)[2022-01-27]
感谢您的回复。 我遇到了这个问题。 这是非常愚蠢的编码,没有正确记录。 batchUpdate是在try块下调用的,在catch中它没有记录到logger而是系统控制台。 执行抛出异常,因为其中一个查询格式不正确。 Thanks for your reply. I got the issue. It was very silly coding which was not logged properly. The batchUpdate was called under a try block and in ... -
使用@Transactional注释来指定超时。 @org.springframework.transaction.annotation.Transactional(timeout = 123) // 123 sec 这是参考文件。 Use @Transactional annotation to specify the timeout. @org.springframework.transaction.annotation.Transactional(timeout = 123) // 123 sec ...
-
默认情况下使用回滚测试jdbcTemplate.batchUpdate(Test jdbcTemplate.batchUpdate with rollback by default)[2023-08-26]
我很抱歉误导你们所有人。 该问题不是由嵌套事务引起的。 这个问题是我对Java中与事务相关的类的层次结构完全误解以及如何实现JDBC中的批处理语句的结果。 测试失败,因为后续调用 myDao.findAllAliasedItems() 被缓存了。 Spring JDBC模板运行得很好,正如人们所期望的那样。 I'm sorry for misleading you all. The issue was not caused by nested transaction. This question is a ...