php
방문 카운터
장곰부대
2018. 3. 27. 13:01
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <?php $mysqli = new mysqli('localhost:3307','phpuser','1234','phpuser_db'); if ($mysqli->connect_errno) { die("Failed to connect to MySQL: (" .$mysqli->connect_errno.") ".$mysqli_error); } if(!$result = $mysqli->query("select count from counter")){ if(!$mysqli->query("create table counter (count int)")|| !$mysqli->query("insert into counter value (0)")){ die("Table creation failed : (". $mysqli_errno.") ".$mysqli_error); } } $mysqli->query("update counter set count=count+1"); $result = $mysqli->query("select count from counter"); $row = $result->fetch_row(); echo "방문횟수 : ".$row[0]; $result->free(); $mysqli->close(); ?> | cs |