urtrivedi 276 Nearly a Posting Virtuoso
$strVarName = $key . "F";
echo $strVarName; //check what is the value of $strVarName, I am sure it is not "no preference"
urtrivedi 276 Nearly a Posting Virtuoso
urtrivedi 276 Nearly a Posting Virtuoso

first

$arrQueryParts[$key] = " " . ucwords($key) . "='" . mysql_real_escape_string($$strVarName) . "'";

have you intentionally placed $$strVarName


second

while($row = mysql_query($strQuery))
{

about code does not look valid

it should be like following

echo $strQuery;//copy the printed query from browser and run in phpmyadmin and see whether it gives expected result or not.

$result=mysql_query($strQuery));

while($row=mysql_fetch_assoc($result))
{
.
.
.
urtrivedi 276 Nearly a Posting Virtuoso
<select name = "fld_wherehear" id="fld_wherehear" >
					  <option value = "0" >Select...</option>
	<option value = "1" <?php echo (($_POST["fld_wherehear"]==1)?"selected":"") ;?> >Internet</option>
	<option value = "2" <?php echo (($_POST["fld_wherehear"]==2)?"selected":"") ;?>>Newsletter</option>
	<option value = "3" <?php echo (($_POST["fld_wherehear"]==3)?"selected":"") ;?>>Friend</option>
	<option value = "4" <?php echo (($_POST["fld_wherehear"]==4)?"selected":"") ;?>>Magazine</option>
	<option value = "5" <?php echo (($_POST["fld_wherehear"]==5)?"selected":"") ;?>>Other</option>
</select>
urtrivedi 276 Nearly a Posting Virtuoso

Somebody will only able to help you, if you do not post your code or sample here.
No body can visualize by just reading the statement.

urtrivedi 276 Nearly a Posting Virtuoso

http://www.apphp.com/php-datagrid/index.php?page=downloads

You may download and use free 4.2.8 version.

urtrivedi 276 Nearly a Posting Virtuoso

http://www.apphp.com/php-datagrid/index.php?page=downloads

You may download and use free 4.2.8 version.

urtrivedi 276 Nearly a Posting Virtuoso

Have you tried quotes around href

<a href='".$r1[10]."' target=_blank>View</a>

urtrivedi 276 Nearly a Posting Virtuoso

Warning is coming because you are using $qu before initializing it.

You may write follwoing statements to ignore error in page_edit_parse.

error_reporting(0);
ini_set("display_errors", 0);

urtrivedi 276 Nearly a Posting Virtuoso

following query is only for MSSQL. Also to update you must have some relation between the two table.

UPDATE tableA
    SET column_in_A = b.ColumninB
    FROM tableB b
    WHERE tableA.keycolumn1 = b.keycolumn1 and tableA.keycolumn2 = b.keycolumn2
urtrivedi 276 Nearly a Posting Virtuoso

suppose $catch_s= 'john'

so instr(members,'john') will return you position of 'john' in members column. if it finds john in members columns it will return non zero value, if it did not find john in member column it will return 0

if we found john in member column we set allowedit to 1 for that row, the row in which members do not have john it will set allowedit to 0,

this allowedit flag we can use in our php code to enable/disable html element or whatwever we want.

urtrivedi 276 Nearly a Posting Virtuoso

you may find thing in the sql query itself

$query="select assignment_id, assignment_name, members, remarks, 
if(  instr(members,'$catch_s')>0 , 1, 0 ) as allowedit 
from assignment_table";

.
.
..other code
.
.
.

if ( $myrow2['allowedit']=='1')
    echo "yes";
else 
    echo "no";
urtrivedi 276 Nearly a Posting Virtuoso

forget my preovis post

give only single dot instead of double dot

$this->Image('./images/gemsheader.png',10,8,190);

urtrivedi 276 Nearly a Posting Virtuoso

Your image directory structure must be like attached file

urtrivedi 276 Nearly a Posting Virtuoso

You must also use session_start() in your generatepdf.php before using session variable. (this is not something causing problem, it is addtional hint)

Now I never merge all folders in one following is my directory structure

webroot
|--myphpfiles(folder)
|--generatepdf.php
|--fpdf(folder)
|--fdpf_support_folders
|--fpdf.php

so when I refer fpdf in my generatepdf.php, i will write

require(../fpdf/fpdf.php)

Diretory structure is attached

Check how your files are stored

urtrivedi 276 Nearly a Posting Virtuoso

I THINK YOUR ORIGINAL QUESTION HAS NOTHING TO DO WITH SESSIONS.

Any how You must set and use session variables there is no link between post and session.


logincheck.php

<?php
session_start();
if($validuser) //check login details if valid then set session variables
{
   $_SESSION['username']=$loggeduser;//logged user may be userid, email or whatever you like to set.
   $_SESSION['on']="1";
   $_SESSION['xyz']="pqr";
}
?>

anyfile.php

<?php
session_start()
if(!$_SESSION['on'])  //if user not logged then send to login page
{
   header('location:login.php');
   exit;
}

echo "welcome {$_SESSION['username']}";
?>
urtrivedi 276 Nearly a Posting Virtuoso

add one more parameter to following function call

$pdf->Output("myfile.pdf",'D');

THIS WILL AUTOMATICALLY ASK USER TO SAVE/OPEN

urtrivedi 276 Nearly a Posting Virtuoso

I do not know how you want payretdate in query so I have not used it

urtrivedi 276 Nearly a Posting Virtuoso

check this query

SELECT  `SRNo` ,  `InvAmount` ,  `SubPayDate` ,  `PayRetDate` ,  `ResubPayDate` , 
CASE WHEN  `ResubPayDate` =  '0000-00-00'
THEN TO_DAYS( NOW( ) ) - TO_DAYS(  `SubPayDate` ) 
ELSE TO_DAYS( NOW( ) ) - TO_DAYS(  `ResubPayDate` ) 
END Days
FROM  `invmain` 
WHERE  `Status` =  'SENT TO PAYABLE'
AND  `SubPayDate` <>  '0000-00-00'
urtrivedi 276 Nearly a Posting Virtuoso

post your table structure, sample data and expected result from that data, do no post query.

urtrivedi 276 Nearly a Posting Virtuoso

whats new in your code akash

urtrivedi 276 Nearly a Posting Virtuoso

Search on excutescalar function.

.
.
.
.

qry1 = "select count (*) from mytable where mycolumn='myvalue'";
                SqlCommand cmd2 = new SqlCommand(qry1, cn);
               value= cmd2.ExecuteScalar();

' now repalce your ?????? with value below

.
.
.
.
.

qry = "insert into General values(@Gno,@GRno,@Fname,@Mname,@Lname,@Sex,@Bdate,@Pass,@Mono,@OtherNo,@Photo,@Role,@GCID)";

SqlCommand cmd2 = new SqlCommand(qry, cn);
cmd.Parameters.AddWithValue("@Gno",value );
cmd.Parameters.AddWithValue("@GRno", TxtAddress.Text);
cmd.Parameters.AddWithValue("@Fname", RadioButtonList1.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Mname", DrpDwnDD.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Lname", DrpDwnMM.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Sex", DrpDwnYY.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Bdate", TxtUserName.Text);
cmd.Parameters.AddWithValue("@Pass", TxtPassword.Text);
cmd.Parameters.AddWithValue("@Mono", TxtEmail.Text);
cmd.Parameters.AddWithValue("@OtherNo", DrpDwnCountry.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Photo", "~/Photo/" + FileUpload1.FileName);
cmd.Parameters.AddWithValue("@Role", DroDpwnPerque.SelectedItem.Text);
cmd.Parameters.AddWithValue("@GCID", TxtAns.Text);
FileUpload1.SaveAs(Server.MapPath("~/Photo/" + FileUpload1.FileName));
cmd.ExecuteNonQuery();

urtrivedi 276 Nearly a Posting Virtuoso

you must pass database name also

$conn=oci_connect("sysdba", "hammad90", $databasename);

urtrivedi 276 Nearly a Posting Virtuoso
<?php

$result=mysql_query("SELECT transtech, blkidfp00,SUM(g.pop) popsum, SUM(g.hu) sumhu, SUM(g.busfirms) sumbusfirms FROM wi_allbcdata g 
			WHERE g.fips='$countyfips' 
			AND (g.transtech=10 OR g.transtech=30 )
			GROUP BY transtech, blkidfp00");
?>
urtrivedi 276 Nearly a Posting Virtuoso

you continue with
php only, do not give any parameter,

then completing creating task, right cick on it and open properties

you will find RUN BOX "C:\Program Files\PHP\php.exe"

CHANGE IT TO (give appropriate path)

"C:\Program Files\PHP\php.exe" "C:\WEBROOT\YOURFOLDER\YOURREPORT\report1.php"

urtrivedi 276 Nearly a Posting Virtuoso

Kindly try on phpmailer forum, I am not sure about the error.

urtrivedi 276 Nearly a Posting Virtuoso

give whole path of your script

php c:\mywebroot\myfolder\myreport\report1.php

urtrivedi 276 Nearly a Posting Virtuoso

For cc on your own you may try

$mail->addCustomHeader("Cc: {$yourccmailid1},{$yourccmailid2}");

urtrivedi 276 Nearly a Posting Virtuoso

I am not sure about the ADD CC Function. Because I directly send mail, means I do not use class.

Now about automation of mail
So I explained in my post that on widows server, You can add scedule task.
Search microsoft site for details.

Cron are genrally utility for linux server cron (linux), schedule task (windows).
Cron commands will not work on windows.

Now you use file search facility of windows. in xamapp folder there might be php folder where you can find php.exe, locate php exe in your computer, I am sure you will find it.

urtrivedi 276 Nearly a Posting Virtuoso

if you have access to windows server.
You can create schedule task.
Accessories->system tools->schedule task
create new task
When it ask for application.
1) browse to php folder and select php.exe
2) then give space and give full path of report1.php
3) set time

