Basically, I've got a database of values such as stadiumID, stadiumName, stadiumImage, matchDescription and matchDate. I have created a CMS and I can view a record in the database on my details.php however, on my edit.php and delete.php the page is blank when opened. The code below shows my delete.php and below that the working details.php. I was hopeing someone could give me a hand as I've spent hours trying and can't figure it out. Happy to give more details. Thanks Josh.
<?php
ini_set('display_errors', 1);
// add your includes for connections and functions
require('../../conn.inc.php');
require('../includes/functions.inc.php');
// make sure the path is correct
$sstadiumID = safeInt($_GET['stadiumID']);
$sql= "SELECT * FROM events WHERE stadiumID LIKE :stadiumID";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':stadiumID', $sstadiumID, PDO::PARAM_INT);
$stmt->execute();
$row = $stmt->fetchObject();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Edit <?php echo $row->stadiumName; ?></title>
<link href="../css/bootstrap.min.css" rel="stylesheet">
<link href="../css/styles.css" rel="stylesheet">
</head>
<body>
<div class="container">
<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li><a href="cms.php">CMS Home</a></li>
</ul>
<p class="nav navbar-nav navbar-right">
<a class="btn btn-danger navbar-btn" href="../cmsIndex.php" role="button">Log Out</a>
</p>
</div>
</nav>
<div class="page-header">
<h1>Edit <?php echo $row->stadiumName; ?></h1>
</div>
<div class="row">
<div class="col-md-12 form-group">
<p>
Are you sure you wish to delete <?php echo $row->stadiumName; ?>?
</p>
<form name="form1" method="post" action="process/deleteRecord.php" class="form-inline">
<!-- Add the stadiumID as a hidden field -->
<input name="stadiumID" type="hidden" value="<?php echo $row->stadiumID; ?>">
<input type="submit" value="Delete" class="btn btn-danger">
<a href="cms.php" class="btn btn-success">Save</a>
</form>
</div>
</div>
</div>
<footer>
<div class="container">
</div>
</footer>
</body>
</html>
<?php
ini_set('display_errors', 1);
// add your include
require('../conn.inc.php');
require('includes/functions.inc.php');
$sstadiumID = safeInt($_GET['stadiumID']);
$sql= "SELECT * FROM events WHERE stadiumID LIKE :stadiumID";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':stadiumID', $sstadiumID, PDO::PARAM_INT);
$stmt->execute();
$row = $stmt->fetchObject();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $row->stadiumName;?></title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/styles.css" rel="stylesheet">
</head>
<body>
<div class="container">
<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li><a href="cmsIndex.php">Home</a></li>
</ul>
</div>
</nav>
<div class="row">
<div class="col-md-4">
<?php
// add image here
echo "<p><img src=\"images/$row->stadiumImage\" alt=$row->stadiumName></p>"; //Gets the film image and provides an alt attribute being the film name
?>
</div>
<div class="col-md-8">
<?php
// format the date output
echo "<p>$row->matchDescription</p>";
$timestampDate = strtotime($row->matchDate);
$displayDate = date("D d M Y", $timestampDate);//Changes the format from mySQL date
echo "<p>Release Date: $displayDate</p>";
echo "<p>Price: £$row->ticketPrice</p>";
?>
</div>
</div>
</div>
<footer>
<div class="container">
<p class="text-muted">© 2016 mustbebuilt.co.uk</p>
</div>
</footer>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire