urtrivedi 276 Nearly a Posting Virtuoso

cast your value using (int).

<?php
	$newvalue=(int)$_REQUEST['userinput'];
?>
urtrivedi 276 Nearly a Posting Virtuoso

you are doing it in reverse order, following is the correct version

$sql="UPDATE $tbl_name set password='$new_password' WHERE user='$user'";
urtrivedi 276 Nearly a Posting Virtuoso

I am printing your query at line no 5 and 22.
Run you page.
the final query will be printed on your browser
copy it and run it in phpmyadmin and see the error.

$query="select * from smenu where id='$idvalue'";
$result=mysql_query($query);

echo $query."<br>";

while($row=mysql_fetch_array($result))
{

$projectid=$row['id'];
$projectname=$row['main'];
$projectcat= $row['itemm'];
$scope=$row['descrip'];
$location=$row['Category'];
$rate=$row['Rate'];

}
echo " $projectid,$projectname,$projectcat,$scope,$location,$rate";


$query="insert into orde values('$projectid','$projectname','$projectcat','$scope','$location','$rate' where id='$idvalue')";
echo $query."<br>";
$dbase=mysql_query($query);
echo "$dbase";
urtrivedi 276 Nearly a Posting Virtuoso

if you still want it in middle then you must set width to 100%

<style="width:100%">

urtrivedi 276 Nearly a Posting Virtuoso

Have you checked and corrected your syntax in phpmyadmin

urtrivedi 276 Nearly a Posting Virtuoso
<html>
<head></head>
<body>

<div id="container" >
    <div id="header" align="center">Header bits go here</div>
    <div id="content" align="center">Content bits go here
    <div id="footer" align="center">Footer bits go here</div>
</div>
</body>
</html>
urtrivedi 276 Nearly a Posting Virtuoso
SELECT Analysis.Profit, Users.Username, User_status.id 
	FROM Users 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>=3
ORDER BY Profit
urtrivedi 276 Nearly a Posting Virtuoso

First correct syntax in your phpmyadmin, then try to do it in php

urtrivedi 276 Nearly a Posting Virtuoso
$query="insert into orde values('$projectid','$projectname','$projectcat','$scope','$location','$rate')";
echo $query;

error_reporting(E_ALL); 
ini_set("display_errors", 1);

copy the ouput of query from browser, run it in phpmyadmin and check whether your query works there or not.

urtrivedi 276 Nearly a Posting Virtuoso

My doubts

1) you are echoing and inserting outside the while loop so this will show and insert only last record.
2) In your insert query. You can not write where id='idvalue'. following is the correct query. I have removed where portion after 'rate'

$query="insert into orde values('$projectid','$projectname','$projectcat','$scope','$location','$rate')";
urtrivedi 276 Nearly a Posting Virtuoso

Please be specific about your problem. What problem you are facing? And why you have embedded html code in your query code.

urtrivedi 276 Nearly a Posting Virtuoso

what error/problem you are facing.

urtrivedi 276 Nearly a Posting Virtuoso

I have added some thing to your query

"select * from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd , products_to_categories pc where pc.products_id=p.products_id and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and pc.categories_id = '25' order by p.products_date_added DESC, pd.products_name";

urtrivedi 276 Nearly a Posting Virtuoso

You just give alias name before column name

p.categories_id

Also check the spelling of column name

urtrivedi 276 Nearly a Posting Virtuoso

I think there is problem with the relation between the tables. If you want to join analysis table with users table then there must be some common column between them. but in analysis table there is no column related to users.

So have some link between these two tables and join on the basis of this columns in your query. Also you may use aggregate functions like sum, average for getting your result and to remove redundant rows from query result.

urtrivedi 276 Nearly a Posting Virtuoso

When you are opening whole file in textarea then why you are treating it as csv, simply load text area with content, modify and save. I hope following code will help you

<form action="save.php" method="post">
<textarea name="events" cols="100" rows="10" style="text-align:left">
<?php 
	$handle=fopen("events.csv","r");
	echo fread($handle,filesize("events.csv"));
	fclose($handle);

?>
</textarea><br />
<input type="submit" name="Edit" value="Save" />
</form>
urtrivedi 276 Nearly a Posting Virtuoso

There is problem with your query.
before executing it do following.

$query="SELECT q.*, IF(v.id,1,0) AS votedFROM quotes AS qLEFT JOIN quotes_votes AS v ON 	q.id = v.qid	AND v.ip =".$ip."	AND v.date_submit = '".$today."'";

echo $query;
.
.
.
$result = mysql_query($query);
.
.
.

copy the output of query, run it in phpmyadmin and check the query syntax properly there.

