Jump to content

jijimj73

New Members
  • Posts

    1
  • Joined

  • Last visited

jijimj73's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am newbie as far as PHP is concerned. But I am thrilled. Could anyone tell me what's wrong with this code? Sometimes it shows errors. <?php if (isset($_GET['id'])) { $id = $_GET['id']; $curPageName = $curPageName. '-' .$id; } $sql = "SELECT counts FROM visitor_counter WHERE page_name = '$curPageName'"; $result = mysqli_query($conn, $sql); $page_count = 0; if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $page_count = $page_count + 1; $visits = $row["counts"] + 1; } } if ($page_count < 1) { $sql = "INSERT INTO visitor_counter (page_name, counts) VALUES ('" .$curPageName. "', '1')"; if ($conn->query($sql) === TRUE) { $visits = "1"; } else { echo ""; } }else{ $sql = "UPDATE visitor_counter SET counts = '$visits' WHERE page_name = '$curPageName'"; $result = mysqli_query($conn, $sql); } echo $visits. " hits"; ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.