repeat 1-3 steps for other reports.

urtrivedi 276 Nearly a Posting Virtuoso

<?php
<img src='<?php echo "http://".$_SERVER["HTTP_HOST"]."/yourfolder/images/phpmailer.gif" ?>' style='height: 90px; width: 340px'>

?>

urtrivedi 276 Nearly a Posting Virtuoso

file_get_contents('contents.php'); will only read php file it will not execute php code.

urtrivedi 276 Nearly a Posting Virtuoso

Try with php_curl
You must enable php_curl on your server.

then write following function in your smtpauth.php

<?php
function my_curl($url,$rethdr=0)
{
	$ch = curl_init();
	curl_setopt ($ch, CURLOPT_URL, $url);
	curl_setopt ($ch, CURLOPT_HEADER, $rethdr);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$res=curl_exec($ch);	
	return $res;
}
?>

$body=my_curl('http://localhost/yourfolder/contents.php',1);

I hope this will work

urtrivedi 276 Nearly a Posting Virtuoso

What output you are getting

urtrivedi 276 Nearly a Posting Virtuoso

CHANGE MY LINE NO 21 OF PREVIOUS POST LIKE GIVEN BeLOW, remove or then write AND

$operator=" and ";

urtrivedi 276 Nearly a Posting Virtuoso
<?php 		

