Hi all,
I'm a newby, but I'd like to kick off with something quite difficult (perhaps). It's too much to mention in a single message, so I'll work it out in a reply to a reply, if I get any ;-).
This is what I want this script to do:
This script opens in a pop-up, when I click on an edit button, which is on every single line of a stock-list. You can see it at: www.anastacia-newkirk.com/shop. It says edit.php?artikelnr=$artikelnr.
So far it works good. It opens the pop-up and all the default values are the original values, selected from the database.
When I want to update the record, it just won't work. The value won't change.
I figured out that it might work out with sessions, though I don't want the session to stay alive, after I've updated the table, as when I want to select another record to update, it would still have the 'artikelnr'-value from the session.
Any help is really appreciated!
<HTML>
<HEAD>
</HEAD>
<body bgcolor="#000000" text="#EFDEB7" link="#EFDEB7" vlink="#EFDEB7" alink="#FCCE7B" style="font-size: 7 pt; font-family: Arial" leftmargin="18">
<?
include("../../dbconnect.php");
$sql = "SELECT * FROM shop WHERE artikelnr = '$artikelnr'";
$result = @($sql);
if (!$result){
die("Database error: " . mysql_error());
}
while ($row = mysql_fetch_array($result)) {
// extract the results per field and assign a variable name to each
// This is just an example of one list I made
$artikelnr = $row["artikelnr"];
$format = $row["format"];
$titel = $row["titel"];
$type = $row["type"];
$releasedate = $row["releasedate"];
$country = $row["country"];
$label = $row["label"];
$cat = $row["cat"];
$tracks = $row["tracks"];
$price = $row["price"];
$shipping = $row["shipping"];
$img = $row["img"];
?>
<FORM action="<?=$PHP_SELF?>" method="post">
<p><font size="3"><B>ADMINISTRATIVE AREA</B></font></p>
<table border="0" width="800">
<tr>
<td width="16%"><font face="Arial" size="2">artikelnr.:</font></td>
<td width="16%"><? echo($artikelnr); ?></td>
<td width="17%"><font face="Arial" size="2">format:</font></td>
<td width="17%"><? include('nformat.php'); ?></td>
<td width="17%"></td>
<td width="17%"></td>
</tr>
<tr>
<td width="16%"><font face="Arial" size="2">titel:</font></td>
<td width="84%" colspan="5"><input type="text" name="newtitel" size="100" value="<? echo($titel); ?>"></td>
</tr>
<tr>
<td width="16%"><font face="Arial" size="2">type:</font></td>
<td width="16%"><? include('ntype.php'); ?></td>
<td width="17%"><font face="Arial" size="2">releasedate:</font></td>
<td width="17%"><input type="text" name="newrelease" size="10" value="<? echo($releasedate); ?>"></td>
<td width="17%"><font face="Arial" size="2">origin:</font></td>
<td width="17%"><? include('norigin.php'); ?></td>
</tr>
<tr>
<td width="16%"><font face="Arial" size="2">label:</font></td>
<td width="16%"><? include('nlabel.php'); ?></td>
<td width="17%"><font face="Arial" size="2">cat.nr.:</font></td>
<td width="17%"><input type="text" name="newcat" size="12" value="<? echo($cat); ?>"></td>
<td width="17%"><font face="Arial" size="2"># of tracks:</font></td>
<td width="17%"><input type="text" name="newtracks" size="2" value="<? echo($tracks); ?>"></td>
</tr>
<tr>
<td width="16%"><font face="Arial" size="2">price:</font></td>
<td width="16%"><input type="text" name="newprice" size="7" value="<? echo($price); ?>"></td>
<td width="17%"><font face="Arial" size="2">shipping:</font></td>
<td width="17%"><input type="text" name="newshipping" size="1" value="<? echo($shipping); ?>"></td>
<td width="17%"><font face="Arial" size="2"># of scans:</font></td></td>
<td width="17%"><? include('nimg.php'); ?></td>
</tr>
</table>
<p><input type="submit" value="submit" name="Submit3"><input type="reset" value="Reset" name="B2"></p>
<?
session_start();
session_register("artikelnr");
?>
</form>
<?
}
echo($artikelnr);
if (isset($Submit3)) {
?>
artikelnr:
<?
echo($artikelnr);
$result3 = mysql_query("UPDATE shop SET format='$newformat', titel='$newtitel', type='$newtype', releasedate='$newrelease', country='$newcountry', label='$newlabel', cat='$newcat', tracks='$newtracks', price='$newprice', shipping='$newshipping', img='$newimg' WHERE artikelnr = '$artikelnr'");
session_unregister("artikelnr");
header("Location: success.php");
}
else {
session_unregister("artikelnr");
}
?>
</body>
</html>
Thanks! Marijn