Not getting second Fetch - php

Hey everyone I have been trying to figure this out for a while and just cant get around while its not showing the second fetch where weaponF is,
<?php
session_start();
if(!$_SESSION['logged']){
header("Location: login_page.php");
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<style type="text/css">
div {
position: relative;
left: 5px;
top: 25px;
width: 280px;
padding: 10px;
color: black;
display: none;
}
</style>
<script language="JavaScript">
function setVisibility(id1,id2,id3) {
if(document.getElementById('bt1').value=='H'){
document.getElementById('bt1').value = 'S';
document.getElementById(id1).style.display = 'none';
document.getElementById(id2).style.display = 'none';
document.getElementById(id3).style.display = 'none';
}else{
document.getElementById('bt1').value = 'H';
document.getElementById(id1).style.display = 'inline';
document.getElementById(id2).style.display = 'inline';
document.getElementById(id3).style.display = 'inline';
}
}
function setvisibility(id4){
if(document.getElementById('bt2').value=='HP'){
document.getElementById('bt2').value = 'SP';
document.getElementById('id4').style.display = 'none';
}else{
document.getElementById('bt2').value = 'HP';
document.getElementById('id4').style.display = 'inline';
}
}
function setvisibility(id5){
if(document.getElementById('bt3').value=='HC'){
document.getElementById('bt3').value = 'SC';
document.getElementById('id5').style.display = 'none';
}else{
document.getElementById('bt3').value = 'HC';
document.getElementById('id5').style.display = 'inline';
}
}
function setvisibility(id6){
if(document.getElementById('bt4').value=='HM'){
document.getElementById('bt4').value = 'SM';
document.getElementById('id6').style.display = 'none';
}else{
document.getElementById('bt4').value = 'HM';
document.getElementById('id6').style.display = 'inline';
}
}
function setvisibility(id7){
if(document.getElementById('bt5').value=='HI'){
document.getElementById('bt5').value = 'SI';
document.getElementById('id7').style.display = 'none';
}else{
document.getElementById('bt5').value = 'HI';
document.getElementById('id7').style.display = 'inline';
}
}
</script>
<body>
<center>
<?php
$con=mysqli_connect(secret);
$validUser = mysqli_real_escape_string($con, $_SESSION['username']);
$result = mysqli_query($con, "SELECT level, exp, maxexp, str, dex, inte, sta, crit, hp, atk, def, dfire, dwater, dposion, atkfire, atkwater, atkposion, weapon FROM users WHERE username = '$validUser'");
$data = mysqli_fetch_array($result,MYSQLI_ASSOC);
$weapon = $data['weapon'];
$weaponQ = mysqli_query($con, "SELECT * FROM equipment WHERE wname= '$weapon'") or die(mysqli_error($con));
$weaponF = mysqli_fetch_array($weaponQ,MYSQLI_ASSOC);
mysqli_close($con);
?>
<body><center>
<table border="1">
<td>Level:<?php echo $data['level']; ?></td>
<td
<?php if ($data['exp'] == $data['maxexp']) {
echo "bgcolor = white";
}
else
{
echo "bgcolor = white";
}
?>
>Exp:<?php echo $data['exp']; ?>/<?php echo $data['maxexp']; ?></td>
<td>Str:<?php echo $data['str']; ?></td>
<td>Dex:<?php echo $data['dex']; ?></td>
<td>Int:<?php echo $data['inte']; ?></td>
<td>Stam:<?php echo $data['sta']; ?></td>
<td>Crit:<?php echo $data['crit']; ?>%</td>
</table>
<?php
if ($data['exp'] == $data['maxexp']) {
echo "<a href='levelup.php'>Level up </a>";
}
else
{
echo "";
}
?>
</center>
<table border="1" align="left">
<tr>
<td>
<a onclick="setVisibility('sub3','sub4','sub5');" id="bt1" href="#">Explore</a><br /><br />
<a onclick="setVisibility('sub6');" id="bt4" href="#">Market</a><br /><br />
<a onclick="setVisibility('sub1');" id="bt2" href="#">Profile</a><br /><br />
<a onclick="setVisibility('sub2');" id="bt3" href="#">Casino</a><br /><br />
<a onclick="setVisibility('sub7');" id="bt5" href="#">Inventory</a><br /><br />
Logout
</td>
</tr>
</table>
<br />
<div id="sub3" align="center">Map</div>
<br><br><br><br><br>
<div id="sub4" align="center">Arrows</div>
<div id="sub5" align="center">Mobs</div>
<div id="sub1" align="center">
<table border="1" align="center">
<td>
<?php
echo "<font size='+2'>Base Stats</font>";
echo "<br><br>";
echo "Str: ";
echo $data['str'];
echo "<br>";
echo "Dex: ";
echo $data['dex'];
echo "<br>";
echo "Int: ";
echo $data['inte'];
echo "<br>";
echo "Stam: ";
echo $data['sta'];
echo "<br>";
echo "Crit: ";
echo $data['crit'];
echo "%";
echo "<br>";
echo "Atk: ";
echo $data['atk'];
echo "<br>";
echo "Def: ";
echo $data['def'];
echo "<br><br>";
echo "<font size='+2'>Bonus Atk</font>";
echo "<br><br>";
echo "Atk Fire: ";
echo $data['atkfire'];
echo "%";
echo "<br>";
echo "Atk Water: ";
echo $data['atkwater'];
echo "%";
echo "<br>";
echo "Atk Posion: ";
echo $data['atkposion'];
echo "%";
echo "<br><br>";
echo "<font size='+2'>Bonus Res</font>";
echo "<br><br>";
echo "Def Fire: ";
echo $data['dfire'];
echo "%";
echo "<br>";
echo "Def Water: ";
echo $data['dwater'];
echo "%";
echo "<br>";
echo "Def Posion: ";
echo $data['dposion'];
echo "%";
?>
</td>
</table>
</div>
<div id="sub2" align="center">Casino</div>
<div id="sub6" align="center">Market</div>
<div id="sub7" align="center">
<table border="1" bordercolor="white">
<tr>
<td bordercolor="white" height="50px" width="50px"></td>
<td width="50px" height="50px" bordercolor="black">
Head
</td>
</tr><br />
<tr>
<td width="50px" height="50px" bordercolor="black">
<img onmouseover="<?php echo $weaponF['name']; ?>" src="equipment/<?php echo $data['weapon']; ?>.png" />
</td>
<td width="50px" height="50px" bordercolor="black">
Chest
</td>
<td width="50px" height="50px" bordercolor="black">
RightArm
</td>
</tr>
<tr>
<td bordercolor="white" height="50px" width="50px">
</td>
<td bordercolor="black" height="50px" width="50px">
Pants
</td>
</tr>
<tr>
<td bordercolor="white" height="50px" width="50px">
</td>
<td bordercolor="black" height="50px" width="50px">
Shoes
</td>
</tr>
</table>
</div>
<?php echo $data['weapon'];
echo $weaponF['wname']; ?>
</body>
It dose not show any errors or faults, Please help haha here is all my code make it easier to view and help I hope lol

i think username and name is your table columns so try
$validUser = mysqli_real_escape_string($con, $_SESSION['username']);
mysqli_query("SELECT * FROM users WHERE username ='$validUser' LIMIT 1");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con, "SELECT level, exp, maxexp, str, dex, inte, sta, crit, hp, atk, def, dfire, dwater, dposion, atkfire, atkwater, atkposion, weapon FROM users WHERE username = '$validUser'");
$data = mysqli_fetch_array($result,MYSQLI_ASSOC);
$weapon = $data['weapon'];
$weaponQ = mysqli_query($con, "SELECT * FROM equipment WHERE wname= '$weapon'") or die(mysqli_error($con));
if(mysqli_num_rows($weaponQ) > 0) {
$weaponF = mysqli_fetch_array($weaponQ,MYSQLI_ASSOC);
}
else {
echo 'No rows found';
}
mysqli_close($con);
and also there is no work of below query so you can remove this:-
mysqli_query("SELECT * FROM users WHERE username ='$validUser' LIMIT 1");

