Håller på bygga en sida åt ett musikbolag med mera. Och håller på bygga bokningssystemet för artisterna. har gjort allt för att den skall skriva in spelningarna i databasen och lista alla.
Spelningarna listas i en tabell med 7 fält på varje rad.
DATUM - PLATS - BAND - TEXT - ID - RADERA - REDIGERA
Allt funkar förutom att jag fasen inte vet hur jag ska få radera och redigera länkarna att funka. kom på att det var ganska enkelt att arbeta med php å mysql i dreamweaver så jag har byggt sjv. hur koden ser ut och fungerar i övrigt bryr jag mig inte om. bara den gör som jag säger.
här är koden som den ser ut nu:
EDIT: har en länk som ser ut såhär:
Code: Select all
<a href="bokning/delete.php?recordID=<?php echo $row_boka['id']; ?>">Radera</a>
Code: Select all
<?php require_once('Connections/MySQL.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO bokning1 (datum, plats, text, id, band) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['datum'], "date"),
GetSQLValueString($_POST['plats'], "text"),
GetSQLValueString($_POST['text'], "text"),
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($_POST['band'], "text"));
mysql_select_db($database_MySQL, $MySQL);
$Result1 = mysql_query($insertSQL, $MySQL) or die(mysql_error());
$insertGoTo = "boka.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO bandnamn (bandnamn) VALUES (%s)",
GetSQLValueString($_POST['bandnamn'], "text"));
mysql_select_db($database_MySQL, $MySQL);
$Result1 = mysql_query($insertSQL, $MySQL) or die(mysql_error());
$insertGoTo = "boka.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_GET['id'])) && ($_GET['id'] != "")) {
$deleteSQL = sprintf("DELETE FROM bokning1 WHERE id=%s",
GetSQLValueString($_GET['id'], "int"));
mysql_select_db($database_MySQL, $MySQL);
$Result1 = mysql_query($deleteSQL, $MySQL) or die(mysql_error());
$deleteGoTo = "boka.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
mysql_select_db($database_MySQL, $MySQL);
$query_boka = "SELECT * FROM bokning1";
$boka = mysql_query($query_boka, $MySQL) or die(mysql_error());
$row_boka = mysql_fetch_assoc($boka);
$totalRows_boka = mysql_num_rows($boka);
mysql_select_db($database_MySQL, $MySQL);
$query_Recordset1 = "SELECT * FROM bandnamn";
$Recordset1 = mysql_query($query_Recordset1, $MySQL) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Inbokning av artister!</title>
<style type="text/css">
<!--
#BOLD {
font-weight: bold;
}
-->
</style>
</head>
<body>
<p> </p>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Datum:</td>
<td><input type="text" name="datum" value="" size="32" />
ÅÅMMDD</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Plats:</td>
<td><input type="text" name="plats" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right" valign="top">Text:</td>
<td><textarea name="text" cols="50" rows="5"></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Band:</td>
<td><select name="band">
<?php
do {
?>
<option value="<?php echo $row_Recordset1['bandnamn']?>" ><?php echo $row_Recordset1['bandnamn']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
?>
</select></td>
</tr>
<tr> </tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Lägg till!" /></td>
</tr>
</table>
<input type="hidden" name="id" value="" />
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
<form action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Lägg till Bandnamn:</td>
<td><input type="text" name="bandnamn" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Lätt till!" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form2" />
</form>
<p> </p>
<table width="765" border="1px" align="center" cellpadding="0" cellspacing="4">
<tr>
<td width="126"><strong>Datum</strong></td>
<td width="117"><strong>Plats</strong></td>
<td width="119"><strong>Band</strong></td>
<td width="222"><strong>Text</strong></td>
<td width="29"><strong>ID</strong></td>
<td width="47"><strong>Radera</strong></td>
<td width="57"><strong>Redigera</strong></td>
</tr>
<?php do { ?>
<tr>
<td align="left" valign="top"><?php echo $row_boka['datum']; ?></td>
<td align="left" valign="top"><?php echo $row_boka['plats']; ?></td>
<td align="left" valign="top"><?php echo $row_boka['band']; ?></td>
<td align="left" valign="top"><?php echo $row_boka['text']; ?></td>
<td align="left" valign="top"><?php echo $row_boka['id']; ?></td>
<td align="center">Radera </td>
<td align="center">Redigera</td>
</tr>
<?php } while ($row_boka = mysql_fetch_assoc($boka)); ?>
</table>
<p> </p>
<p> </p>
</body>
</html>
<?php
mysql_free_result($boka);
mysql_free_result($Recordset1);
?>
Hoppas nån kan hjälpa!