urtrivedi 276 Nearly a Posting Virtuoso
$response=mail(...pass proper parameters.....);

if($response)
   echo "Mail sent successfully";
else
   echo "error occured while sending a Mail";
urtrivedi 276 Nearly a Posting Virtuoso

you print the post values some where in between. check whether it is comming as expected.

echo $_POST['EffStartDT']."<br>";
echo $_POST['EffEndDT']."<br>";
urtrivedi 276 Nearly a Posting Virtuoso

I am writing code for your third page.

In php you must use post element name without [], to access whole array

Checked item ids will be displayed by the following code

<?php

echo "close now checked <br>";
for($i=0;$i<count($_POST['closenow'];$i++)
{
	echo "{$_POST['closenow'][$i]}<br>";
}

echo "delete checked <br>";
for($i=0;$i<count($_POST['O_delete'];$i++)
{
	echo "{$_POST['O_delete'][$i]}<br>";
}
?>
urtrivedi 276 Nearly a Posting Virtuoso

Because you are passing same value=\"".trim($_POST)."\";
You must give some other variable for first one

urtrivedi 276 Nearly a Posting Virtuoso

you again use do ....while () loop
that will solve your problem. because your code is desinged that way.

urtrivedi 276 Nearly a Posting Virtuoso

at line 8 add
echo $query_getPages;
copy the output query from browser and run in phpmyadmin. check the result

urtrivedi 276 Nearly a Posting Virtuoso

there is a problem in your line no 217-218. $sel_subject; is not having proper value.

<a href="delete_subject.php?subj=                
<?php $sel_subject['id']; ?>"
urtrivedi 276 Nearly a Posting Virtuoso

First of all let me know Have you applied the suggested changes and are you getting the grand total.

Secondly If you not getting more recrods then, You should post the portion of your code where you are executing database query.
supppost your code is like below, You just echo your query text, copy it and run it in phpmyadmin or other database tool, and see whether it is working there fine.

$query="select * from mytable where mycol=mycondtion";
echo $query;
.
.
.
$result=mysql_query($query");
.
.
urtrivedi 276 Nearly a Posting Virtuoso

I am not sure what is your problem, even though I guessed your problem and made certain changes.
1) used while{ } loop instead of do.. while loop
2) used two variable grandnaira & granddollar , intialize them and added current value in every iteration.
3) You were printing grand total in the while loop, i m not sure why. so I have taken out that grand total row out of while loop and printed two varaibles grandnaira & granddollar at appropriate place. I have also remove html tr ID for the grand total row.