$_POST['keywords']="aaa    ccc";

for($i=0;$i<10;$i++)
	$_POST['keywords']=str_replace("  "," ",$_POST['keywords']);

$arrkey=explode(" ",trim($_POST['keywords']));	


$query="select * from product where somecol='somevalue' ";

$keycount=count($arrkey);
if($keycount>0 and trim($_POST['keywords'])!="")
{
	$query.=" and (";
	$operator="";
	for($i=0;$i<$keycount;$i++)
	{
		$query.=$operator."(product_name like '%{$arrkey[$i]}%')";
		$operator=" or ";		
	}
	$query.=")";
}
echo $query;

?>
urtrivedi 276 Nearly a Posting Virtuoso

I think ajax would be better option for you.
You may try xajax libraries for easy integration.

urtrivedi 276 Nearly a Posting Virtuoso

no need to union

select * from dbo.T_JOBS where (STATUS = 'Failed' or ENDDATEANDTIME = NULL)
urtrivedi 276 Nearly a Posting Virtuoso

query with where will sumup only those rows which are displayed, it will not sum up rows filtered by where condition. you have to take care in your php code.

urtrivedi 276 Nearly a Posting Virtuoso
SELECT YEAR, SUM(profit) profit FROM sales 
where year>2000
GROUP BY YEAR WITH ROLLUP
urtrivedi 276 Nearly a Posting Virtuoso

I am not able to understand your requirement, though you have tried your best to explain.
So I am giving one mysql syntax (found in mysql manual) that will add the sum at the end with null description.

SELECT year, SUM(profit) profit FROM sales GROUP BY year WITH ROLLUP;

year, profit
-------------
2001,60000
2002,50000
null,110000

I hope this is what you are looking for.

urtrivedi 276 Nearly a Posting Virtuoso

this is the final one.

