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.

urtrivedi 276 Nearly a Posting Virtuoso

and two forieng keys to your deal table
Lawyerid, organizationid
and one more say deal_fees

So you deal will be like
dealid, lawyerid,orgniszationid, deal_fees and other columns

urtrivedi 276 Nearly a Posting Virtuoso

This is most complex query. I hope this is what you are looking for.

select a.id, a.username, a.id_status,sum(a.won) won, sum(a.void) void, sum(a.lost) lost

(

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

) a
where a.rownum <=20
GROUP BY a.id, a.Username, a.id_status
urtrivedi 276 Nearly a Posting Virtuoso

Ya you may also use code posted by vibhadevit.

urtrivedi 276 Nearly a Posting Virtuoso
$condition="";

if(isset($_POST['bedrooms']) && isset($_POST['bathrooms']) )
    $condition=" where bedrooms like '{$_POST['bedrooms']}' AND bathrooms like '{$_POST['bathrooms']}' "; 
elseif(!isset($_POST['bedrooms']) && isset($_POST['bathrooms']) )
    $condition=" where bathrooms like  '{$_POST['bathrooms']}' "; 
elseif(isset($_POST['bedrooms']) && !isset($_POST['bathrooms']) )
    $condition=" where bedrooms like '{$_POST['bedrooms']}' "; 


$query= "SELECT * FROM inventory {$condition} ORDER BY model_name ASC";
urtrivedi 276 Nearly a Posting Virtuoso

You play with where clause of last query i have given. I think you will get it.

I am not able to understand what you are trying to tell.
You simply show sample data, you have and show me the expected output from it.

urtrivedi 276 Nearly a Posting Virtuoso

select Users.id, Users.Username, User_status.id_status,
sum(case when Analysis.status_name='w' then 1 else 0 end) won,
sum(case when Analysis.status_name='v' then 1 else 0 end) void,
sum(case when Analysis.status_name='l' then 1 else 0 end) lost
FROM UsersINNER 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
GROUP BY Users.id, Users.Username, User_status.id_status
order by won desc


i removed having (won+void+lost)<20. you where asking for limiting it thats why i place that conidtion.

urtrivedi 276 Nearly a Posting Virtuoso
SELECT Users.id, Users.Username, User_status.id_status, 
sum(case when Analysis.status_name='w' then 1 else 0 end) won,
sum(case when Analysis.status_name='v' then 1 else 0 end) void,
sum(case when Analysis.status_name='l' then 1 else 0 end) lost
FROM UsersINNER 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
GROUP BY Users.id, Users.Username, User_status.id_status
having (won+void+lost)<=20
urtrivedi 276 Nearly a Posting Virtuoso

according to your code your final query will be like

delete from teacher where title ='1'

As you option value is 1,2,3.

Are you sure your title columns holds numerice values or you have any other id field.

urtrivedi 276 Nearly a Posting Virtuoso

Remove the red portion. The .(dot) and "(double quote)
It is not required.

$query="SELECT CRNo AS CR,DescriptionCR AS DCR FROM cr where Product='".$product."' ORDER BY CR".";
$result = mysql_query($query);
$i=0;
$numrows=0;

while($row = mysql_fetch_array($result))
{
$numrows=$i;

$i++;
}

urtrivedi 276 Nearly a Posting Virtuoso

It seems that there is not problem in the query. what error or message u are getting?

To actually delete the record you must pass whole title into $_GET.

urtrivedi 276 Nearly a Posting Virtuoso

specify exactly what problem you are facing, error message, unexpected output or some thing like that.

urtrivedi 276 Nearly a Posting Virtuoso

your query could be like following

SELECT DISTINCT vehicles.vehicles_model, manufacturer.manufacturer_name from ....

For option element use vehicle_model field, do not use vehicle_id for option value.

echo "<option value=$nt[vehicles_model]>Model: $nt[vehicles_model] Year: $nt[vehicles_year]</option>";
urtrivedi 276 Nearly a Posting Virtuoso

post you tables structure with sample data. or attach such file

Also tell you want vehcile_id or vehicle_model in next page.

urtrivedi 276 Nearly a Posting Virtuoso

you may user master table only for listing vechicle id, Here you are joining so many tables, that is creating problem for you.

And I think i suggested you to remove year from the query.

urtrivedi 276 Nearly a Posting Virtuoso

i think there is a problem in vehicle_id of you query. in first page. it is null,
YOu have selected vehicles_id column in your query. please check it.

urtrivedi 276 Nearly a Posting Virtuoso

Your code seems to be fine, I am not able to trace the problem.

