I am trying to access this weapon store file and am getting a blank page. I was hoping someone could help me fix this. The link.php file is just a page holding images and is not the source of the problem as other pages calling on link work fine.
<?php
echo "<table width='100%'><tr><td valign='left' width='95%'><font size=2 color=silver><b>Weapon Market</b></font></td><td><table width=100%><tr><td align=right>";
include('../beta/files/link.php');
echo" Weapon Market. Users can come here to buy weapons that they can to to another city and sell at a black market for profit.'></a></td></tr></table><img src='/beta/layout_images/headertop.gif' width=100% height=4></center><br /><br />";
if(!isset($tools)){
echo"<font color=red><b>Error | It Seems Something Went Wrong Processing Your Account. Please Try Logging Out And Then Logging Back In. If The Problem Persists Please Email Support At Account#Steam-Wars.com. We Apologize For The Inconvenience.</b></font><br /><br /><center><img src='/beta/layout_images/headertop.gif' width=100% height=4></center><br />";
session_destroy();
exit();}
$qry = 'SELECT * FROM weapons WHERE uid='.db_quote_smart($player->uid);
$res = db_query($qry);
$has_weapons_array = mysql_fetch_array($res);
$weapon_names = array('bbgun_bullet', 'handgun_bullet', 'shotgun_bullet', 'rifle_bullet', 'bbgun', 'handgun', 'shotgun', 'ak47', 'bomb', 'taser', 'baseballbat', 'shank', 'detonator', 'battery');
$name_hash = array(
'bbgun_bullet' => 'BBGun Bullet (4-9)',
'handgun_bullet' => 'Handgun Bullet (9-47)',
'shotgun_bullet' => 'Shotgun Bullet (28,142)',
'rifle_bullet' => 'Rifle Bullet (47-237)',
'bbgun' => 'BBGun (280-300)',
'handgun' => 'Handgun (470-500)',
'shotgun' => 'Shotgun (96-100)',
'ak47' => 'AK47 (415-500)',
'bomb' => 'Bomb (248-250)',
'taser' => 'Taser (45-50)',
'baseballbat' => 'Baseball Bat (90-100)',
'shank' => 'Shank (55-100)',
'detonator' => 'Detonator (427-475)',
'battery' => 'Battery (3-9)'
);
$qry = 'SELECT * FROM prices_booze WHERE city='.db_quote_smart($player->city);
$res = db_query($qry);
$prices = mysql_fetch_array($res);
$qry = 'SELECT * FROM weapons WHERE uid='.db_quote_smart($player->uid);
$res = db_query($qry);
$weapons = mysql_fetch_array($res);
$limit = $has_weapons_array["weapon_limit"];
$space_used = 0;
foreach($weapon_names as $name){
$space_used += $weapons[$name];
}
$space_left = $limit - $space_used;
$action = $_GVARS['action'];
if( $action == 'buy' ){
foreach($weapon_names as $weapon){
$price = $prices[$weapon];
$amount = (isset($_POST[$weapon]) ? intval($_POST[$weapon]) : 0);
$cost = $price * $amount;
if( $amount > 0 ){
if( $gUser['cash'] < $cost ){
echo"<font color=red><b>Error | You Do Not Have Enough Money To Purchase $amount unit(s) Of $weapon.</b></font><br /><br /><center><img src='/beta/layout_images/headertop.gif' width=100% height=4></center><br />";
}elseif( ($space_left-$amount) < 0 ){
echo"<font color=red><b>Error | You Do Not Have Enough Space To Carry $amount unit(s) Of $weapon.</b></font><br /><br /><center><img src='/beta/layout_images/headertop.gif' width=100% height=4></center><br />";
}else{
$space_left -= $amount;
$gUser['cash'] -= $cost;
$qry = 'UPDATE user_characters SET cash=cash-'.$cost.' WHERE uid='.db_quote_smart($player->uid);
$res = db_query($qry);
$randscam = mt_rand(1, 100);
$randscam2 = mt_rand(1, 100);
if( $randscam == $randscam2 ){
echo"<font color=red><b>Error | You Were Scammed By A Dealer. The Weapons You Bought Turned Out To Be Replicas.</b></font><br /><br /><center><img src='/beta/layout_images/headertop.gif' width=100% height=4></center><br />";
$randexp=rand(0,1);
$qry = 'UPDATE user_characters SET exp=exp+'.$randexp.', drug_points=drug_points+'.$amount.' WHERE uid='.db_quote_smart($player->uid);
$res = db_query($qry);
}else{
$qry = "UPDATE weapons SET $weapon=$weapon+$amount WHERE uid=".db_quote_smart($player->uid);
$res = db_query($qry);
$randexp2=rand(1,2);
$qry = 'UPDATE user_characters SET exp=exp+'.$randexp2.', drug_points=drug_points+'.$amount.' WHERE uid='.db_quote_smart($player->uid);
$res = db_query($qry);
$sql="UPDATE adv_stats SET drugs_bought=drugs_bought+$amount WHERE uid=".db_quote_smart($player->uid);
$sql=mysql_query($sql);
echo"<font color=green><b>Ciao | You Have Purchased $amount Crate(s) Of $weapon.</b></font><br /><br /><center><img src='/beta/layout_images/headertop.gif' width=100% height=4></center><br />";
}
}
}
}
}
// gets updated version of weapons in pocket
$qry = 'SELECT * FROM weapons WHERE uid='.db_quote_smart($player->uid);
$res = db_query($qry);
$has_weapons_array = mysql_fetch_array($res);
echo "<table align=center width=100% bgcolor=000000><tr><td><br>";
echo "<table width='450' cellpadding='0' border='2' bordercolor='black' style='margin:0 auto;background-image: url(/beta/layout_images/bg_2.gif);'>
<tr bgcolor=#11111>
<td align=center>
<font face=verdana size=1 color=silver><b>Weapon</b></font>
</td>
<td align=center>
<font face=verdana size=1 color=silver><b>Cost</b></font>
</td>
<td align=center>
<font face=verdana size=1 color=silver><b># you have</b></font>
</td>
<td align=center>
<font face=verdana size=1 color=silver><b># to buy</b></font>
</td>
</tr>";
$space_used = 0;
$row = 0;
foreach($weapon_names as $weapon){
$space_used += $has_weapons_array[$weapon];
echo('<tr bgcolor="#'.($row++ % 2 ? '444444' : '333333').'">
<td align="center" width="125"><font face="tahoma" size="1" color="#ffffff"><b>'.$name_hash[$weapon].'</b></td>
<td align="center" width="125"><font face="tahoma" size="1" color="#ffffff">$ '.number_format($prices[$weapon]).'</font></td>
<td align="center" width="125"><font face="tahoma" size="1" color="#ffffff">'.number_format($has_weapons_array[$weapon]).'</font></td>
<td align="center" width="125"><font face="tahoma" size="1" color="#ffffff"><form name="login" action="driver.php?x=weaponstore" method="post"><input type="text" name="'.$weapon.'" size=5 style="font-weight:none;font-size:8pt;color:#ffffff;font-family:arial;background-color:#000000;border-color:#ffffff" maxlength="15"></font></td>
</tr>');
echo "
</table>
<table width='450' cellpadding='0' border='2' bordercolor='black' style='margin:0 auto;background-image: url(/beta/layout_images/bg_2.gif);'>
<tr bgcolor=#11111 valign=top><td>
<table width=100%><tr>
<td align=left width=125><font face=verdana size=1 color=silver><input type=radio checked name=action value=buy> Buy </td>
<td align=center width=250><font size=1><font color=#FFFFFF><b>Weapon space:</b></font> " . $space_used . "/" . $has_weapons_array["weapon_limit"] . "</font></td>
<td align=right width=125><center><font face=verdana size=1 color=silver><input type=submit value=\" Purchase Weapon \" style=\"FONT-WEIGHT: bold; FONT-SIZE: 8pt; COLOR: #FFFFFF; FONT-FAMILY: Arial; BACKGROUND-COLOR: #333333\" size=1></center></td>
</tr></table>
</td></tr>
</table>";
?>
This question was answered by me and you deleted it...
As I said before there is no end bracket in last foreach !
foreach($weapon_names as $weapon){
$space_used += $has_weapons_array[$weapon];
echo('<tr bgcolor="#'.($row++ % 2 ? '444444' : '333333').'">
<td align="center" width="125"><font face="tahoma" size="1" color="#ffffff"><b>'.$name_hash[$weapon].'</b></td>
<td align="center" width="125"><font face="tahoma" size="1" color="#ffffff">$ '.number_format($prices[$weapon]).'</font></td>
<td align="center" width="125"><font face="tahoma" size="1" color="#ffffff">'.number_format($has_weapons_array[$weapon]).'</font></td>
<td align="center" width="125"><font face="tahoma" size="1" color="#ffffff"><form name="login" action="driver.php?x=weaponstore" method="post"><input type="text" name="'.$weapon.'" size=5 style="font-weight:none;font-size:8pt;color:#ffffff;font-family:arial;background-color:#000000;border-color:#ffffff" maxlength="15"></font></td>
</tr>');
}
Related
I am a back end dev for a WordPress website: https://westtechshipping.com.
The admin side is where the majority of our time is spent. We deal with packages ordered by our customers and deliver them. I have a system put in place where you upload a .csv file and the PHP function reads the contents of the .csv, then updates the data into the database, then sends out an email to our clients.
Over time we realized that we cannot do a .csv upload with more than 30 entries because we would get errors like this one
I took this image from google images because I cannot recreate the error at the moment due to the time of this post, but the error is similar.
We also sometimes get a page that says this
We've tried many things and are not sure what the issue is. These hiccups cause our data to be uploaded twice and multiple emails to be sent out to each client.
We have spoken to our server hosting, go daddy, and followed their recommendations of editing our user.ini accordingly.
This are our PHP settings from our user.ini
If this is an issue with the code, below is the current code for our .csv upload feature.
if(isset($_POST["submitcsv"])) // Upload Package Amount CSV File
{
$file = $_FILES['file']['tmp_name'];
$handle = fopen($file, "r");
$c = 0;
$c2 = 0;
$row = 1;
while(($filesop = fgetcsv($handle, 1000, ",")) !== false)// What?
{
$Name = $filesop[0];
$AccID = $filesop[1];
$Freight = $filesop[2];
$Handling = $filesop[3];
$Consolidation = $filesop[4];
$Duty = $filesop[5];
$VTax = $filesop[6];
$Delivery = $filesop[7];
$Insurance = $filesop[8];
$Amount = $filesop[9];
$Statuscsv = $filesop[10];
$Pickup = $filesop[11];
$trackingnumber =$filesop[12];
if($row == 1) { $row++; continue;}
$num = count($filesop);
//Separating First name
$First_Name = substr($Name,0,strrpos($Name,' '));
if(strrpos($Name, ' ')!== false){
$First_Name = $First_Name;
}else{
$First_Name = $Name;
}
//Getting rid of blank costs
if(empty($Freight)){$Freight = "0";}
if(empty($Handling) ){$Handling = "0";}
if(empty($Consolidation)){$Consolidation = "0";}
if(empty($Duty) ){$Duty = "0";}
if(empty($VTax) ){$VTax = "0";}
if(empty($Delivery)){$Delivery = "0";}
if(empty($Insurance)){$Insurance = "0";}
if(empty($Amount)){$Amount = "0";}
//$pkg = get_packages_query($trackingnumber);
//$pkginv = get_invoices_by_trackingid($trackingnumber);
$userID = explode('WT100',$AccID);
$userdata = get_userdata( $userID[1] );
$site_name = get_bloginfo('name');
$messageinv = " <style>
#media screen (max-width:768px) { /* smartphones, iPhone, portrait 480x320 phones */
#packagetable{
margin-left:20px;
}
}
</style>
<div style='font-size:15px;'>
<strong> Dear ".$First_Name."</strong>, <br><br>
".$site_name." has a package available for you. You can come in to collect during our working hours of Monday- Friday 8AM to 5PM and Saturdays 9AM to 1PM.
</div>
<br><br>
<table id='packagetable' style='border:1px solid #8EAADB; margin-left:150px;'>
<tr class ='invhead' style='background-color:#4472C4; color:white;'>
<th>Charges</th>
<th>Amount (EC)</th>
</tr>
<tr class ='2ndtr' >
<td > Tracking Number </td>
<td> ".$trackingnumber."</td>
</tr>
<tr class ='1str' style='background-color:#D9E2F3; '>
<td > Shipping Charge: </td>
<td> $".$Freight." </td>
</tr>
<tr class ='2ndtr' >
<td > Duty Charge: </td>
<td> $".$Duty."</td>
</tr>
<tr class ='1str' style='background-color:#D9E2F3; '>
<td > Handling Fee: </td>
<td> $".$Handling." </td>
</tr>
<tr class ='2ndtr' >
<td > Consolidation Fee: </td>
<td> $".$Consolidation." </td>
</tr>
<tr class ='1str' style='background-color:#D9E2F3; '>
<td > Delivery Fee: </td>
<td> $".$Delivery." </td>
</tr>
<tr class ='2ndtr' >
<td > <strong>Total Amount: </strong> </td>
<td><strong>$".$Amount."</strong> </td>
</tr>
</table>
<div>
<br><br>
Thanks for using our service! We appreciate it.
<br><br>
Regards,<br>
".$site_name."
<br>______________________________________________________<br><br>
<strong>Call Us</strong><br><br>
<strong>Rodney Bay</strong>: 458-9378 <strong>Castries</strong>: 451-9378 <strong>Vieux Fort</strong>: 454-9378
</div>
";
$messageinvadmin .=
" <style>
#media screen (max-width:768px) { /* smartphones, iPhone, portrait 480x320 phones */
#packagetable{
margin-left:20px;
}
}
</style>
<div><strong>".$Name."</strong> with email address ".$userdata->data->user_email.", had an invoice update. <br><br>
View the changes below
</div>
<br><br>
<table id='packagetable' style='border:1px solid #8EAADB; margin-left:150px;'>
<tr class ='invhead' style='background-color:#4472C4; color:white;'>
<th>Charges</th>
<th>Amount (EC)</th>
</tr>
<tr class ='2ndtr' >
<td > Tracking Number </td>
<td> ".$trackingnumber."</td>
</tr>
<tr class ='1str' style='background-color:#D9E2F3; '>
<td > Shipping Charge: </td>
<td> $".$Freight." </td>
</tr>
<tr class ='2ndtr' >
<td > Duty Charge: </td>
<td> $".$Duty."</td>
</tr>
<tr class ='1str' style='background-color:#D9E2F3; '>
<td > Handling Fee: </td>
<td> $".$Handling." </td>
</tr>
<tr class ='2ndtr' >
<td > Consolidation Fee: </td>
<td> $".$Consolidation." </td>
</tr>
<tr class ='1str' style='background-color:#D9E2F3; '>
<td > Delivery Fee: </td>
<td> $".$Delivery." </td>
</tr>
<tr class ='2ndtr' >
<td > <strong>Total Amount: </strong> </td>
<td><strong>$".$Amount."</strong> </td>
</tr>
<tr class ='1str' style='background-color:#D9E2F3; '>
<td > Delivery Fee: </td>
<td> $".$Delivery." </td>
</tr>
</table>
_______________________________________________________
<br><br>
";
$closing = "Regards,<br>
".$site_name."
<br>______________________________________________________<br><br>
<strong>Call Us</strong><br><br>
<strong>Rodney Bay</strong>: 458-9378 <strong>Castries</strong>: 451-9378 <strong>Vieux Fort</strong>: 454-9378
</div>
";
$invtotalsql = mysql_fetch_assoc(mysql_query("SELECT invoice_total_charges FROM wp_xq4w067xaq_customer_invoice WHERE invoice_tracking_number = '$trackingnumber'"));
$packstatsql = mysql_fetch_assoc(mysql_query("SELECT pms_status FROM wp_xq4w067xaq_package WHERE tracking_id = '$trackingnumber'"));
if($Statuscsv == "Collected & Paid"){
$Statuscsv = 5;
}if($Statuscsv == "Available for Pick-Up"){
$Statuscsv = 4;
}if($Statuscsv == "Pending Invoice"){
$Statuscsv = 3;
}if($Statuscsv == "Paid"){
$Statuscsv = 7;
}if($Statuscsv == "Collected"){
$Statuscsv = 9;
}if($Statuscsv == "Shipped"){
$Statuscsv = 2;
}if($Statuscsv == "Received"){
$Statuscsv = 1;
}
if($invtotalsql['invoice_total_charges'] !== $Amount OR $packstatsql['pms_status'] !== $Statuscsv){
send_email_pkg2($userdata->data->user_email, $messageinv, $site_name. ' Package Amount Update',$userdata->user_email_2,$userdata->user_email_3);
//send_email_pkg("shipping#westtg.com", $messageinvadmin, $site_name. "Package Amount update");
//send_email_pkg("5sp4lr9#gmail.com", $messageinvadmin, $site_name. "Invoices");
//send_email_pkg("5sp4lr9#gmail.com", $message3, $site_name. "Minimum Invoices");
}
$sql = "UPDATE wp_xq4w067xaq_package SET pms_full_name='$Name',pms_status='$Statuscsv',pms_amount_owned='$Amount',pms_pickup='$Pickup' WHERE tracking_id='$trackingnumber'";
mysql_query($sql);
$c = $c + 1; // count number of package info updated
$sql2 = "UPDATE wp_xq4w067xaq_customer_invoice SET invoice_shipping_charge='$Freight',invoice_handling_fee='$Handling',invoice_consolidation_fee='$Consolidation',invoice_duty_charge='$Duty',invoice_added_tax='$Vtax',invoice_delivery_fee='$Delivery',invoice_insurance='$Insurance',invoice_total_charges='$Amount' WHERE invoice_tracking_number='$trackingnumber'";
mysql_query($sql2);
$c2 = $c2 + 1; // count number of invoices updated
//update_invoice2();
}
$finaladmin = $messageinvadmin.$closing;
send_email_pkg("shipping#westtg.com", $finaladmin, $site_name. "Package Amount update");
// Success OR Error Message
if($sql AND $sql2){
echo "Your database has imported successfully. You have inserted ". $c ." records in packages and ".$c2." records in invoices";
}else{
echo "Sorry! There is some problem.";
}
}
my problem may be easy for experienced users, but I'm stucked on it. So, here's the problem. I have submit buttons in while loop, they draw, but they don't react on click. Here's my piece of code.
`<?php
$zap_cmember = count_query("SELECT * FROM `users` WHERE `clan` = '".$member['id']."' AND clan_stat != 'Призывник'");
while ($cmember = mysql_fetch_array($zap_cmember))
{
$zap_gold = mysql_result(mysql_query("SELECT SUM(gold) FROM klog WHERE name = '".$cmember['name']."'"), 0);
$zap_online = mysql_num_rows(count_query("SELECT * FROM `online` WHERE `id_session`='".$cmember['id_user']."'"));
if ($zap_online > 0)
{
$img_on = "<td align='center' valign='middle' ><img src='images/ico_online.png' alt='онлайн' class='png' ></td>";
}
else
{
$img_on = "<td align='center' valign='middle' ><img src='images/ico_offline.png' alt='оффлайн' class='png' ></td>";
}
$i = 'set';
echo '<tr>
<td width="141" height="25" align="left" valign="middle" >'.$cmember['name'].' ['.lvl($cmember['exp']).']</td>
<td align="center" valign="middle" ><span class="text_main_4">'.$cmember['clan_stat'].'</span></td>
<td align="center" valign="middle" ><span class="text_main_4">-</span></td>
<td align="center" valign="middle" ><span class="text_main_4">'.$zap_gold.'</span></td>
<td align="center" valign="middle" ><span class="text_main_4">'.$cmember['glory'].'</span></td>
'.$img_on.'';
if($boss)
{echo '<td align="center" id = "'.$i.'" valign="middle"><input type="submit" name="bSet" value="Назначить"></span></td>'; }
$i++;
$player = $cmember;
'</tr>';
if (isset($_POST['bSet']))
{
echo 'works';
count_query("UPDATE users SET clan_stat='Вождь' WHERE id_user='".$player['id_user']."'");
$time = date('j.n.y H:i');
count_query("INSERT INTO `message` (`time`, `to`, `text`, `metka`) VALUES ('".$time."', '".$player['name']."', 'Вас выбрали главой клана <a href=clan.php>".$clan['name']."</a>', '6')");
echo "<script>location.href='clan.php'</script>";
}
}
?>
`
You need to put everything that you want to submit to a <form id="yid">... </form>, after that to put on the button the onclick="javascript:$('#yid').submit()" and the yid= the particular id of the form you want the button to submit.
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.
in this edit file i have to choose the same picture file or another picture file to be able update the rows. but i want to be able to change whichever i want without touching the other rows. any ideas over here?
<?php
include('../config.php');
include ('../ac.thumbs.php');
if ($_GET['sil']) {
$sil = htmlspecialchars(stripslashes($_GET['sil']));
mysql_query("DELETE FROM CloseOut WHERE itemNO = $sil limit 1");
echo "<h1>$sil item nolu kayit silinmistir</h1><br>";
}
$edit = htmlspecialchars(stripslashes($_GET['edit']));
$data = mysql_query("SELECT * FROM CloseOut WHERE itemNO=$edit") or die(mysql_error());
//Puts it into an array
while($info = mysql_fetch_array( $data ))
{ echo "
<center>
[ Delete ]<br>
<a href=../../large.php?f=upload/".$info['resim'], $thumblarge .">
<img src=../../small.php?f=upload/".$info['resim'], $thumbsmall .">
</a>";
$editresim = $info[resim];
$editisim = $info[isim];
$editalan1 = $info[alan1];
$editalan2 = $info[alan2];
$editalan3 = $info[alan3];
$editalan4 = $info[alan4];
}
//Resimlerin yuklenecegin yer
$target = "../../upload/";
//////////////////////////////////////////////////////////////////////
///////////////////////////////Resim1/////////////////////////////////
//////////////////////////////////////////////////////////////////////
$target1 = $target . basename( $_FILES['resim1']['name']) ;
//Formdan gelen bilgileri almasi icin
$resim=($_FILES['resim1']['name']);
$isim=$_POST['isim1'];
$alan1=$_POST['alan11'];
$alan2=$_POST['alan21'];
$alan3=$_POST['alan31'];
$alan4=$_POST['alan41'];
/////////////Formdaki bos alanlara bos bilgi kayit etmemesi icin////////////////////////
$updates = array();
if (!empty($resim))
$updates[] = 'resim="'.mysql_real_escape_string($resim).'"';
if (!empty($isim))
$updates[] = 'isim="'.mysql_real_escape_string($isim).'"';
if (!empty($alan1))
$updates[] = 'alan1="'.mysql_real_escape_string($alan1).'"';
if (!empty($alan2))
$updates[] = 'alan2="'.mysql_real_escape_string($alan2).'"';
if (!empty($alan3))
$updates[] = 'alan3="'.mysql_real_escape_string($alan3).'"';
if (!empty($alan4))
$updates[] = 'alan4="'.mysql_real_escape_string($alan4).'"';
$updates = implode(', ', $updates);
/////////////////////////////////////////////////////////////////////////////////////////
//update etmesi icin
if(move_uploaded_file($_FILES['resim1']['tmp_name'], $target1))
{
mysql_query("UPDATE CloseOut SET $updates WHERE itemNO='$edit' ");
echo "Tebrikler, ". basename( $_FILES['resim1']['name']). " isimli dosya yuklendi ve database'e basariyla islendi!<br>";
}
?>
<br>
<center>
<table width="900" border="5" style="background-color:white; "bordercolor="#000000">
<tr>
<td width="120" height="50" bgcolor= "545454"><b>RESIM</b></td>
<td width="120" height="50" bgcolor= "545454"><b>NAME</b></td>
<td width="120" height="50" bgcolor= "545454"><b>CATAGORY</b></td>
<td width="120" height="50" bgcolor= "545454"><b>QUANTITY</b></td>
<td width="120" height="50" bgcolor= "545454"><b>LOCATION</b></td>
<td width="120" height="50" bgcolor= "545454"><b>PRICE</b></td>
</tr>
<tr>
<form enctype="multipart/form-data" method="post" action="">
<td><input type="file" name="resim1" value="<?php echo $editresim;?>"> </td>
<td><input type="text" name="isim1" value="<?php echo $editisim;?>"> </td>
<td><input type="text" name="alan11" value="<?php echo $editalan1;?>"> </td>
<td><input type="text" name="alan21" value="<?php echo $editalan2;?>"> </td>
<td><input type="text" name="alan31" value="<?php echo $editalan3;?>"></td>
<td><input type="text" name="alan41" value="<?php echo $editalan4;?>"></td>
</tr>
<td colspan="5"><center><input type="submit"></center></td>
</form>
</table>
</center>
Hello i have a table with some fields like
here i want make colors for table entire rows..means if ASR value is 75 to 100 should get one color and 50 to 75 should get another color and below 50 should get another color.
and here is my php code
<table width="75%" border="1">
<tr>
<td align="center">channel no</td>
<td align="center">IP</td>
<td align="center">Total calls</td>
<td align="center">Connected calls</td>
<td align="center">Disconnected calls</td>
<td align="center">Duration</td>
<td align="center">ASR</td>
<td align="center">ACD</td>
</tr>
<?php
while ($row = mysql_fetch_assoc($result)) {
//$minutes = gmdate("H:i:s", $row['tduration']);
echo "<tr>
<td>".$row['channel']." </td>
<td>".$row['ip']." </td>
<td>".$row['totalcalls']." </td>";
if ($row['totalcalls']>1){
$sql1 = "SELECT count(duration) as count FROM gateways where duration=0 and ip='".$_POST['ip']."' and channel='".$row['channel']. "' and (connect_datetime BETWEEN ' ".$_POST['toval']." ' and '".$_POST['fromval']."' or disconnect_datetime BETWEEN ' ".$_POST['toval']." ' and '".$_POST['fromval']."' ) Group by channel";
$result1 = mysql_query($sql1, $link);
$norow=mysql_fetch_assoc($result1);
$attenedcalls=($row['totalcalls']-$norow['count']);
echo "<td>".$attenedcalls." </td>";
$disconnectedcalls=($row['totalcalls']-$attenedcalls);
echo "<td>".$disconnectedcalls." </td>";
echo " <td>".$row['tduration']." </td>";
echo "<td>".(($attenedcalls/$row['totalcalls'])*100)."</td>";
}else{
echo "<td>".$row['totalcalls']."</td>";
echo "<td>100</td>";
}
$minutes = gmdate("H:i:s", ($row['tduration']/$attenedcalls));
echo " <td>".$minutes." </td>
</tr>";
}
?>
</table>
thanks in advance
You can try like this
<table width="75%" border="1">
<tr>
<td align="center">channel no</td>
<td align="center">IP</td>
<td align="center">Total calls</td>
<td align="center">Connected calls</td>
<td align="center">Disconnected calls</td>
<td align="center">Duration</td>
<td align="center">ASR</td>
<td align="center">ACD</td>
</tr>
<?php
while ($row = mysql_fetch_assoc($result)) {
$color = '';
if ($row['totalcalls']>1){
$sql1 = "SELECT count(duration) as count FROM gateways where duration=0 and ip='".$_POST['ip']."' and channel='".$row['channel']. "' and (connect_datetime BETWEEN ' ".$_POST['toval']." ' and '".$_POST['fromval']."' or disconnect_datetime BETWEEN ' ".$_POST['toval']." ' and '".$_POST['fromval']."' ) Group by channel";
$result1 = mysql_query($sql1, $link);
$norow=mysql_fetch_assoc($result1);
$attenedcalls=($row['totalcalls']-$norow['count']);
$asr = (($attenedcalls/$row['totalcalls'])*100);
if($asr >= 75 && $asr <=100 ){
$color = 'red';
}else if($asr >= 50 && $asr < 75){
$color = 'cyan';
}else if($asr < 50){
$color = 'blue';
}
}
//$minutes = gmdate("H:i:s", $row['tduration']);
echo "<tr style='background-color : ".$color."'>
<td>".$row['channel']." </td>
<td>".$row['ip']." </td>
<td>".$row['totalcalls']." </td>";
if ($row['totalcalls']>1){
echo "<td>".$attenedcalls." </td>";
$disconnectedcalls=($row['totalcalls']-$attenedcalls);
echo "<td>".$disconnectedcalls." </td>";
echo " <td>".$row['tduration']." </td>";
echo "<td>".$asr."</td>";
}else{
echo "<td>".$row['totalcalls']."</td>";
echo "<td>100</td>";
}
$minutes = gmdate("H:i:s", ($row['tduration']/$attenedcalls));
echo " <td>".$minutes." </td>
</tr>";
}
?>
</table>
[...]
while ($row = mysql_fetch_assoc($result)) {
$asrVal=(($attenedcalls/$row['totalcalls'])*100);
if($asrVal>=50 && $asrVal <=75) $class="from50to75";
if($asrVal>=75 && $asrVal <=100) $class="from75to100";
if($asrVal<50) $class="below50";
//$minutes = gmdate("H:i:s", $row['tduration']);
echo "<tr class='$class'>
[...]
then add:
<style>
tr.from50to75 td{background-color:red;}
tr.from75to100 td{background-color:green;}
tr.below50 td{background-color:blue;}
</style>
Modify your while loop so that you compute the ASR value before emitting the <tr> tag. Use that value to select a class according to the classification you have set up, and emit a tag of the form <tr class=foo> where foo is the class name you have selected. Then it’s just a matter of writing CSS rules for the classes, using class selectors like tr.foo.
(Provided that you have not set color on the td cells. If you have, you need to use selectors like tr.foo td to override such settings.)