Related

Adding an upload feature blocked my multiple deletion

Multiple deletion used to work just fine before adding the upload page and condition
am sure the problem comes from a in one of the echo's
I didn't manage to figure out a way to get them both working at the same time.
You can check by yourself here: agencedevoyages.tk
Enter the
email: abc#gmail.com
Password: 2
You'll notice that upload does work and multiple deletion doesn't work anymore
Code:
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Accueil</title>
</head>
<body>
<?php
if(isset($_SESSION['email']) AND isset($_SESSION['password']))
{
echo "<b>Welcome ".$_SESSION['prenom']." ".$_SESSION['nom']." !";
echo "<div align='right'><a align='right' href='deconnect.php'><button type='button'>Se déconnecter</button></a></div>";
?>
<table border="1" align="center">
<caption><b><h1>La liste des étudiants</h1></caption>
<tr><td align="center"><b>Photo</td>
<td align="center"><b>Matricule</td>
<td align="center"><b>Nom</td>
<td align="center"><b>Prénom</td>
<td align="center"><b>Adress</td>
<td align="center"><b>Birthday</td>
<td align="center"><b>E-mail</td>
<td align="center" colspan="2"><b>Option</td>
<td align="center"><b>Multiple Deletion</td>
<td align="center"><b>Upload</td></tr>
<?php
include 'connect.php';
$sql = "SELECT * FROM etudiant";
$res = mysqli_query($connect, $sql);
if (mysqli_num_rows($res)>0){
while($row = mysqli_fetch_assoc($res))
{
echo "<tr><td>";
?>
<?php
if(empty($row['photo']))
{
?>
<img src='photos/image.jpg' width="100" height="100">
<?php
}
else
{
?>
<img src='photos/<?php echo $row['photo'] ?>' width="100" height="100">
<?php
}
echo "</td>";
echo "<td align='center'>".$row['matricule']."</td>";
echo "<td align='center'>".$row['nom']."</td>";
echo "<td align='center'>".$row['prenom']."</td>";
echo "<td align='center'>".$row['adresse']."</td>";
echo "<td align='center'>".$row['date_naissance']."</td>";
echo "<td align='center'>".$row['email']."</td>";
if($_SESSION['email']==$row['email'] OR $_SESSION['email']=='abc#gmail.com')
{
echo "<td><a href='modif.php?id=".$row['id']."'><button type='button'>Edit</button></a></td>";
echo "<td><a href='supp.php?id=".$row['id']."'><button type='button'>Delete</button></a></td>";
echo "<td align='center'><form method='post' action='supp3.php'><input type='checkbox' name='sup[]' value='".$row['id']."'></form></td>";
echo "<td align='center'><form method='post' action='upload.php' enctype='multipart/form-data'><input type='file' name='fichier'><input type='submit' value='Confirm'></td><input type='hidden' name='id' value='".$row['id']."'></td></tr>";
}
}
echo "<tr><td colspan='9'></td><td colspan='1' align='center'><button>Multiple Deletion</button></td></tr></form>";
}
else
{
echo "<tr><td colspan ='10' align='center'>No users.</td></tr>";
$sql = "TRUNCATE etudiant";
$res = mysqli_query($connect, $sql);
}
?>
</table>
<p align="center"><button>Add a user</button></p>
<?php
}
else
{
echo "<div align='center'><b><h1>Not allowed.";
echo "<br><a href='index.php'><button type='button'>Back</button></a></div>";
}
?>
</body>
</html>

