Tuesday, 3 September 2013

PHP/MYSQL Check if a field in a certain row and column is empty

PHP/MYSQL Check if a field in a certain row and column is empty

So, I have a database with the fields player1 player2 player3... player12
I need to check if the column player1 is empty in a certain row.
Here's what I have in join.php
<?php
require 'connect.inc.php';
$playername = $_GET['name'];
$tour_name = $_GET['tourname'];
if (isset($playername)&&
isset($tour_name)) {
$query = "SELECT `tour_name` FROM `tournies` WHERE
`tour_name` = '$tour_name'";
$query_run = mysql_query($query);
echo mysql_error();
//mysql_query("UPDATE `tournies` SET
player1='".$playername."' WHERE
tour_name='".$tour_name."'");
if ($query_run = mysql_query($query)) {
header('Location: s.php');
} else {
echo 'not a win.';
echo mysql_error();
}
} else {
echo 'Invalid username or tournament ID, please return to <a
href="index.php">Home</a> and try again. Sorry.';
}
?>

No comments:

Post a Comment