<?php
{
echo "</br>";
echo "</br>";
echo "<table border='1'> <tr>";
while ($row1=mysql_fetch_array($result1)){
echo "<td><strong>" . $_POST['card_no']. "</strong></td>";
echo "<td><strong>" . $row1['lname']. "</strong></td>";
}
"</tr>";
echo "<tr><td><strong> Total Incentive: </strong></td><td><strong> Rs." $TotalIncentive " </strong> </td></tr>";
//i want to show Total Incentive Value above table "$TotalIncentive". pls see attached image for more clarification.
echo "<table border='1' width='auto'>
<tr>
<th>Tid</th>
<th>Depart</th>
<th>Sub Depart</th>
<th>EARN</th>
<th>Eff</th>
<th> Group Eff </th>
<th>Date</th>
<th>Incentive</th>
</tr>";
//$sql=Query not show here becz its very large Query
$result=mysql_query($sql);
while ($row=mysql_fetch_array($result)){
echo "<tr>";
echo "<td bgcolor='#FFFFF'>" . $row['t_id'] . "</td>";
echo "<td bgcolor='#FFFFF'>" . $row['dep_code'] . "</td>";
echo "<td bgcolor='#FFFFF'>" . $row['subdep_code']." ".$row['type_code'] . "</td>";
echo "<td bgcolor='#FFFFF'>" . $row['TER']. "</td>";
echo "<td bgcolor='#00FF33'>" . round(($row['TER']/570)*$pre). "%</td>";
echo "<td bgcolor='#FFFF00'>" . round($row['geff1']) . "%</td>";
echo "<td bgcolor='#FFFFF'>" . $row['tdate'] . "</td>";
if($row['geff1']>=105){
$inc=(300*($row['TER']/570)*$pre)/105;
}elseif($row['geff1']>=100){
$inc=(275*($row['TER']/570)*$pre)/100;
}elseif($row['geff1']>=95){
$inc=(240*($row['TER']/570)*$pre)/95;
}elseif($row['geff1']>=90){
$inc=(200*($row['TER']/570)*$pre)/90;
}elseif($row['geff1']>=85){
$inc=(160*($row['TER']/570)*$pre)/85;
}elseif($row['geff1']>=80){
$inc=(120*($row['TER']/570)*$pre)/80;
}elseif($row['geff1']>=75){
$inc=(90*($row['TER']/570)*$pre)/75;
}elseif($row['geff1']>=70){
$inc=(60*($row['TER']/570)*$pre)/70;
}elseif($row['geff1']>=65){
$inc=(30*($row['TER']/570)*$pre)/65;
}elseif($row['geff1']<65){
$inc=0;
}
echo "<td ><strong>Rs.".round($inc,2);"</strong></td>";
echo "</tr>";
//Total Incentive Should be SUM(round($inc,2))
}
echo "</table>";
mysql_close($con);
}
//I want to Show "Total Incentive" Value in the place that i mention in my Image
?>
update your while loop as below & echo $totalInc at the end of this while() loop
<?php
$totalInc = 0; //added this variable
while ($row=mysql_fetch_array($result)){
echo "<tr>";
echo "<td bgcolor='#FFFFF'>" . $row['t_id'] . "</td>";
echo "<td bgcolor='#FFFFF'>" . $row['dep_code'] . "</td>";
echo "<td bgcolor='#FFFFF'>" . $row['subdep_code']." ".$row['type_code'] . "</td>";
echo "<td bgcolor='#FFFFF'>" . $row['TER']. "</td>";
echo "<td bgcolor='#00FF33'>" . round(($row['TER']/570)*$pre). "%</td>";
echo "<td bgcolor='#FFFF00'>" . round($row['geff1']) . "%</td>";
echo "<td bgcolor='#FFFFF'>" . $row['tdate'] . "</td>";
if($row['geff1']>=105){
$inc=(300*($row['TER']/570)*$pre)/105;
}elseif($row['geff1']>=100){
$inc=(275*($row['TER']/570)*$pre)/100;
}elseif($row['geff1']>=95){
$inc=(240*($row['TER']/570)*$pre)/95;
}elseif($row['geff1']>=90){
$inc=(200*($row['TER']/570)*$pre)/90;
}elseif($row['geff1']>=85){
$inc=(160*($row['TER']/570)*$pre)/85;
}elseif($row['geff1']>=80){
$inc=(120*($row['TER']/570)*$pre)/80;
}elseif($row['geff1']>=75){
$inc=(90*($row['TER']/570)*$pre)/75;
}elseif($row['geff1']>=70){
$inc=(60*($row['TER']/570)*$pre)/70;
}elseif($row['geff1']>=65){
$inc=(30*($row['TER']/570)*$pre)/65;
}elseif($row['geff1']<65){
$inc=0;
}
$totalInc = $totalInc + $inc; //set value to this variable
echo "<td ><strong>Rs.".round($inc,2);"</strong></td>";
echo "</tr>";
Related
I need to retrieve the color hex code stored in a database and display it as seen on screen within a table cell. i'm trying to find a way to convert the hex code the db query returns for that specific table cell into the actual color that the hex denotes. Here's my code...
<?php
// Include config file
require_once "config.php";
$pdo = new PDO($dsn, $username, $password, $options);
// Attempt select query execution
$sql = "SELECT * FROM sales";
if($result = $pdo->query($sql)){
if($result->rowCount() > 0){
echo "<table class='table table-bordered table-striped'>";
echo "<thead>";
echo "<tr>";
echo "<th>S/N</th>";
echo "<th>Transaction Date</th>";
echo "<th>Customer Name</th>";
echo "<th>Address</th>";
echo "<th>Phone Number</th>";
echo "<th>Vehicle Model</th>";
echo "<th>Vehicle Chassis Number</th>";
echo "<th>Vehicle Registration Number</th>";
echo "<th>Vehicle Color</th>";
echo "<th>Amount Paid</th>";
echo "<th>Advance</th>";
echo "<th>Balance</th>";
echo "<th>Balance Due Date</th>";
echo "<th>Paid To</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while($row = $result->fetch()){
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['transactiondate'] . "</td>";
echo "<td>" . $row['customername'] . "</td>";
echo "<td>" . $row['address'] . "</td>";
echo "<td>" . $row['phonenumber'] . "</td>";
echo "<td>" . $row['vehiclemodel'] . "</td>";
echo "<td>" . $row['vehiclechassisnumber'] . "</td>";
echo "<td>" . $row['vehicleregistrationnumber'] . "</td>";
echo "<td>" . $row['vehiclecolor'] . "</td>";
echo "<td>" . $row['amountpaid'] . "</td>";
echo "<td>" . $row['advance'] . "</td>";
echo "<td>" . $row['balance'] . "</td>";
echo "<td>" . $row['balancedate'] . "</td>";
echo "<td>" . $row['paidto'] . "</td>";
echo "<td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
// Free result set
unset($result);
} else{
echo "<p class='lead'><em>No records were found.</em></p>";
}
} else{
echo "ERROR: Could not able to execute $sql. " . $mysqli->error;
}
// Close connection
unset($pdo);
?>
It is a bit unclear about where you wish to use the colour but I'm assuming it is here. And also my assumption is the retrieved value for vehiclecolor column is a HEX value
echo "<td>" . $row['vehiclecolor'] . "</td>";
You can use tag property 'background-color' for this.
$temp = $row['vehiclecolor'];
echo "<td style='background-color:" . $temp ."'></td>";
Pretty self-explanatory I guess. String concatenation.
when either Project or No is clicked, they open in a new window with other details under that clicked row, but i want them to open in a child window instead. is there a way to do it?
this is my code
<table id="keywords" class="container">
<thead>
<tr>
<td><span>Project</span></td>
<td><span>No</span></td>
<td><span>Sub ID</span></td>
<td><span>Name</span></td>
<td><span>Requested Amount</span></td>
<td><span>Paid Amount</span></td>
<td><span>Amount To be Paid</span></td>
<td><span>Description</span></td>
<td><span>State</span></td>
</tr>
</thead>
<?php
/* showing table */
$sql = "SELECT * FROM memo ORDER BY No DESC, SubID ASC"
or die("Failed to query database" .mysqli_error());
$result = $link->query($sql);
while ($row = $result->fetch_assoc()) {
print "<tr>";
print "<td >" . $row['Project'] . "</td>";
print "<td >" . $row['No'] . "</td>";
print "<td >" . $row['SubID'] . "</td>";
print "<td >" . $row['Name'] . "</td>";
print "<th >" . $row['RequestAmount'] . "</th>";
print "<th >" . $row['PaidAmount'] . "</th>";
print "<th >" . $row['AmountToPay'] . "</th>";
print "<td >" . $row['Description'] . "</td>";
print "<td >" . $row['State'] . "</td>";
print "</tr>";
}
// print "</table>";
?>
</table>
I'm wondering if my code could be easier with a foreach loop. my code thusfar:
the purpose is to read the values in the MYSQL table, and if the anwser is "NEE" display the background color in RED. my code works but it is very long..
$connection = mysql_connect('localhost', 'root', ''); //The Blank string is
the password
mysql_select_db('heijsDB');
$query = "SELECT * FROM hygieneaanvoer"; //You don't need a ; like you do in
SQL
$result = mysql_query($query);
//List the Columns for the Report
if(! $result ) {
die('Could display data: ' . mysql_error());
}
echo "<table border='1' class='w3-panel'>
<fieldset>hygiëne/GMP aduit Aanvoer</fieldset>
<tr>
<th>Datum</th>
<th>Controleur</th>
<th>controleur</th>
<th>Revisie</th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
<th>7</th>
<th>8</th>
<th>9</th>
<th>10</th>
<th>11</th>
<th>12</th>
<th>13</th>
<th>14</th>
<th>15</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['datum'] . "</td>";
echo "<td>" . $row['controleur'] . "</td>";
echo "<td>" . $row['codering'] . "</td>";
echo "<td>" . $row['revisie'] . "</td>";
if($row['q1']=='NEE') // [val1] can be 'approved'
echo "<td style='background-color: #e21010;'>".$row['q1']."</td>";
else echo "<td>".$row['q1']."</td>";
if($row['q2']=='NEE') // [val1] can be 'approved'
echo "<td style='background-color: #e21010;'>".$row['q2']."</td>";
else echo "<td>".$row['q2']."</td>";
if($row['q3']=='NEE') // [val1] can be 'approved'
echo "<td style='background-color: #e21010;'>".$row['q3']."</td>";
else echo "<td>".$row['q3']."</td>";
if($row['q4']=='NEE') // [val1] can be 'approved'
echo "<td style='background-color: #e21010;'>".$row['q4']."</td>";
else echo "<td>".$row['q4']."</td>";
if($row['q5']=='NEE') // [val1] can be 'approved'
echo "<td style='background-color: #e21010;'>".$row['q5']."</td>";
else echo "<td>".$row['q5']."</td>";
if($row['q6']=='NEE') // [val1] can be 'approved'
echo "<td style='background-color: #e21010;'>".$row['q6']."</td>";
else echo "<td>".$row['q6']."</td>";
if($row['q7']=='NEE') // [val1] can be 'approved'
echo "<td style='background-color: #e21010;'>".$row['q7']."</td>";
else echo "<td>".$row['q7']."</td>";
if($row['q8']=='NEE') // [val1] can be 'approved'
echo "<td style='background-color: #e21010;'>".$row['q8']."</td>";
else echo "<td>".$row['q8']."</td>";
if($row['q9']=='NEE') // [val1] can be 'approved'
echo "<td style='background-color: #e21010;'>".$row['q9']."</td>";
else echo "<td>".$row['q9']."</td>";
if($row['q10']=='NEE') // [val1] can be 'approved'
echo "<td style='background-color: #e21010;'>".$row['q10']."</td>";
else echo "<td>".$row['q10']."</td>";
if($row['q11']=='NEE') // [val1] can be 'approved'
echo "<td style='background-color: #e21010;'>".$row['q11']."</td>";
else echo "<td>".$row['q11']."</td>";
if($row['q12']=='NEE') // [val1] can be 'approved'
echo "<td style='background-color: #e21010;'>".$row['q12']."</td>";
else echo "<td>".$row['q12']."</td>";
if($row['q13']=='NEE') // [val1] can be 'approved'
echo "<td style='background-color: #e21010;'>".$row['q13']."</td>";
else echo "<td>".$row['q13']."</td>";
if($row['q14']=='NEE') // [val1] can be 'approved'
echo "<td style='background-color: #e21010;'>".$row['q14']."</td>";
else echo "<td>".$row['q14']."</td>";
if($row['q15']=='NEE') // [val1] can be 'approved'
echo "<td style='background-color: #e21010;'>".$row['q15']."</td>";
else echo "<td>".$row['q15']."</td>";
echo "</tr>";
}
echo "</table>";
?>
Here is solution
$result = mysql_query("SELECT * FROM hygieneaanvoer")or die('Could display data: ' . mysql_error());;
echo "<table border='1' class='w3-panel'>
<fieldset>hygiëne/GMP aduit Aanvoer</fieldset>
<tr>
<th>Datum</th>
<th>Controleur</th>
<th>controleur</th>
<th>Revisie</th>";
for ($i=1;$i<=15;$i++){
echo '<th>'.$i.'</th>';
}
echo "</tr>";
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['datum'] . "</td>";
echo "<td>" . $row['controleur'] . "</td>";
echo "<td>" . $row['codering'] . "</td>";
echo "<td>" . $row['revisie'] . "</td>";
for ($j=1;$j<=15;$j++){
echo "<td ".(($row['q'.$j] == 'NEE') ? "style='background-color: #e21010;'" : "" ).">".$row['q'.$j]."</td>";
}
echo "</tr>";
}
echo "</table>";
?>
What you could do, is just create a single variable that you'd use for setting the style of all rows:
while($row = mysql_fetch_array($result))
{
$style_string = "";
if($row['q1']=='NEE') {
$style_string = "style='background-color: #e21010;'";
}
echo "<tr>";
echo "<td>" . $row['datum'] . "</td>";
echo "<td>" . $row['controleur'] . "</td>";
echo "<td>" . $row['codering'] . "</td>";
echo "<td>" . $row['revisie'] . "</td>";
echo "<td " . $style_string . ">" . $row['q1'] . "</td>";
echo "<td " . $style_string . ">" . $row['q2'] . "</td>";
echo "<td " . $style_string . ">" . $row['q3'] . "</td>";
echo "<td " . $style_string . ">" . $row['q4'] . "</td>";
echo "<td " . $style_string . ">" . $row['q5'] . "</td>";
echo "<td " . $style_string . ">" . $row['q6'] . "</td>";
echo "<td " . $style_string . ">" . $row['q7'] . "</td>";
echo "<td " . $style_string . ">" . $row['q8'] . "</td>";
echo "<td " . $style_string . ">" . $row['q9'] . "</td>";
echo "<td " . $style_string . ">" . $row['q10'] . "</td>";
echo "<td " . $style_string . ">" . $row['q11'] . "</td>";
echo "<td " . $style_string . ">" . $row['q12'] . "</td>";
echo "<td " . $style_string . ">" . $row['q13'] . "</td>";
echo "<td " . $style_string . ">" . $row['q14'] . "</td>";
echo "<td " . $style_string . ">" . $row['q15']. "</td>";
echo "</tr>";
}
(Or just set the background color of the <tr>)
Best of luck!
You can simply add the class to the td like this
echo "<td class='". $row['q15'] . "'>".$row['q15']."</td>";
Add css like this
.NEE {background-color: #e21010;}
I have a mysql table with a row that is either going to be a 0 or a 1. However, I want to be able to display the table with PHP and have 0 show up as no, and 1 show up as yes. I am still a beginner with PHP and have been searching for a way to do it, but have had no luck. The row in question is the 'masterwork' row. The line of code I thought would do it is
$row['masterwork'] = ( intval( $row['masterwork']) == 1) ? "YES" : "NO";
Here is the code that displays the table:
<?php
$con=mysqli_connect("localhost","username","password","database");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM weapons");
$row['masterwork'] = ( intval( $row['masterwork']) == 1) ? "YES" : "NO";
while($row = mysqli_fetch_array($result))
{
echo "<center>";
echo "<table border='1' class='display'>";
echo "<tr>";
echo "<td>Weapon Name: </td>";
echo "<td>" . $row['weaponName'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Creator: </td>";
echo "<td>" . $row['creator'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Weapon Category: </td>";
echo "<td>" . $row['weaponCategory'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Weapon Sub-Category: </td>";
echo "<td>" . $row['weaponSubCategory'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Cost: </td>";
echo "<td>" . $row['costAmount'] . " " . $row['costType'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Damage(S): </td>";
echo "<td>" . $row['damageS'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Damage(M): </td>";
echo "<td>" . $row['damageM'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Critical: </td>";
echo "<td>" . $row['critical'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Range Increment: </td>";
echo "<td>" . $row['rangeIncrement'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Weight: </td>";
echo "<td>" . $row['weight'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Weapon Type: </td>";
echo "<td>" . $row['weaponType'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Masterwork: </td>";
echo "<td>" . $row['masterwork'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Special Abilities: </td>";
echo "<td>" . $row['specialAbilities'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Additional Info: </td>";
echo "<td>" . $row['additionalInfo'] . "</td>";
echo "</tr>";
}
echo "</table>";
echo "</center>";
mysqli_close($con);
?>
try this --
$result = mysqli_query($con,"SELECT * FROM weapons");
while($row = mysqli_fetch_array($result))
{
$row['masterwork'] = ( intval( $row['masterwork']) == 1) ? "YES" : "NO";
echo "<center>";
echo "<table border='1' class='display'>";
echo "<tr>";
echo "<td>Weapon Name: </td>";
echo "<td>" . $row['weaponName'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Creator: </td>";
echo "<td>" . $row['creator'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Weapon Category: </td>";
echo "<td>" . $row['weaponCategory'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Weapon Sub-Category: </td>";
echo "<td>" . $row['weaponSubCategory'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Cost: </td>";
echo "<td>" . $row['costAmount'] . " " . $row['costType'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Damage(S): </td>";
echo "<td>" . $row['damageS'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Damage(M): </td>";
echo "<td>" . $row['damageM'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Critical: </td>";
echo "<td>" . $row['critical'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Range Increment: </td>";
echo "<td>" . $row['rangeIncrement'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Weight: </td>";
echo "<td>" . $row['weight'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Weapon Type: </td>";
echo "<td>" . $row['weaponType'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Masterwork: </td>";
echo "<td>" . $row['masterwork'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Special Abilities: </td>";
echo "<td>" . $row['specialAbilities'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Additional Info: </td>";
echo "<td>" . $row['additionalInfo'] . "</td>";
echo "</tr>";
}
echo "</table>";
echo "</center>";
mysqli_close($con);
?>
I have a simple crud application where i am listing certain information . i need to create a filter on the basis of category but am getting an error.
I get the error:
Notice: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql_real_escape_string()' at line 1 in C:\wamp\www\media universe\list.php on line 6
Also tell me if I am going wrong with the filtering.
<?php
include('config.php');
$result = mysql_query("SELECT * FROM `media_universe`") or trigger_error(mysql_error());
if (isset($_POST['submitted_filter'])) {
$filter_category= $_POST[category_filter];
$result = mysql_query("SELECT * FROM `media_universe` where category= '%s',mysql_real_escape_string($filter_category)") or trigger_error(mysql_error());
}
?>
<form action='' method='POST'>
<p><b>Category:</b> <select name="category">
<option>All</option>
<option>Lifestyle</option>
<option>Automobiles</option>
<option>FoodandBeverage</option>
<option>Health</option>
<option>IT</option>
<option>Telecom</option>
<option>EntertainmentandCelebrity</option>
<option>Education</option>
<option>BankingInvestmentandInsurance</option>
<option>Travel</option>
<option>Sports</option>
<option>Parenting</option>
<option>ConsumerElectronics</option>
<option>RealtyandLogistics</option>
<option>CauseLed</option>
</select>
<p><input type='submit' value='Filter' /><input type='hidden' value='1' name='submitted_filter' />
</form>
<?php
include('config.php');
echo "<table border=1 >";
echo "<tr>";
echo "<td><b>Id</b></td>";
echo "<td><b>Category</b></td>";
echo "<td><b>Coursedetail</b></td>";
echo "<td><b>Nameofblog</b></td>";
echo "<td><b>Blogdescription</b></td>";
echo "<td><b>Nameofsocialnetworkiforkfac</b></td>";
echo "<td><b>Nameofsocialnetworkifnotorkfac</b></td>";
echo "<td><b>Nameofsocnetcommunity</b></td>";
echo "<td><b>Numberofmembersinsocnetcommunity</b></td>";
echo "<td><b>Nameofdiscussionforum</b></td>";
echo "<td><b>Descriptionofdiscussionforum</b></td>";
echo "<td><b>NameofQNAsite</b></td>";
echo "<td><b>Nameofnewssite</b></td>";
echo "<td><b>DescriptionofQNAsite</b></td>";
echo "</tr>";
while($row = mysql_fetch_array($result)){
foreach($row AS $key => $value) { $row[$key] = stripslashes($value); }
echo "<tr>";
echo "<td valign='top'>" . nl2br( $row['id']) . "</td>";
echo "<td valign='top'>" . nl2br( $row['category']) . "</td>";
echo "<td valign='top'>" . nl2br( $row['coursedetail']) . "</td>";
echo "<td valign='top'>" . nl2br( $row['nameofblog']) . "</td>";
echo "<td valign='top'>" . nl2br( $row['blogdescription']) . "</td>";
echo "<td valign='top'>" . nl2br( $row['nameofsocialnetworkiforkfac']) . "</td>";
echo "<td valign='top'>" . nl2br( $row['nameofsocialnetworkifnotorkfac']) . "</td>";
echo "<td valign='top'>" . nl2br( $row['nameofsocnetcommunity']) . "</td>";
echo "<td valign='top'>" . nl2br( $row['numberofmembersinsocnetcommunity']) . "</td>";
echo "<td valign='top'>" . nl2br( $row['nameofdiscussionforum']) . "</td>";
echo "<td valign='top'>" . nl2br( $row['descriptionofdiscussionforum']) . "</td>";
echo "<td valign='top'>" . nl2br( $row['nameofQNAsite']) . "</td>";
echo "<td valign='top'>" . nl2br( $row['nameofnewssite']) . "</td>";
echo "<td valign='top'>" . nl2br( $row['descriptionofQNAsite']) . "</td>";
echo "<td valign='top'><a href=edit.php?id={$row['id']}>Edit</a></td><td><a href=delete.php?id={$row['id']}>Delete</a></td> ";
echo "</tr>";
}
echo "</table>";
echo "<a href=new.php>New Row</a>";
?>
Your error, as the error message states, is here:
"SELECT * FROM `media_universe` where category='%s',mysql_real_escape_string($filter_category)"
You're constructing the string incorrectly. You were probably thinking of using sprintf, but didn't. This should do it:
"SELECT * FROM `media_universe` where category='" . mysql_real_escape_string($filter_category) . "'"