-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-data.php
49 lines (42 loc) · 1.49 KB
/
get-data.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
$link = mysql_connect('localhost', 'highvoltage', 'ZasadaKTV3350');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("sashabase") or die("cannot connect to the database" . mysql_error());
$data = mysql_query("SELECT id, date, user, heading, content, pic FROM news ORDER BY news.id DESC") or die(mysql_error());
$info = mysql_fetch_array( $data );
$infoarray = array('id','date','user','heading','content','pic');
$totalarray = array('');
$infoarray[0] = $info['id'];
$infoarray[1] = $info['date'];
$infoarray[2] = $info['user'];
$infoarray[3] = $info['heading'];
$infoarray[4] = $info['content'];
$infoarray[5] = $info['pic'];
array_push($totalarray,$infoarray[0]);
array_push($totalarray,$infoarray[1]);
array_push($totalarray,$infoarray[2]);
array_push($totalarray,$infoarray[3]);
array_push($totalarray,$infoarray[4]);
array_push($totalarray,$infoarray[5]);
while ($info = mysql_fetch_array( $data ))
{
foreach ($infoarray as $i => $value) {
unset($infoarray[$i]);}
$infoarray[0] = $info['id'];
$infoarray[1] = $info['date'];
$infoarray[2] = $info['user'];
$infoarray[3] = $info['heading'];
$infoarray[4] = $info['content'];
$infoarray[5] = $info['pic'];
array_push($totalarray,$infoarray[0]);
array_push($totalarray,$infoarray[1]);
array_push($totalarray,$infoarray[2]);
array_push($totalarray,$infoarray[3]);
array_push($totalarray,$infoarray[4]);
array_push($totalarray,$infoarray[5]);
}
echo json_encode($totalarray);
mysql_close($link);
?>