php ajax multiple data requests

I have problem with getting multiple data with ajax.
I have cart and if I add (+) more quantity then it crashes, with one data parameter it works correctly, but if I try multiple it gives wierd big number.
If im not using VAT + Total cost then it works, but if I use VAT + total I get multiple dot numbers..
Example: 251.52254.5141.92 // without VAT and Total cost price is 251,52 (251.52 254.51 41.92)
Example2: 262264.9943.6666666667 // added one qty more..
<div class="table-content table-responsive mb-50">
<table class="text-center">
<thead>
<tr>
<th class="product-thumbnail">Product</th>
<th class="product-price">Price</th>
<th class="product-quantity">QTY</th>
<th class="product-subtotal">subtotal</th>
<th class="product-remove">RMV</th>
</tr>
</thead>
<tbody>
<tr id="row<?php echo $i;?>">
<td class="product-thumbnail">
<div class="pro-thumbnail-img">
<img width="75" src="<?php echo "$baseurl/productimages/$ppp[img]";?>" alt="<?php echo $ppp['name']; ?>">
</div>
<div class="pro-thumbnail-info text-left">
<h6 class="product-title-2">
<?php echo $ppp['name'];?>
</h6>
<p>Brand: <?php echo $subcat['name']; ?></p>
</div>
</td>
<td class="product-price"><?php echo number_format(round($data['rraate'], 2), 2) . " " . $curr['currency']; ?></td>
<td class="product-quantity">
<button id="btnminus<?php echo $i;?>" onClick="var result = document.getElementById('qty<?php echo $i;?>'); var qty<?php echo $i;?> = result.value; if( !isNaN( qty<?php echo $i;?> ) && qty<?php echo $i;?> > <?php echo $ppp['minbuy']; ?> ) result.value--;return false;" class="reduced items-count" typy="button"><i class="zmdi zmdi-minus"> </i></button>
<input type="text" id="qty<?php echo $i;?>" class="input-text qty" title="Qty" value="<?php echo $data['qty']; ?>" min="<?php echo $ppp['minbuy']; ?>" maxlength="12" id="qty<?php echo $i;?>" name="qty" style="display:inline-block; width: 70px;">
<button id="btnplus<?php echo $i;?>" onClick="var result = document.getElementById('qty<?php echo $i;?>'); var qty<?php echo $i;?> = result.value; if( !isNaN( qty<?php echo $i;?> )) result.value++;return false;" class="increase items-count" type="button"><i class="zmdi zmdi-plus"> </i></button>
</td>
<input type="hidden" id="id" name="id" value="<?php echo $iidd; ?>">
<input type="hidden" id="unique" name="unique" value="<?php echo $unique; ?>">
<td class="product-subtotal" id="chk<?php echo $i;?>"><?php echo $ttl . " " . $curr['currency']; ?></td> <!-- subtotal id -->
<td class="product-remove">
<a id="btnrmv<?php echo $i;?>" href="#" title="Eemalda toode"><i class="zmdi zmdi-close"></i></a>
</td>
</tr>
</tbody>
</table>
</div>
<div class="row">
<div class="col-md-6 pull-right">
<div class="payment-details box-shadow p-30 mb-50">
<h6 class="widget-title border-left mb-20">Payment</h6>
<table>
<tr>
<td class="td-title-1">Delivery price</td>
<td class="td-title-2"><?php echo $tarne . " " . $curr['currency']; ?></td>
</tr>
<tr>
<td class="td-title-1">VAT(20%)</td>
<td class="td-title-2" id="km<?php echo $i;?>"><?php echo $km . " " . $curr['currency']; ?></td> <!-- VAT id -->
</tr>
<tr>
<td class="order-total">Total</td>
<td class="order-total-price" id="sum<?php echo $i;?>"><?php echo $sum . " " . $curr['currency']; ?></td> <!-- SUM id -->
</tr>
</table>
</div>
</div>
</div>
Ajax:
$(document).ready(function() {
$("#btnplus<?php echo $i;?>").click(function() {
$.post("<?php echo $baseurl;?>/api-cart-update.php",{
unique: "<?php echo $unique;?>",
cccid: "<?php echo $data['id'];?>",
act: "plus"
},
function(data) {
$('#chk<?php echo $i;?>').html(data);
$('#sum<?php echo $i;?>').html(data);
$('#km<?php echo $i;?>').html(data);
});
});
$("#btnminus<?php echo $i;?>").click(function() {
$.post("<?php echo $baseurl;?>/api-cart-update.php",{
unique: "<?php echo $unique;?>",
cccid: "<?php echo $data['id'];?>",
act: "minus"
},
function(data) {
$('#chk<?php echo $i;?>').html(data);
$('#sum<?php echo $i;?>').html(data);
$('#km<?php echo $i;?>').html(data);
});
});
});
api-cart-update.php:
require_once('function.php');
if(isset($_POST['unique'])) {
$un = $_POST["unique"];
$act = $_POST["act"];
try{
$database = new Connection();
$db = $database->openConnection();
$sql = "SELECT code FROM carrrt WHERE id = :cccid";
$qry1 = $db->prepare($sql);
$qry1 -> bindParam(':cccid', $_POST["cccid"], PDO::PARAM_INT);
$qry1 -> execute();
$security = $qry1->fetch(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
echo "There is some problem in connection: " . $e->getMessage();
}
if($security['code']==$un){
try{
$database = new Connection();
$db = $database->openConnection();
$sql= "SELECT qty, rraate FROM carrrt WHERE id = :cccid";
$qry = $db->prepare($sql);
$qry -> bindParam(':cccid', $_POST["cccid"], PDO::PARAM_INT);
$qry -> execute();
$qnow = $qry->fetch(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
echo "There is some problem in connection: " . $e->getMessage();
}
$sum=0;
$tarne=2.99;
if($act=="plus"){
$will = $qnow['qty']+1;
}else{
$will = $qnow['qty']-1;
}
if($will<=1){
$will=1;
}
try{
$database = new Connection();
$db = $database->openConnection();
$sql = "UPDATE carrrt SET qty = :qty WHERE id = :cccid";
$stmt = $db->prepare($sql);
$stmt->bindParam(':cccid', $_POST['cccid'], PDO::PARAM_INT);
$stmt->bindParam(':qty', $will, PDO::PARAM_INT);
$stmt -> execute();
} catch (PDOException $e) {
echo "There is some problem in connection: " . $e->getMessage();
}
$subttl = $qnow['rraate']*$will;
$sum += $subttl + $tarne;
$vat = 20;
$vatDivisor = 1 + ($vat / 100);
$priceBeforeVat = $subttl / $vatDivisor;
$km = $subttl - $priceBeforeVat;
if($stmt){
echo "$subttl";
echo "$sum";
echo "$km";
}
}
}
Try this:
$.ajax({
url: 'YOUR URL',
type: 'post',
dataType: 'json',
data: {
'POST1': 'variable',
'POST2': 'variable'
},
success: function(data) {
alert(data.array1);
}
});
And on your PHP file
if (isset($_POST['POST1'])) {
//'DO SOME THING';
json_encode(array(array1=>'bla bla',array2=>'ble ble'));
}

Viewing queried data from mysql database in a table

I am attempting to update the code for my web page's search function, right now it is not returning anything. I have been working with it for a little while and not getting anything out of it.
This is the HTML search code:
<form method="post" action="words_results1.php">
<table align="center">
<tr>
<td>Keyword</td>
<td><input type="text" name="Keyword" /></td>
</tr>
<tr>
<td>Author</td>
<td><input type="text" name="Author" /></td>
</tr>
<tr>
<td valign=bottom>Words Posted<BR />on or before</td>
<td valign=top>
<table>
<tr>
<td width="33%">Day</td>
<td width="33%">Month</td>
<td width="34%">Year</td>
</tr>
<tr>
<td>
<select name=Day>
<?php
echo '<option></option>';
for($count = 1; $count <= 31; ++$count)
{
echo "<option>$count</option>";
}
?>
</select>
</td>
<td>
<select name=Month>
<?php
echo '<option></option>';
for($count = 1; $count <= 12; $count++)
{
echo "<option value=$count>".date("M", mktime(0,0,0,$count,1, 2000))."</option>";
}
?>
</select>
</td>
<td>
<select name=Year>
<?php
echo '<option></option>';
for($count = date("Y"); $count >= 1997; $count--)
{
echo "<option>$count</option>";
}
?>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan=2 align=center>
<BR />
<input type="submit" value="Search" />
<input type="submit" name="cancel" value="Cancel" />
</td>
</tr>
</table>
</form>
PHP
<?php
if(isset($_POST['cancel']))
{
echo("index.html");
exit;
}
$qry_string = "SELECT * FROM Words";
$search = "";
if(!empty($Keyword))
{
$End_String = "(Word LIKE '%$Keyword%' OR Title LIKE '%$Keyword%')";
$search .="&Keyword=$Keyword";
}
if(!empty($Author))
{
if(isset($End_String))
{
$End_String .= " AND (Author LIKE '%$Author%')";
}
else
{
$End_String = "(Author LIKE '%$Author%')";
}
$search .="&Author=$Author";
}
if(!empty($Day))
{
if(isset($End_String))
{
$End_String .= " AND (DAYOFMONTH(Date_Created) = '$Day')";
}
else
{
$End_String = "(DAYOFMONTH(Date_Created) = '$Day')";
}
$search .="&Day=$Day";
}
if(!empty($Month))
{
if(isset($End_String))
{
$End_String .= "AND (MONTH(Date_Created) = '$Month')";
}
else
{
$End_String = "(MONTH(Date_Created) = '$Month')";
}
$search .="&Month=$Month";
}
if(!empty($Year))
{
if(isset($End_String))
{
$End_String .= " AND (YEAR(Date_Created) = '$Year')";
}
else
{
$End_String = "(YEAR(Date_Created) = '$Year')";
}
$search .="&Year=$Year";
}
if (!isset($offset)) $offset=0;
if(isset($End_String))
{
$qry_string = $qry_string." WHERE ".$End_String . " ORDER BY Date_Created DESC LIMIT $offset,101";
}
else
{
$qry_string = $qry_string." ORDER BY Date_Created DESC LIMIT $offset,101";
}
// echo $qry_string . "<P><HR><P>";
$result = mysql_query($qry_string);
echo mysql_error();
?>
This last bit is the code that forms the table, I have an assumption that the problem lies here but honestly am not sure at this point
<table style="margin: 5px 15px; 5px 20px;" align="center" bgcolor="#666666" border="0" cellpadding="3" cellspacing="1">
<tbody><tr style="background: #04C1DE; font-family: Verdana; font-weight: bold; font-size: 18px;">
<td style="width: 50%; padding: 5px;">
Word
</td>
<td style="width: 20%; padding: 5px;">
Author
</td>
<td style="width: 10%; padding: 5px;">
Date
</td>
<td>Category</td>
<td>Active?</td>
<td> </td>
<td> </td>
</tr>
</tbody>
</tr>
<?php
$count = 1;
$bgc = 0;
while($row = mysql_fetch_array($sql))
{
if ($count > 100) break;
echo '<tr style="background: ';
if ($bgc==0) echo "#FFFFFF";
else echo "#CFEBFD";
$bgc == 0?$bgc=1:$bgc=0;
echo ';">';
echo "<td><a href=../../words/display_word.php?ID=$row[ID]>$row[Title]</a></td>";
echo "<td>$row[Author]</td><td>$row[Display_Date]</td><td>$row[category]</td>";
if($row[active])
{
echo "<td>YES</td>";
}
else
{
echo "<td>NO</td>";
}
echo "<td>$row[link_count]</td>";
if($row[Title] != "")
{
echo "<td><a href=words_edit.html?ID=$row[ID]>Edit</a></td></tr>";
}
else
{
echo "</tr>";
}
$count++;
}
?>
It seems,you are not collecting the value of
$Keyword=$_POST['Keyword'];
and add ,closing table tag to display the results in the table format correctly.

Make 4 columns in my while loop

Below is my while loop table, currently it's showing just one item per row. I can't seem to figure out how to get 4 items/columns to show before it shows a new row below. Any help with this would be much appreciated, thank you!
Jerome
<table style="background-color: white">
<?php
while ($row = mysql_fetch_array($rs)) {
?>
Collapse | Copy Code
<tr <?php //if ($i % 2) echo ' style="background-color: #ECECFB;"';?>>
<td class="rows"><font color="4D4D4D" size="3"><? echo '<a type="video/x-matroska" href=file://///'.$row["Link"].' target=blank>'.$row["Name"].'</a>' ?><br />
<? echo '<a type="video/x-matroska" href=file://///'.$row["Link"].' target=blank><img src='.$row["Picture"].' height=210px width=141px></a>' ?><br />
<? echo '('.$row["Type"].')' ?> <? echo $row["Year"] ?> <? echo $row["Rating"] ?> <? echo date('H:i', mktime(0,$row["Length"])); ?><br />
<? echo $row["Genre"] ?><br />
<? if ($row["Queue"]==='x') {
echo
"<center><a title=Remove From Watch List href='deletequeue.php?id=".$row['ID']."'><img align='center' width='20px' src='http://www.ourlittlelucas.net/ourflix/images/Minus.png'></a></td></font></center>";
}
else {
echo "<center><a title=Add To Watch List href='addqueue.php?id=".$row['ID']."'><img align='center' width='20px' src='http://www.ourlittlelucas.net/ourflix/images/Plus.png'></a></td></font></center>";
}
?>
</td></tr></font>
<?php $i++?>
<?php
}
?>
</table>
Try it
<table style="background-color: white">
<?php
while ($row = mysql_fetch_array($rs))
{
?>
Collapse | Copy Code
<tr <?php //if ($i % 2) echo ' style="background-color: #ECECFB;"';?>>
<td class="rows">
<font color="4D4D4D" size="3"><?php echo '<a type="video/x-matroska" href=file://///'.$row["Link"].' target=blank>'.$row["Name"].'</a>'; ?><br />
<?php echo '<a type="video/x-matroska" href=file://///'.$row["Link"].' target=blank><img src='.$row["Picture"].' height=210px width=141px></a>'; ?><br />
<?php echo '('.$row["Type"].')' ?>
<?php echo $row["Year"] ;?>
<?php echo $row["Rating"]; ?>
<?php echo date('H:i', mktime(0,$row["Length"])); ?><br />
<?php echo $row["Genre"] ;?><br />
<?php
if ($row["Queue"]=="x") {
echo
"<center><a title=Remove From Watch List href='deletequeue.php?id=".$row['ID']."'><img align='center' width='20px' src='http://www.ourlittlelucas.net/ourflix/images/Minus.png'></a></td></font></center>";
}
else
{
echo "<center><a title=Add To Watch List href='addqueue.php?id=".$row['ID']."'><img align='center' width='20px' src='http://www.ourlittlelucas.net/ourflix/images/Plus.png'></a></td></font></center>";
}
?>
</td></tr></font>
<?php $i++?>
<?php
}
?>
</table>

how to show specific value from table column and update column

I have built a web page that updates the status to either active, inactive or "NA".
"N/A" = 0
active = 1
inactive = -1
This all works fine
These are therefore inserted into database: 1, 0 and -1
Now i want to make a update page that only shows inactive values, in other words, only shows -1
Now I want to update this like I have inserted it on the insert page
if($_REQUEST['update']=="Yes")
{
if($_GET['status']==-1){
$update = mysql_query("update causelist set msg=0 where id='".$_GET['uid']."'");
}elseif($_GET['status']==1){
$update = mysql_query("update causelist set msg=-1, where id='".$_GET['uid']."'");
}elseif($_GET['status']==0){
$update = mysql_query("update causelist set msg=1 where id='".$_GET['uid']."'");
}
}
?>
<table width="100%" style="table-layout:fixed;">
<tbody>
<?php
$query = mysql_query("select * from causelist where CaseType='A'");
while($res= mysql_fetch_array($query))
{ ?>
<tr >
<td class="blueh" width="5px" style="height:40px;">
<?php echo $res['SNo']; ?>
</td>
<td class="purpleh" width="25px" style="height:40px;">
<font size="3" style="color:black;line-height:100%;font-family:'Calibri';">
<?php echo $res['CaseNo']; ?>
</font>
</td>
<td class="purpleh" width="25px" style=" width=20px;height:40px;">
<font size="3" style="color:black;line-height:100%;font-family:'Calibri';">
<?php echo $res['CouncilName']; ?>
</font>
</td>
<td class= "purpleh" width="25px" style="width=20px;height:40px;">
<font size="3" style="color:black;line-height:100%;font-family:'Calibri';">
<?php echo $res['resadv']; ?>
</font>
</td>
<td class="redh" width="3px" style=";line- height:50%;">
<?php if($res['msg']==1)
{
//echo "Active";
echo "<img src='images/r.png'/>";
}
elseif($res['msg']==-1)
{
//echo "Inactive";
echo "<img src='images/take.png'/>";
}
elseif($res['msg']==0)
{
//echo "NA";
echo "<img src='images/none.png'/>";
} ?></td>
<td class="redh" width="3px" style="center;height:5px;line-height:50%;">
<a href="case.php?uid=<?php echo $res['id']; ?>&update=Yes&status=
<?php echo $res['msg']; ? >">
<img src="images/p2.png"/></a></td>
</tr>
<?php }}?>
</tbody>
</table>

Categories