</table><table width="95%" border="1" align="center" CELLPADDING="2" CELLSPACING="0" bordercolor="<?PHP print "$BorderColour"; ?>">
          <tr valign="middle" class="tableheadsx">
            <td width="91" height="29" align="left" class="welcomexx"><strong>Date</strong></td>
            <td width="136" height="29" align="left" class="welcomexx"><strong>Distributor's ID </strong></td>
			<td width="136" height="29" align="left" class="welcomexx"><strong>Customer's Name </strong></td>
            <td width="140" height="29" align="left" class="welcomexx"><strong>Total Paid(Naira) </strong></td>
			<td width="157" height="29" align="left" class="welcomexx"><strong>Total Paid(Dollar)</strong></td>
          </tr>
		  <?php 
		  $rowShine = 1;
		 //next 2 lines added by urtrivedi,			 		  
		  $grandnaira=0;
		  $granddollar=0;
		  ?>
          <?php if ($totalRows_getPages > 0) { // Show if recordset not empty ?>
            <?php  while ($row_getPages = mysql_fetch_assoc($getPages)) { ?>
              <tr id="row-<?php echo $row_getPages['code']; ?>" <?php if($rowShine%2){
						echo "class=\"alternate\" ";
					}
			?>>
			<?php 
			
			 $me=$row_getPages['totalDollar']; 
			 $mee=$row_getPages['totalNaira']; 
			 //next 2 lines added by urtrivedi,			 
			 $grandnaira +=$mee;
			 $granddollar+=$me;
			 
			 ?>
                <td height="25" align="left" valign="top" class="style1"><?php echo $row_getPages['xdate']; ?></td>
				 <td height="25" align="left" valign="top" class="style1"><?php echo $row_getPages['dis_id']; ?></td>
                <td height="25" align="left" valign="top" class="style1"><strong><?php echo $row_getPages['dis_name']; ?></strong></td>
                <td height="25" align="left" valign="top" class="style1"><?php print number_format($mee,2); ?></td>
				<td height="25" align="left" valign="top" class="style1"><?php print number_format($me); ?></td>
              </tr>
              
              <?php $rowShine++;?>
              <?php }//end while   ?>
			
			
			
			
			
			
			
			<tr …
urtrivedi 276 Nearly a Posting Virtuoso

I am giving you every code segment after proper testing. I dont know why its not working there. any ways post your final code for others.

urtrivedi 276 Nearly a Posting Virtuoso

Have you changed the code as I mentioned

urtrivedi 276 Nearly a Posting Virtuoso

Please do not use html code only keep php tags whatever i have given below.

Also there is one error in line $row=$mysql_fetch_array($result);
remove $ sign from the begining of mysql_fetch_array
so correct line is

$row=mysql_fetch_array($result);

following code is correct code

<?php			
include("config.php");    
$result=mysql_query("select SiteID,MFR from eims_info where SiteID='{$_REQUEST['course']}'");    
$row=mysql_fetch_array($result);    
echo $row['MFR']; //return mf value for requested code;
?>

REMOVE ALL HTML CODE your script should return only value of mf

urtrivedi 276 Nearly a Posting Virtuoso

xmlhttp.open("GET","getmf.php?course="+str,true);

here you are passing course and in your getmf you are using Requst[a]
so you should use
....where SiteID='{$_REQUEST}'


you open browser and run yourserver/getmf.php?course=8645

now see what the browser is returning, is it giving curret value for 8645 or not.

also in getmf.php file delete extra space and lines before <?php tag and after ?> tag

urtrivedi 276 Nearly a Posting Virtuoso

You refer to my last post on the first page of this thread, code is using AJAX.

Now if you want to do it in above code. then this code will set 5500 array elements in javascript, which is not good practice. Also you need to set database connection before executing the query. also have you changed. mytable to the actual tablename in your script.

urtrivedi 276 Nearly a Posting Virtuoso

I am using basic ajax. Now you have to create one php file getmf.php in the same folder where your current file is saved. copy following code to it. set database connection properly

<?php
	//set data base connection
    $result=mysql_query("select code,mf from mytable where code='{$_REQUEST['code']}'");
    $row=$mysql_fetch_array($result);
    echo $row['mf'];//return mf value for requested code;
?>

then add new javascript function and other changes as given below to current file. Now if you are not comfortable with the code then I suggest you to learn some ajax tutorials and then try to solve your problem

<script lang='javascript'>
function findmf(str)
{
	if (str=="")
	{
		document.getElementById("a").value="";
		return;
	}  
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("a").value=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET","getmf.php?code="+str,true);
	xmlhttp.send();
}

function calculate()
{
 //e is previous
 //f is current
 //g is new is f-e
 //code is code
 //a is mf
 
 	previous=parseFloat(document.getElementById("e").value);
 	curr=parseFloat(document.getElementById("f").value);

	if(!isNaN(previous) && !isNaN(curr) )
	{
	 	if(curr>=previous)
			document.getElementById("g").value=curr-previous*(parseFloat(document.getElementById("a").value));
		else
			document.getElementById("g").value="";
	}
	else
	{
		document.getElementById("g").value="";
	}
}
</script>


<body>
<form>
code <input type="text" name="code" id="code" value=""  class="input"    onblur='javascript:findmf(this.value);' > <br>
a <input type="text" name="a" id="a" value=""  class="input"   readonly> <br>

e <input type="text" name="e" id="e" value="340"  class="input" onblur='javascript:calculate();' > <br>
f <input type="text" name="f" id="f" value=""  class="input"  onblur='javascript:calculate();' > <br>
g <input type="text" name="g" id="g" value=""  class="input"  readonly >
</form>
urtrivedi 276 Nearly a Posting Virtuoso

You mean your code-mf table is having 5500 rows.

urtrivedi 276 Nearly a Posting Virtuoso

what is the data source and its format?

urtrivedi 276 Nearly a Posting Virtuoso

Go through the follwing code carefully. I have not used ajax here. Its simple php/javascript. I am assuming that your code,mf table is very small so i am storing its values in a javascript array, and using it for calculation. If your table is very large then u must learn ajax for retriving values from mysql. Make necessary changes whereever application

<script lang='javascript'>
arrmfrates = new Array();
<?php 
	/*here find code, mf from database and create one javascript array*/
	
	/* following loop will create javacript asscoicate array as following
	arrmfrates["c8620"] = 2;
	arrmfrates["c8621"] = 1;
	arrmfrates["c8645"] = 5;
	*/
    
    $result=mysql_query("select code,mf from mytable");
	while ($row=$mysql_fetch_array($result ))
	{
		
		echo "\n arrmfrates['c".$row['code']."] = ".$row['code'].";";

	}
?>

/*this function will be called when user enters code, to find mf value stored in javascript array, this mf value is copied to "a" field of database*/
function findmf(code)
{

	if(arrmfrates['c'+code]!=undefined)
		document.getElementById("a").value=arrmfrates['c'+code];
	else
		document.getElementById("a").value="";
}

function calculate()
{
 //e is previous
 //f is current
 //g is new is f-e
 //code is code
 //a is mf
 
 	previous=parseFloat(document.getElementById("e").value);
 	curr=parseFloat(document.getElementById("f").value);

	if(!isNaN(previous) && !isNaN(curr) )
	{
	 	if(curr>=previous)
			document.getElementById("g").value=curr-previous*(parseFloat(document.getElementById("a").value));
		else
			document.getElementById("g").value="";
	}
	else
	{
		document.getElementById("g").value="";
	}
}
</script>


<body>
<form>
code <input type="text" name="code" id="code" value=""  class="input"    onblur='javascript:findmf(this.value);' > <br>
a <input type="text" name="a" id="a" value=""  class="input"   readonly> <br>

e <input type="text" name="e" id="e" value="340"  class="input" onblur='javascript:calculate();' > <br>
f <input type="text" name="f" id="f" value=""  class="input"  onblur='javascript:calculate();' > <br>
g <input type="text" name="g" id="g" value=""  class="input"  readonly >
</form>
urtrivedi 276 Nearly a Posting Virtuoso

Go through the follwing code carefully. I have not used ajax here. Its simple php/javascript. I am assuming that your code-mf table is very small so i am storing its values in a javascript array and using it for calculation. make necessary changes whereever applicable.

<script lang='javascript'>
arrmfrates = new Array();
<?php 
	/*here find code, mf from database and create one javascript array*/
	
	/* following loop will create javacript asscoicate array as following
	arrmfrates["c8620"] = 2;
	arrmfrates["c8621"] = 1;
	arrmfrates["c8645"] = 5;
	*/
    
    $result=mysql_query("select code,mf from mytable");
	while ($row=$mysql_fetch_array($result ))
	{
		
		echo "\n arrmfrates['c".$row['code']."] = ".$row['code'].";";

	}
?>

/*this function will be called when user enters code, to find mf value stored in javascript array, this mf value is copied to "a" field of database*/
function findmf(code)
{

	if(arrmfrates['c'+code]!=undefined)
		document.getElementById("a").value=arrmfrates['c'+code];
	else
		document.getElementById("a").value="";
}

function calculate()
{
 //e is previous
 //f is current
 //g is new is f-e
 //code is code
 //a is mf
 
 	previous=parseFloat(document.getElementById("e").value);
 	curr=parseFloat(document.getElementById("f").value);

	if(!isNaN(previous) && !isNaN(curr) )
	{
	 	if(curr>=previous)
			document.getElementById("g").value=curr-previous*(parseFloat(document.getElementById("a").value));
		else
			document.getElementById("g").value="";
	}
	else
	{
		document.getElementById("g").value="";
	}
}
</script>


<body>
<form>
code <input type="text" name="code" id="code" value=""  class="input"    onblur='javascript:findmf(this.value);' > <br>
a <input type="text" name="a" id="a" value=""  class="input"   readonly> <br>

e <input type="text" name="e" id="e" value="340"  class="input" onblur='javascript:calculate();' > <br>
f <input type="text" name="f" id="f" value=""  class="input"  onblur='javascript:calculate();' > <br>
g <input type="text" name="g" id="g" value=""  class="input"  readonly >
</form>
urtrivedi 276 Nearly a Posting Virtuoso

no need to keep it in hidden field.
You may query database before script tag and find value in variable $mfvalue.
then echo value of $mfvalue in your javascript as i have shown in abouve post.

urtrivedi 276 Nearly a Posting Virtuoso

you view your html source and see what is going wrong

urtrivedi 276 Nearly a Posting Virtuoso

you need to change as code given below

<?php
// find multiplier here 
$mfvalue=9;
?>
<script lang='javascript'>
function calcualte()
{
.
.
.
.
if(curr>=previous)
	document.getElementById("g").value=(curr-previous)*(<?php echo $mfvalue;?>);

.
.
.
}
urtrivedi 276 Nearly a Posting Virtuoso

Ya ayesha you may ask.

urtrivedi 276 Nearly a Posting Virtuoso

option 1

<?php
for($j=0;$j<count($number);$j++) 
{
 ?>
 
 <input type='text' size='1' name='inputno<?php echo $j;?>' id='inputno<?php echo $j;?>' onchange="check_input(this.value, '<?php echo $j;?>' );">

 <?php
 }
?>

option 2

<?php
for($j=0;$j<count($number);$j++) 
{

 	echo "<input type='text' size='1' name='inputno{$j}' id='inputno{$j}' onchange=\"check_input(this.value, '{$j}')\">";

}
?>
urtrivedi 276 Nearly a Posting Virtuoso

Dear Raja
Some time if you parse string to float it my give Nan (NOT a number) error, to avoid such error I have used isNaN function.

Dear Ayesha
Dont worry, this code will give you result in g field

urtrivedi 276 Nearly a Posting Virtuoso

g field is calculated field, user may not change it so onblur='javascritp:calculate();' is not required for g field. User is not going to type there anything.

I am not checking for browser compatibility anywhere, why do you feel so?

urtrivedi 276 Nearly a Posting Virtuoso

The poll is meaning less, its asking like mother is best or father is best.

urtrivedi 276 Nearly a Posting Virtuoso

some code was not required given in my previous post. following is the final one.
Add following javascript code before html body tag.

<script lang='javascript'>
function calculate()
{
 //e is previous
 //f is current
 //g is new is f-e
 	previous=parseFloat(document.getElementById("e").value);
 	curr=parseFloat(document.getElementById("f").value);
	if(!isNaN(previous) && !isNaN(curr) )
	{
	 	if(curr>=previous)
			document.getElementById("g").value=curr-previous;
		else
			document.getElementById("g").value="";
	}
	else
	{
		document.getElementById("g").value="";
	}
}
<script>

in your html part add onblur events as shown below in your text box elements

<input type="text" name="e" id="e" value="<?php echo $e; ?>"  class="input" onblur='javascritp:calculate();' /> 
<input type="text" name="f" id="f" value=""  class="input"  onblur='javascritp:calculate();' />
urtrivedi 276 Nearly a Posting Virtuoso

Add following javascript code before html body tag.

<script lang='javascript'>
function calculate()
{
 //e is previous
 //f is current
 //g is new is f-e
 	previous=parseFloat(document.getElementById("e").value);
 	curr=parseFloat(document.getElementById("f").value);
	if(!isNaN(previous) && !isNaN(curr) )
	{
	 	if(curr>=previous)
			document.getElementById("g").value=curr-previous;
		else
			document.getElementById("g").value="";
	}
	else
	{
		document.getElementById("g").value="";
	}
	var total = 0;      
	for (i = 1 ;i <= 15; i++)      
	{        
		if (i<10)
			labelname='amount_0'+i;
		else
			labelname='amount_'+i;
	
	
		if (!isNaN(parseFloat(document.getElementById(labelname).innerHTML)))
			total += parseFloat(document.getElementById(labelname).innerHTML);      
	}      
	
	document.getElementById(label2).innerHTML = total;
}
<script>

in your html part add onblur events as shown below in your text box elements

<input type="text" name="e" id="e" value="<?php echo $e; ?>"  class="input" onblur='javascritp:calculate();' /> 
<input type="text" name="f" id="f" value=""  class="input"  onblur='javascritp:calculate();' />
urtrivedi 276 Nearly a Posting Virtuoso

If you want to refer to same table only once than you can do it in same table. If there are more than one references then you need to create another table with one to many relation.

You should always link to primary key, DO NOT USE ATTNAME. It is not a good practice.
you just refer to attid.

nav33n commented: true! +6
urtrivedi 276 Nearly a Posting Virtuoso

your query is absolutely fine. what error message you are getting.

urtrivedi 276 Nearly a Posting Virtuoso

I hope this will work

function calculate(.......)
{
 .
 .
 .
 .
 
	var total = 0;      
	for (i = 1 ;i <= 15; i++)      
	{        
		if (i<10)
			labelname='amount_0'+i;
		else
			labelname='amount_'+i;
	
	
		if (!isNaN(parseFloat(document.getElementById(labelname).innerHTML)))
			total += parseFloat(document.getElementById(labelname).innerHTML);      
	}      
	
	document.getElementById(label2).innerHTML = total;
}
urtrivedi 276 Nearly a Posting Virtuoso

change you calculate function at the end as shown below

function calcuate(...........)
{
.
.
.
.

var total = 0;      
for (i = 1 ;i <= 15; i++)      
{        
	if (i<10)
	{
		total += parseFloat(document.getElementById('amount_0'+i).innerHTML);      
	}
	else
	{
		total += parseFloat(document.getElementById('amount_'+i).innerHTML);      
	}
}      
document.getElementById(label2).innerHTML = total;

}