Okay, its probably that PHP automatically recieves the httpvars and i'm creating some sort of redundancy but ANYONE please help me on this. I can't get these databases to update correctly. Here's the database structure:
pnum varchar(30) NULL
length smallint(6) 0
price smallint(6) 0
weight smallint(6) 0
desc varchar(60) NULL
id mediumint(9) auto_increment
and here's the code that doesn't work:
<body>
<?php
$dbase = mysql_connect("localhost", "joes", "wasup");
mysql_select_db("joesgaragebbs_com", $dbase);
$varcnt = 0;
while (list($name, $value) = each($HTTP_POST_VARS)) {
$var = $name;
global $$var;
$var = $value;
}
if ($submit) {
$sqla = "UPDATE axle SET length='$length', price='$price', weight='$weight' WHERE id='$id'";
$sqlb = "UPDATE axle SET pnum='$pnum' WHERE pnum='$oldpnum' WHERE id='$id'";
$sqlc = "UPDATE axle SET desc='$desc' WHERE desc='$olddesc' WHERE id='$id'";
echo $submit;
echo $sqla . "<br>" . $sqlb . "<br>" . $sqlc;
mysql_query($sqla) or die(mysql_error());
mysql_query($sqlb) or die(mysql_error());
mysql_query($sqlc) or die(mysql_error());
echo $sqla . "<br>" . $sqlb . "<br>" . $sqlc;
}
$dbase = mysql_connect("localhost", "joes", "wasup");
mysql_select_db("joesgaragebbs_com", $dbase);
$result = mysql_query("Select * From axle");
echo "<table width='100%' border=0 cellpadding=2 cellspacing=1 border=1 align='center' bordercolor='#000000'> <tr align='center'>";
echo "<form action='$PHP_SELF' method=POST>";
echo "<td>Part Number</td><td>Length</td><td>Price</td><td>Weight</td><td>Description</td><td>Change?</td></tr></b>";
$cntr = 1;
while($row = mysql_fetch_row($result)) {
$pnum = $row[0];
$length = $row[1];
$price = $row[2];
$weight = $row[3];
$desc = $row[4];
$id = $row[5];
echo "<tr align='center'>";
echo "<td><input type=text name='pnum' value='$pnum'></td>";
echo "<td><input type=text name='length' value='$length'></td>";
echo "<td><input type=text name='price' value='$price'></td>";
echo "<td><input type=text name='weight' value='$weight'></td>";
echo "<td><input type=text name='desc' value='$desc'></td>";
echo "<td><input type=hidden value='$id' name='id'></td>";
echo "</tr>";
echo "<input type=hidden name='oldpnum' value='$pnum'><input type=hidden name='olddesc' value='$desc'></form>";
$cntr += 1;
}
echo "<input type=submit name='submit' value='submit'>";
echo "</table>";
mysql_close;
?>
i was getting it to update the number/int fields, but not the strings...i even messed around w/ the types...making them text/varchars...but to no avail...