Not sure if this should be in the MySQL section but here goes,

I basically need some sort of code which can read events from a database, display them on a webpage, and the ability to edit and add new events.
Please do not suggest any sort of calendar as this is not what im looking for, i basically want an admin page to be able to add a new event, and then that to be shown in another page.

I just need pointing in the right direction really, and have tried searching but only seem to come up with calendars.
I was maybe thinking of the PHP read / write function, but not sure how to implement this or what would be the best way.

Thanks,
Adam

Dani AI

Generated

A practical follow-up to this thread: as pointed out, an AJAX-based CRUD interface is a good fit for an admin page. A simple, maintainable architecture is: one MySQL events table, a small PHP admin area that exposes create/read/update/delete actions (returning JSON for AJAX), and a public page that queries only published events and renders them. Keep validation and access control on the server; use client-side JS only for UX.

Example schema (minimal, index the date column):

CREATE TABLE events (
  id INT AUTO_INCREMENT PRIMARY KEY,
  title VARCHAR(255) NOT NULL,
  description TEXT,
  start_dt DATETIME,
  end_dt DATETIME,
  location VARCHAR(255),
  is_published TINYINT(1) DEFAULT 1,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  INDEX (start_dt)
);

Minimal PHP pattern (PDO + prepared statements):

<?php
$pdo = new PDO('mysql:host=localhost;dbname=app;charset=utf8mb4','user','pass',[
  PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]);
$stmt = $pdo->prepare('INSERT INTO events (title,description,start_dt,end_dt,is_published) VALUES (:title,:desc,:s,:e,:p)');
$stmt->execute([':title'=>$_POST['title'],':desc'=>$_POST['description'],':s'=>$_POST['start_dt'],':e'=>$_POST['end_dt'],':p'=>isset($_POST['publish'])?1:0]);

Important notes and troubleshooting:

  • Store datetimes in UTC and convert for display.
  • Always use prepared statements and escape output with htmlspecialchars(..., ENT_QUOTES, 'UTF-8') to prevent SQLi/XSS.
  • Protect admin pages with authentication and CSRF tokens; validate and sanitize any HTML input (use a whitelist sanitizer).
  • If events don’t appear, check is_published, timezone mismatches, and the ORDER BY start_dt/LIMIT logic.
  • Add pagination, an index on date columns, simple caching for the public view, and regular DB backups. For recurring events, model recurrences separately (one table or rrule storage) rather than embedding recurrence logic in the main row.

This gives a clean, low-maintenance solution that delivers the admin workflow mentioned by without turning the app into a full calendar system.

Recommended Answers

All 2 Replies

I guess you want something like this ?

I guess you want something like this ?

That is perfect, exactly what i wanted!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.