just again try at the begining of you destionation page, SEE WHAT COMES.

echo "<pre>";
print_r($_POST);
echo "</pre>";
urtrivedi 276 Nearly a Posting Virtuoso

then you just create table as you have shown in your thread.

urtrivedi 276 Nearly a Posting Virtuoso

copy this line in the begining of your code and check what error message it is giving. correct your query and then try again.

error_reporting(E_ALL); 
	ini_set("display_errors", 1);
urtrivedi 276 Nearly a Posting Virtuoso

detailtable (game,winnername,age)

cricket,abc, 25
basketball,abc, 28

you should store in this manner.

what you are asking is report. so we may retrived any kind of information from above table in any format using queires.

so you should use above table to store basic info.

urtrivedi 276 Nearly a Posting Virtuoso

You remove line

echo"<input type=\"hidden\" name=\"vehicles_model\" value=\"$model\">";

becuase you alreay have <select name=vehicle_model> no need to have hidden field for it.


Please check the spelling of vehicle-model (that you hightligted in red). Use underscore(_) instead of hypen(-).

urtrivedi 276 Nearly a Posting Virtuoso

use ifnull function around profit column.

Also change line 13 to
$sel_profit = $row;

"SELECT SUM(ifnull(Analysis.Profit,0)) profit, Users.id, Users.Country_name, Users.Username, User_status.id_statusFROM UsersINNER JOIN User_status ON Users.User_status_name=User_status.user_statusleft outer JOIN Analysis ON Users.Username=Analysis.TipsterWHERE User_status.id_status>=3GROUP BY TipsterORDER BY SUM(ifnull(Analysis.Profit,0)) DESC"
urtrivedi 276 Nearly a Posting Virtuoso

which query is not working properly first or second.

or

why you have used two quries

urtrivedi 276 Nearly a Posting Virtuoso

at the end of query write

order by profit desc

urtrivedi 276 Nearly a Posting Virtuoso

when you run first page just view html source. check whether all hidden fields are set properly, are they getting values or not.

secondly. when you open destination page. what values you are missing or exactly what problem occur.

urtrivedi 276 Nearly a Posting Virtuoso

write following code in destionantion file, to check whether data is posted or not

echo "<pre>";
print_r($_POST);
echo "</pre>";
urtrivedi 276 Nearly a Posting Virtuoso

My fisrt script was better. it shows all files in your directory in file order. you may user a.txt... like that.

another version given below based on 1,2,3,4 series, which depends on series of number. if suppose 5.txt is not there then below script will fail.

$currdirectory=".";//path or your current directory from where you want to show files. i assume all files are text files
	if($_REQUEST['txtfile']=="")
		$txtfile=$currdirectory."/1".".txt";
	else
		$txtfile=$currdirectory."/".$_REQUEST['txtfile'].".txt";
	

	if(file_exists($currdirectory."/".($_REQUEST['txtfile']-1).".txt"))
		$prevfile=$_REQUEST['txtfile']-1;
	if(file_exists($currdirectory."/".($_REQUEST['txtfile']+1).".txt"))
		$nextfile=$_REQUEST['txtfile']+1;
	

	$handle=fopen($txtfile,"r");

	$contents=fread($handle,filesize($txtfile));
	echo($contents);
	fclose($handle);
	echo "<br>";
	if($prevfile!="" )
		print "<a class='text17' href='{$_SERVER['PHP_SELF']}?txtfile={$prevfile}'>Previous</a>&nbsp;&nbsp;";
	if($nextfile!="")
		print "&nbsp;<a class='text17' href='{$_SERVER['PHP_SELF']}?txtfile={$nextfile}'>Next</a>";

its your choice what to use

urtrivedi 276 Nearly a Posting Virtuoso

it depends on order in array so its sorts in text mode and not in numeric mode.

urtrivedi 276 Nearly a Posting Virtuoso

Use following script, nothing more to do. Set your text directory path in currdirectory folder.

<?php
	$currdirectory="textfilesfolder";//path or your current directory from where you want to show files. i assume all files are text files
	if($_REQUEST['txtfile']=="")
		$txtfile=$currdirectory."/1.txt";
	else
		$txtfile=$currdirectory."/".$_REQUEST['txtfile'];
	
	
	$files = scandir($currdirectory);				
	$nextfile=$files[2];
	for ($i=0;$i<count($files);$i++)
	{
		$content=$currdirectory."/".$files[$i];
	 	if (is_file($content))
	 	{
	 	 	if($_REQUEST['txtfile']==$files[$i])
	 	 	{
				$prevfile=$files[$i-1];
				//$txtfile=$files[$i];
				$nextfile=$files[$i+1];
				break;
			}
		}

	}
	
	$handle=fopen($txtfile,"r");
	$contents=fread($handle,filesize($txtfile));
	echo($contents);
	fclose($handle);

	if($prevfile!="" && $i>=3)
		print "<br><a class='text17' href='{$_SERVER['PHP_SELF']}?txtfile={$prevfile}'>Previous</a>&nbsp;&nbsp;";
	if($nextfile!="")
		print "&nbsp;<a class='text17' href='{$_SERVER['PHP_SELF']}?txtfile={$nextfile}'>Next</a>";
 
         ?>
