Please help me out, this is my project for finals, I am desperate.
<?php
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","root","root");
//select which database you want to edit
mysql_select_db("DATABASE");
$count = 0;
//get the mysql and store them in $result
//change whatevertable to the mysql table you're using
//change whatevercolumn to the column in the table you want to search
$result = mysql_query("SELECT * FROM table");
$self = $_SERVER['PHP_SELF'];
$form = "<form method=\"post\" action=\"$self\"><input type=\"submit\" name=\"submit\" value=\"change_value\"></form>";
echo "<table border=1>";
echo "<tr>";
echo "<td></td>";
echo "<td>col1</td>";
echo "<td>col2</td>";
echo "<td>col3</td>";
echo "<td>col4</td>";
echo "<td>col5</td>";
echo "<td>col6</td>";
echo "<td>col7</td>";
echo "</tr>";
//grab all the content
while($r = mysql_fetch_array($result))
{
//the format is $variable = $r["nameofmysqlcolumn"];
//modify these to match your mysql table columns
$col1=$r["col1"];
$col2=$r["col2"];
$col3=$r["col3"];
$col4=$r["col4"];
$col5=$r["col5"];
$col6=$r["col6"];
$col7=$r["col7"];
$col8=$r["col8"];
$col9=$r["col9"];
//there are a total of 9 columns in the table
if(($col9 == "y") || ($col9 == "Y"))
{
if(($col8 == "Y") || ($col8 == "y"))
{
echo "<tr>";
echo "<td></td>";
echo '<td bgcolor="#ffff00">';
echo "$col1";
echo '</td>';
echo '<td bgcolor="#ffff00">';
echo "$col2";
echo '</td>';
echo '<td bgcolor="#ffff00">';
echo "$col3";
echo '</td>';
echo '<td bgcolor="#ffff00">';
echo "$col4";
echo '</td>';
echo '<td bgcolor="#ffff00">';
echo "$col5";
echo '</td>';
echo '<td bgcolor="#ffff00">';
echo "$col6";
echo '</td>';
echo '<td bgcolor="#ffff00">';
echo "$col7";
echo '</td>';
echo "</tr>";
//display the row
}
else{
echo "<tr>";
print "<td>$form</td>";
echo "<td>$col1</td>";
echo "<td>$col2</td>";
echo "<td>$col3</td>";
echo "<td>$col4</td>";
echo "<td>$col5</td>";
echo "<td>$col6</td>";
echo "<td>$col7</td>";
echo "</tr>";
}
if(isset($_POST['submit']))
{
mysql_query("UPDATE table SET col8='Y' ");
}
$count = $count + 1;
}
}
echo "</table><br />";
echo "only found $count number of datas";
?>


Sign In
Create Account

Back to top









