28, May 2012

set item as completed - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: set item as completed
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: set item as completed  (Read 814 times)
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« on: Aug 26, 2006, 09:00:53 pm »

trying to make it so i can set these things to do as completed by clicking a link.. im pretty sure i have done most of it right and it says taht it successfully marked it as complete, but it doesnt. thing_status stays at 0 when it should be 1:

list of things with link to complete it

Code:
<?php
echo "<center>";

$result2 dbquery("SELECT * FROM fusion_things2do_cats ORDER BY cat_id");
while (
$data2 dbarray($result2))
{
   $result dbquery("SELECT * FROM fusion_things2do WHERE thing_cat = " $data2['cat_id']);
   while ($data dbarray($result))
   {
echo $data['thing_id'];
echo ". <b>".$data['thing_name']."</b><br>";
echo "<i>Item Category: ".$data2['cat_name']."</i><br>";
echo $data['thing_description']; 
echo "<br><br>";
if ($data['thing_status'] == 0){
echo "[<a href='done_thing.php".$aidlink."&amp;cmd=completed&amp;thing_id=".$data['thing_id']."'>Mark As Completed</a>]<br><hr width='30%'><br>";
} else { 
echo "<font color='yellow' weight='bold'>Item Completed.</font><br><hr width='30%'><br>"
}
}
}
echo 
"</center>";
?>


this is the page that performs the complete command

Code:
<?php
require_once "../maincore.php";
require_once 
BASEDIR."subheader.php";
require_once 
ADMIN."navigation.php";

if (!
checkrights("KA") || !defined("iAUTH") || $aid != iAUTHfallback("../index.php");
opentable('Set Thing to Do as Complete');

if(
$_GET["cmd"]=="completed")
{
$getcompleted mysql_query("SELECT * from fusion_things2do order by thing_id asc"); 
while(
$data mysql_fetch_array($getcompleted)) 

if(!isset($cmd)) 
{
$result mysql_query("UPDATE fusion_things2do SET thing_status = 1 WHERE thing_id = " $data['thing_id']); 
while($r=mysql_fetch_array($result)) 

$thing_id=$r['thing_id'];
     }
}
}
    $sql "SELECt * FROM fusion_things2do WHERE thing_id=$thing_id";
    $result mysql_query($sql);
    echo "<center>Thing to Do has been marked as completed!<br><br>Click [<a href='".BASEDIR."administration/things_todo.php".$aidlink."'>here</a>] to return to the Things to Do.</center>";
}
closetable();


require_once 
BASEDIR."footer.php";
?>


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Aug 26, 2006, 09:05:31 pm »

In a first sight, I think this line has the problem :

if(!isset($cmd))

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #2 on: Aug 26, 2006, 09:10:50 pm »

what is wrong with it Shocked i use similair approach to delete a thing to do and it works fine


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #3 on: Aug 26, 2006, 09:14:33 pm »

The $cmd variable is not seted anywhere.

So is allways false => so it will never execute the UPDATE sql statement.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #4 on: Aug 26, 2006, 09:22:59 pm »

how do i fix this problem Shocked im totally confused once again


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #5 on: Aug 26, 2006, 09:27:06 pm »

I guess if you just remove this if statement it will work Smiley

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #6 on: Aug 26, 2006, 09:35:03 pm »

when i run it, it sets all things to status 1, when it should only set the thing that i clicked on to 1..

Code:
<?php
require_once "../maincore.php";
require_once 
BASEDIR."subheader.php";
require_once 
ADMIN."navigation.php";

if (!
checkrights("KA") || !defined("iAUTH") || $aid != iAUTHfallback("../index.php");
opentable('Set Thing to Do as Complete');

if(
$_GET["cmd"]=="completed")
{
$getcompleted mysql_query("SELECT * from fusion_things2do order by thing_id asc"); 
while(
$data mysql_fetch_array($getcompleted)) 

//if(!isset($cmd)) 
//{
$result dbquery("UPDATE fusion_things2do SET thing_status = 1 WHERE thing_id = " $data['thing_id']); 
while($r=dbarray($result)) 

$thing_id=$r['thing_id'];
     }
//}
}
    
$sql "SELECt * FROM fusion_things2do WHERE thing_id=$thing_id";
    
$result mysql_query($sql);
    echo 
"<center>Thing to Do has been marked as completed!<br><br>Click [<a href='".BASEDIR."administration/things_todo.php".$aidlink."'>here</a>] to return to the Things to Do.</center>";
}
closetable();


require_once 
BASEDIR."footer.php";
?>


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #7 on: Aug 26, 2006, 09:37:54 pm »

Then propably the whole thing is wrong.

You shouldn't do anyother query except something like this :

$result = dbquery("UPDATE fusion_things2do SET thing_status = 1 WHERE thing_id = " . $_POST['id']);

where $_POST['id'] supposed to be the user you clicked on.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=3839
Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: set item as completed
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 03:20:36 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.