質問編集履歴
1
コードの変数を編集しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
include_once("functions.php");
|
25
25
|
|
26
26
|
$userid = $_SESSION['userid'];
|
27
|
-
$body = substr($_POST['
|
27
|
+
$body = substr($_POST['content'],0,140);
|
28
28
|
|
29
29
|
add_post($userid,$body);
|
30
30
|
$_SESSION['message'] = "Your post has been added!";
|
@@ -38,7 +38,7 @@
|
|
38
38
|
unset($_SESSION['message']);
|
39
39
|
}
|
40
40
|
?>
|
41
|
-
<form method='post' action='
|
41
|
+
<form method='post' action='index.php'>
|
42
42
|
<p>Your status:</p>
|
43
43
|
<textarea name='body' rows='5' cols='40' wrap=VIRTUAL></textarea>
|
44
44
|
<p><input type='submit' value='submit'/></p>
|
@@ -75,8 +75,8 @@
|
|
75
75
|
function.php
|
76
76
|
<?php
|
77
77
|
function add_post($userid,$body){
|
78
|
-
$sql = "insert into posts (
|
78
|
+
$sql = "insert into posts (content,created)
|
79
|
-
values ($
|
79
|
+
values ($content,now());
|
80
80
|
|
81
81
|
$result = mysql_query($sql);
|
82
82
|
}
|
@@ -84,15 +84,12 @@
|
|
84
84
|
function show_posts($userid){
|
85
85
|
$posts = array();
|
86
86
|
|
87
|
-
$sql = "select
|
87
|
+
$sql = "select content,created from posts
|
88
|
-
where
|
88
|
+
where id = '$content' order by created desc";
|
89
89
|
$result = mysql_query($sql);
|
90
90
|
|
91
91
|
while($data = mysql_fetch_object($result)){
|
92
|
-
$posts[] = array( '
|
92
|
+
$posts[] = array( 'content' => $cntent);
|
93
|
-
'userid' => $userid,
|
94
|
-
'body' => $data->body
|
95
|
-
);
|
96
93
|
}
|
97
94
|
return $posts;
|
98
95
|
|