-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path12.2.db_con.php
49 lines (45 loc) · 1.72 KB
/
12.2.db_con.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
<?php
$host = 'localhost';
$user = 'testsite_vz';
$password = 'testsite_vz';
$database = 'testsite_vz';
$con = mysqli_connect($host, $user, $password, $database);
mysqli_set_charset($con, 'utf8');
if(mysqli_errno($con)){
echo 'Failed connect ' . mysqli_errno($con);
}// else {echo 'oke';}
//
//
//$query = "INSERT INTO news_category(name, description, sort_order) VALUES ('name4', 'desc4', 'sort4'),('name5', 'desc5', 'sort5')";
//$query = "DELETE FROM news_category WHERE id=11";
//$sql = "DELETE FROM news WHERE date > DATE_SUB(CURDATE(), INTERVAL 1 HOUR)";
//$sql = "DELETE FROM news ORDER BY date LIMIT 1"; // удалить одну первую с начала строку
//$sql = "DELETE FROM news ORDER BY date DESC LIMIT 1"; // удалить одну строку c конца
//$sql = "UPDATE news SET status='1' WHERE id='7'"; // удалить одну строку c конца
//
//$sql = "SELECT * FROM news";
//$sql = "SELECT MAX(id) AS count FROM news";
//$sql = "SELECT SUM(id) AS sum FROM news";
$sql = "SELECT *, COUNT(*) AS count FROM news GROUP BY short_content";
$result = mysqli_query($con,$sql);
$count = mysqli_num_rows($result); // узнать количество полученных строк
//
//
if($count){
while ($row = mysqli_fetch_array($result)) {
echo $row['h1'].'-';
echo $row['count'].'<br>';
//echo $row['sum'];
}
}
//$row1 = mysqli_fetch_array($result); // полученные даные преобразовать в массив
//echo '<pre>';
//print_r($row1);
//echo '</pre>';
//echo '<br> mysqli_affected_rows: '. mysqli_affected_rows($con);
//echo '<br> mysqli_num_rows: '.$count;
//
//
//echo '<pre>';
//print_r($result);
//echo '</pre>';