select a.id, a.username, a.id_status,sum(a.won) won, sum(a.void) void, sum(a.lost) lost
from (
select Users.id, Users.Username, User_status.id_status,
case when Analysis.status_name='Won' then 1 else 0 end won,
case when Analysis.status_name='Void' then 1 else 0 end void,
case when Analysis.status_name='Lost' then 1 else 0 end lost,
@row := case when @prevuser=Users.Username then @row + 1 else 1 end as rownum,
@prevuser:=Users.Username FROM Users left outer join (SELECT @row := 0, @prevuser:=null ) r on @row=@row
INNER JOIN User_status ON Users.User_status_name=User_status.user_status
left outer JOIN Analysis ON Users.Username=Analysis.Tipster
WHERE User_status.id_status>=3
order by Users.Username, Analysis.date
)  a where a.rownum <=20 GROUP BY a.id, a.Username, a.id_status;
urtrivedi 276 Nearly a Posting Virtuoso

I was expecting sql script not a pdf file. so that i can create same environment as you are having. to find the syntax error. also send 3rd tables that u use in your query.

urtrivedi 276 Nearly a Posting Virtuoso

I have no clue about xampp. what i used to do was
I opened my php.ini file enabled curl by adding following line with other extension, save the file

extension=php_curl.dll

Then i ensured that this file is there in php/extensions/ folder
restarted apache
and thats it

But as i told u in my previous post, even after writing a code you will not able to access that website, because they are not allowing.

urtrivedi 276 Nearly a Posting Virtuoso

try to run internal query first and have a look. make syntax correct, then try whole query. if you still not able to run then attacht script of database and data for thest two tables i will run it here.

select Users.id, Users.Username, User_status.id_status,
 case when Analysis.status_name='Won' then 1 else 0 end won,
case when Analysis.status_name='Void' then 1 else 0 end void,
case when Analysis.status_name='Lost' then 1 else 0 end lost,
@row := case when @prevuser=Users.Username then @row + 1 else 1 end as rownum,
@prevuser:=Users.Username 
FROM Users,(SELECT @row := 0, @prevuser:=null ) r  
INNER JOIN User_status ON Users.User_status_name=User_status.user_status
left outer JOIN Analysis ON Users.Username=Analysis.Tipster 
WHERE User_status.id_status>=3
order by Users.Username, Analysis.Tipster date

(SELECT @row := 0, @prevuser:=null ) r
this is used to initialise two variables @row and @prevuser


@row := case when @prevuser=Users.Username then @row + 1 else 1 end as rownum
with every row i m trying to generate sr no for each user of if. its a first row compare my prevauser variable with username in table if both are same then add one to srno. if username in prev row and current row is different then reset srno to 1 for new user.

@prevuser:=Users.Username
save current username to our prevuser variable to compare in next row.

result of inner query will be like following

id, username, id_status, won, void, lost, rownum
1, abc, xyz, 1,0,0, 1
1, abc, xyz, 0,1,0, 2
1, abc, xyz, …

urtrivedi 276 Nearly a Posting Virtuoso

WITHOUT CURL

$handle = fopen("http://www.mepco.com.pk/ls/ConsumerLoadShedding.asp?SDiv=5124&off=Shah Rukn-e-Alam Sub Division", "rb");
$contents = stream_get_contents($handle);
fclose($handle);
echo $contents;

or WITH CURL

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, "http://www.mepco.com.pk/ls/ConsumerLoadShedding.asp?SDiv=5124&off=Shah Rukn-e-Alam Sub Division");
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);	
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_MAXREDIRS, 10);	

$res=curl_exec($ch);
echo $res;

Actually I was trying above code for your site. They have prohibited such access. its giving me following message.

Your page is blocked due to a security policy that prohibits access to Category default

urtrivedi 276 Nearly a Posting Virtuoso

you need to enable php_curl.dll extention

urtrivedi 276 Nearly a Posting Virtuoso

I will write steps to follow for completing the job. You may have to learn certain things before starting from manauls and tutorials

1) You must have substation database with id and name at your server where u are going to write a script
2) write a script fetch subsation list from database and go through them one by one using loop.
3) in loop you have write open url using curl and you have to pass substation id. curl will return you the page soucre in your variable.
4) you have to extract table data and save it in some text file with appropriate file name.

ayesha789 commented: Great post +1
urtrivedi 276 Nearly a Posting Virtuoso

is it working on phpmyadmin directly. please check whether there is a syntax error.

urtrivedi 276 Nearly a Posting Virtuoso

you need to learn curl.