im pretty this is wrong is there a way to narrow it down to 2 files one to update in and edit in mysql and one where its viewed and do i need a mysql_connect on each page? I tried a few times and still can't get these to work. Im sorry for posting the same topic i did the other day but i couldnt get it to work and figured let me try in the coding forum.
Thanks Guys and or gals
3 files
standings.php
<?php
mysql_connect('localhost','Dbname','pw');
$db=mysql_select_db('dbname');
$db
$query = "SELECT * FROM standings";
$qh = mysql_query($query);
if (!$qh) {
echo mysql_errno().": ".mysql_error()."<BR>";
} else {
while ($row = mysql_fetch_array($qh)) {
echo "Rank: $row[rank]<br>Won: $row[won]<br>Lost: $row[lost]<br>Percent: $row[percent]%<br>Updated: $row[date]<br>";
}
}
?>
stanedit.php
<table width="500">
<tr>
<td valign=top width=250><font size="3" face="tahoma"><br>Rank:<br>Won:<br>Lost:
</td>
<?php
mysql_connect('localhost','Dbname','pw');
$db=mysql_select_db('dbname');
$db
$query = "SELECT * FROM standings";
$qh = mysql_query($query);
if (!$qh) {
echo mysql_errno().": ".mysql_error()."<BR>";
} else {
while ($row = mysql_fetch_array($qh)) {
echo "<form method=post action=standupdater.php><td valign=top width=250><br><input type=text name=rank1 value=$row[rank]><BR><input type=text name=won1 value=$row[won]><BR><input type=text name=lost1 value=$row[lost]><br><BR><input type=submit value=Update>\n";
}
}
?>
</td></tr></table>
standepdate.php
<?php
mysql_connect('localhost','Dbname','pw');
$db=mysql_select_db('dbname');
$db
$percent1 = floor(($won1 / ($won1 + $lost1)) * 100);
$date1 = date ("n/d/Y");
$q = "update standings SET rank='$rank1',won='$won1',lost='$lost1',percent='$percent1',date='$date1'";
mysql_query($q);
$qh = mysql_query($q);
if (!$qh) {
echo mysql_errno().": ".mysql_error()."<BR>";
} else {
echo "Updated.\n";
}
?><br>