urtrivedi 276 Nearly a Posting Virtuoso

It is used to suppress errors. Even if function fails, it continues execution. But we should avoid using it, let the error shown and fix it.

urtrivedi 276 Nearly a Posting Virtuoso

You may also use javascript datepicker library. In that case you need not to use seperate selection boxes

urtrivedi 276 Nearly a Posting Virtuoso

You try with mysqli

if (mysqli_num_rows($result) > 0 && $name!='')

If you want header in any case then bring table head and footer out of if condition. Also wrap "no result matching...." text in tr td tags.

urtrivedi 276 Nearly a Posting Virtuoso

at line no 12 write following code

$page=$_REQUEST['page'];
urtrivedi 276 Nearly a Posting Virtuoso

specify your problem in detail may be with your code.

urtrivedi 276 Nearly a Posting Virtuoso

remove
, vehicles.vehicles_year
from your query.

urtrivedi 276 Nearly a Posting Virtuoso

Following query will add 15 minutes to col2 and then compare new time with col1.
col1 and col2 must be datetime type column.

select * from mytable 
where col_1_datetime= date_add(col_2_datetime ,interval 15 minute)
urtrivedi 276 Nearly a Posting Virtuoso

Is your problem solved? if not then please specify the problem or close this thread.

urtrivedi 276 Nearly a Posting Virtuoso

You simple cut your line 27

echo "<form action=\"cat.php\" method=\"post\">\n";

and place it at line no 8 that is before executing your query. your select-option must be the part of your form to post it to next page.

urtrivedi 276 Nearly a Posting Virtuoso

you may write update code at the end of your fist database connection file.

do not Write code in every page.

urtrivedi 276 Nearly a Posting Virtuoso

It is alias for timestampdiff(.....) column.
if your user table is like following

useriid, last_accesssed
urtrivedi, 2010-06-03 12:10:00
ayesha, 2010-06-03 11:40:00

now if you execute following query at say 12:30

select TIMESTAMPDIFF(second,last_accessed,current_timestamp) login_since_minutes from usertable

then execution will give

userid, login_since_minutes
urtrivedi, 20
ayesha, 50

means urtriedi visited some page before 20 minutes and ayesha visited some page before 50 minutes

urtrivedi 276 Nearly a Posting Virtuoso

following query will give the username with minutes(page accessed by user before that much minutes). You may set one standard say 20 minutes. If minutes is less than 20 minutes then he/she is online if minutes is greater than 20 then user is offline.

select userid, TIMESTAMPDIFF(minute,last_accessed,current_timestamp) login_since_minutes
 from usertable
urtrivedi 276 Nearly a Posting Virtuoso

As almostbob suggested you may Use your menu file if you are having or any other file that is called in almost all pages to update user status.

I would prefer to do it in following way. I am not sure that it is the best way to do it or not. But it is just to start with.
1) create column in user master say last_accessed (datetime)
2) in you common file you may update user last_accessed column
suppose you store user name in session then you may write update query at the end of your file.

update usertable set last_accessed=current_timestamp() where userid='{$_SESSION['userid]}'

3) now you have time for each user in your usertable. now you may use this column for reporting, that depends on your requirements.

Are you getting?

urtrivedi 276 Nearly a Posting Virtuoso

Is there a page which is called from all pages, some configuration or connection page. You may use that page to update user table. And I suggest to insert timestamp intead of flag.

urtrivedi 276 Nearly a Posting Virtuoso

I think you have not intialized $page anywhere in the code. so line number 9 always sets $page to 1.

urtrivedi 276 Nearly a Posting Virtuoso

I am adding something to condition in line no 23

if ($result <> '' && trim($name) !='') {
urtrivedi 276 Nearly a Posting Virtuoso

I guess name of textbox is userinput. so when you submit you form for processing in processing page you can trim the leading zeros by casting it.

<?php
	$newvalue=(int)$_REQUEST['userinput'];
?>

I guess you are asking for php solution as you have posted it in php forum