troubleshooting Question

Update MYSQL - Me no understand

Avatar of Mike Kristensen
Mike Kristensen asked on
HTMLPHPCOBOL
11 Comments2 Solutions424 ViewsLast Modified:
Hello all..... I got a Little problem.

The first code here will update my table correctly.

if(isset($_POST['ryd_finaletavle'])){
$UpdateQuery = "UPDATE finale_tavle SET finale_deltager='', finale_kval_res='0' WHERE finale_dage='onsdag_1' OR finale_dage= 'onsdag_2'";
mysql_query($UpdateQuery, $con);
};

$sql = "SELECT * FROM finale_tavle"; 
$myData = mysql_query($sql,$con) or die(mysql_error());

echo "<br><br><b>Finaletavle</b><br><br>

<table border=0>
<tr>
<th>Dag</th>
<th>Navn</th>
<th>Resultat</th>
</tr>";
while($record = mysql_fetch_array($myData)){
echo "<form action=admin.php method=post>";
echo "<tr>";
echo "<td>" . "<input type=text name=f_dage value='" . $record['finale_dage'] . "'> </td>";
echo "<td>" . "<input type=text name=f_deltager value='" . $record['finale_deltager'] . "'> </td>";
echo "<td>" . "<input type=text name=f_kval_res value='" . $record['finale_kval_res'] . "'> </td>";
echo "<td>" . "<input type=submit name=finale_tavle_opdater value=Opdater" . "> </td>";
echo "<td>" . "<input type=submit name=ryd_finaletavle value='Ryd hele Finaletavlen' style='color:#c00;'" . "> </td>";
echo "</tr>";
echo "</form>";

}


But with 1 tiny change, it wont do anymore. . . I move the "Updatequery" submit under the fetch loop and then it wont update anymore........
I am missing the reason. I guees i dont understand the syntax completely.

if(isset($_POST['ryd_finaletavle'])){
$UpdateQuery = "UPDATE finale_tavle SET finale_deltager='', finale_kval_res='0' WHERE finale_dage='onsdag_1' OR finale_dage= 'onsdag_2'";
mysql_query($UpdateQuery, $con);
};

$sql = "SELECT * FROM finale_tavle"; 
$myData = mysql_query($sql,$con) or die(mysql_error());

echo "<br><br><b>Finaletavle</b><br><br>

<table border=0>
<tr>
<th>Dag</th>
<th>Navn</th>
<th>Resultat</th>
</tr>";
while($record = mysql_fetch_array($myData)){
echo "<form action=admin.php method=post>";
echo "<tr>";
echo "<td>" . "<input type=text name=f_dage value='" . $record['finale_dage'] . "'> </td>";
echo "<td>" . "<input type=text name=f_deltager value='" . $record['finale_deltager'] . "'> </td>";
echo "<td>" . "<input type=text name=f_kval_res value='" . $record['finale_kval_res'] . "'> </td>";
echo "<td>" . "<input type=submit name=finale_tavle_opdater value=Opdater" . "> </td>";

echo "</tr>";
echo "</form>";

}
echo "<td>" . "<input type=submit name=ryd_finaletavle value='Ryd hele Finaletavlen' style='color:#c00;'" . "> </td>";

I just want 1 button to update my table. Not a button right from every fetch loop.
ASKER CERTIFIED SOLUTION
mankowitz

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros