It will give average of all individual cigars, no matters how may entries.
I forget to group by CigarId.
SELECT CigarId , sum( (
Quantity * Price
) ) / sum( Quantity ) as avg
FROM `cigar`
group by CigarId
It will give average of all individual cigars, no matters how may entries.
I forget to group by CigarId.
SELECT CigarId , sum( (
Quantity * Price
) ) / sum( Quantity ) as avg
FROM `cigar`
group by CigarId
I have changed select query.
Check this.
<?php
$con = mysql_connect('localhost','root','');
if (!$con)
{
die("Could not connect: " . mysql_error());
}
mysql_select_db('users',$con);
$user = $_POST['username'];
$result= mysql_query("SELECT * FROM users_info WHERE username='".$user."'");
if (mysql_num_rows($result) == 0)
{
die("Error: Username is not in our database! Make sure you check the spelling.");
}
else
{
redirect('/user/' . $user . '.php');
}
mysql_close($con);
?>
What i understood, Your calculation is giving 2.33 not 1.73.
(10 * 1.00) + (20 * 2.00) + (30 * 3.00)
----------------------------------
SUM(Quantity)
=> 140 / 60
=> 2.33
Check this query.
SELECT sum( (
Quantity * Price
) ) , sum( Quantity ) , sum( (
Quantity * Price
) ) / sum( Quantity )
FROM `cigar`
Error is based on coding and logic.
You have to increase your memory limit.
ini_set(’memory_limit’, '20M');
But if your script is in end level recursion, above solution wont work.
Make sure your recursive function has one limit and break somewhere.
If you are testing this page in local then it won't work.
You need smtp setting for sending email.
For other error post the error you are getting.
Using php?? OR using js?
Post your code.
I have checked in IE9.. its working fine. Same view as firefox.
Whats issue?
@divya: i don't think you can get browser close event.
It works only on some browser, i have tried it in past.
If your code works in all browser post here for others use.
BTW its different question but how to see that query has examined how many record?
I am having mysql query browser and phpmyadmin.
I have made this code in past.
Hope this will help you.Add it in your code and echo query you will understand it.
You can change upto your requirement.
<?
function searchString($str,$matchAr)
{
$out = '';
$str = preg_replace('/\s\s+/', ' ', $str);
$temp = explode(' ',$str);
foreach($matchAr as $match)
{
$out.="(";
foreach($temp as $value)
{
$out.="$match LIKE '%$value%' AND ";
}
$out = substr($out,0,-4);
$out.=") OR ";
}
return substr($out,0,-4);
}
$where.=" AND (".searchString($key,array('title','name')).")";
// if user type aaa , it will match with title field and name field
// if user type aaa bbb , it will check search must contain aaa bbb both. Either in title or name.
echo $sql = "select * FROM tbl_name WHERE $where ";
?>
Ajax is used for the case:
- Once php page is loaded.
- Then we want any php stuff like database insert,update,delete,select query or any php coding without again refreshing page.
- so here we use ajax, so end user wont realize that some thing happen on server side.
- The code i have given is using jquery. Jquery is JS library, using which we can do all stuff of javascript more easily and min line of coding. Jquery have thousands of function e.h. you have used innerHTML, jquery have http://api.jquery.com/html/.
Hope this helps you.
Mark thread solved.
That is called ajax. and case 2 in my above post.
Hope you have some idea what AJAX is.
<script language="javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
<script language="javascript">
function change()
{
$.ajax({ // this function will send php request in back so no need to refresh page
type: "POST",
url: "ajax.php", // in ajax.php check requested flexi variable passed from below line and write update query.
data: "flexi=flexi1",
success: function(msg){
// change html portion
}
});
}
// same for flexi2
</script>
For case 1 you don't need javascript onclick.
<?
if(isset($_POST['alloc1']))
{
$query = 'UPDATE flexi SET allocation = "allocated", user = "'.$_SESSION["username"].'" WHERE flexi="flexi1"';
$result = mysql_query($query);
$result = $_SESSION['allocate'];
header("location:page.php");// page.php is the page where you want to redirect after success update
exit;
}
if(isset($_POST['alloc2']))
{
$query = 'UPDATE flexi SET allocation = "allocated", user = "'.$_SESSION["username"].'" WHERE flexi="flexi2"';
$result = mysql_query($query);
$result = $_SESSION['allocate'];
header("location:page.php");// page.php is the page where you want to redirect after success update
exit;
}
?>
// this should be in form
<input type='button' style='float:right' name="alloc1" value='Allocate'>
<input type='button' style='float:right' name="alloc2" value='Allocate'>
Your mysql credentials is wrong apart from that
The string error is because on
define("SITE_PATH", "D:\Hosting\6585577\html\rhythmmovement\");
The last \ (back slash) ignore double qoute and string is broken.
Try below.
define("SITE_PATH", "D:\Hosting\6585577\html\rhythmmovement\\");
You have placed this code on top.
$query1 = 'UPDATE flexi SET allocation = "allocated", user = "'.$_SESSION["username"].'" WHERE flexi="flexi1"';
$result1 = mysql_query($query1);
$result1 = $_SESSION['allocate'];
$query2 = 'UPDATE flexi SET allocation = "allocated", user = "'.$_SESSION["username"].'" WHERE flexi="flexi2"';
$result2 = mysql_query($query2);
$result2 = $_SESSION['alloc'];
That means each time page is refreshed sql query will update record.
You can do it by 2 way.
1) server side
Use submit button.
When user click on submit button page will be posted and top php code will update record. Top php code will be in if condition.
e.g.
if(isset($_POST('submit'))){ //===update query====}
2) Client side
Use Ajax.
Which meanse once user click on button you will send one ajax request to one page which will update data.
<? define('SITE_ROOT_PATH',$_SERVER['DOCUMENT_ROOT'].'testproject/')
include(SITE_ROOT_PATH.'config.php');
?>
You can add above code in any file of any directory of testproject.
Try this.
<?
$cnt = 1;
foreach($images->photos->photo as $photo)
{
if($cnt==1 || (($cnt-1)%4==0))
echo '<div>';
echo '<a href="http://flickr.com/photos/' . $flickr->username . '/' . $photo->attributes()->id . '"><img src="http://farm' . $photo->attributes()->farm . '.static.flickr.com/' . $photo->attributes()->server . '/' . $photo->attributes()->id . '_' . $photo->attributes()->secret . '_s.jpg" width="55" height="55" alt="flickr"/></a>';
if($cnt==count($images->photos->photo) || $cnt%4==0)
echo '</div>';
$cnt++;
}
?>
@caperjack : I have taken video in snagit but i can not edit video from that.e.g. labels,callouts,delay..etc.
Camtasia is really good. I have tried it.
But one problem:
I have taken 30 mins video.My video is little bit fast.
Now i am adding callouts.But i want to make callout display for alteast3-4 sec. so user can read its text.
I have tried to extend frames but it splits timeline and i am not able to drag(extend) callout on timeine.
Any suggestion friends?
Add this code at line#16.
Try to copy paste data and Post query you are getting.
Also try to run that query in phpmyadmin.
echo "INSERT INTO news VALUES('$_POST[category]','$_POST[place]',now(),'$_POST[headline]','$_POST[bdesc]','$_POST[para1]','$st_nno')"; exit;
use CODE tags to post your code.
What error are you getting?
Are you using single or double quote in notepad text?
In php you can do this by ffmpeg.
You need to install it in server.
Check this : http://lmgtfy.com/?q=ffmpeg+php+tutorial
You can use in HTML code to give space.
Check where is ROOT_PATH defined and what is its value?
How php string works??
In php you can give single quote or double quote for defining string.
If you start with single quote, php will find next single quote for completion of it.In middle you can also use double quote.
Dot(.) is used for two string concatenation.
Same for double quote. If you want to use double quote inside two double quote you can use back slash.
e.g.
'Hi I" am '.'php developer' => valid
'Hi I" am '."php developer" => valid
'Hi I' am '."php developer" => Not valid
'Hi I\' am '."php developer" => valid
'Hi I am '."<a href="http://php.net">php</a> developer" => Not valid
'Hi I am '."<a href=\"http://php.net\">php</a> developer" => Valid
Even if you are using dream-weaver like editor proper string always give red color.
If something is messy, based on color highlighting you can recognize it.
Debug your code with echo.
echo both select script and run it in phpmyadmin.
Post what you are getting.
<?php
if ($_POST['submit-login'])
{
$sql = "SELECT * FROM `users` WHERE
`username` = '" . mysql_escape_string($_POST['username']) . "' &&
`password` = '" . mysql_escape_string(md5(SALT_KEY . $_POST['password'] . SALT_KEY)) . "'";
echo 'First Query : <br> :'.$sql;
$user_retrieve = mysql_query($sql);
if (mysql_num_rows($user_retrieve))
{
$ur = mysql_fetch_array($user_retrieve);
$sql = "SELECT * FROM `user_sessions` WHERE `session_id` = '".mysql_escape_string($_COOKIE['PHPSESSID'])."' && `ip_address` = '".mysql_escape_string($_SERVER["REMOTE_ADDR"])."'";
echo 'Second Query : <br> :'.$sql;
exit;
$session_retrieve = mysql_query($sql);
if (mysql_num_rows($session_retrieve))
{
echo "You are already logged in. <a href='members-area.php'>Click Here</a>";
}
else
{
if (empty($_COOKIE['PHPSESSID']))
{
echo "Unknown Error, Please try enabling cookies.";
}else{
$create_session = mysql_query("INSERT into `user_sessions` (session_id, ip_address, uid) values ('".mysql_escape_string($_COOKIE['PHPSESSID'])."', '" . mysql_escape_string($_SERVER["REMOTE_ADDR"]) . "', '" . mysql_escape_string($ur['id']) . "');");
echo "You have successfully logged in. <a href='members-area.php'>Click Here</a>";
}
}
}
else
{ echo "Invalid Username or Password.";
}
}
?>
Try this code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<script language="javascript">
function checkvalue()
{
var grWeight = parseInt(document.getElementById('grWeight').value);
var netWeight = parseInt(document.getElementById('netWeight').value);
var crWeight = parseInt(document.getElementById('crWeight').value);
document.getElementById('grWeight').style.backgroundColor = '#FFFFFF';
document.getElementById('netWeight').style.backgroundColor = '#FFFFFF';
document.getElementById('crWeight').style.backgroundColor = '#FFFFFF';
if(grWeight>netWeight && grWeight>crWeight)
document.getElementById('grWeight').style.backgroundColor = '#FCF964';
if(netWeight>grWeight && netWeight>crWeight)
document.getElementById('netWeight').style.backgroundColor = '#FCF964';
if(crWeight>netWeight && crWeight>grWeight)
document.getElementById('crWeight').style.backgroundColor = '#FCF964';
}
</script>
<form>
<table>
<tr>
<td width="172" class="label" > </td>
<td class="content" colspan="3" > Grwt
<input name="grWeight" type="text" class="box" id="grWeight" size="20" maxlength="255" />
ntwt
<input name="netWeight" type="text" class="box" id="netWeight" size="20" maxlength="255" />
crwt
<input name="crWeight" type="text" class="box" id="crWeight" size="20" maxlength="255" />
<input name="click" value="Click here" onclick="return checkvalue();" type="button" />
</td>
</tr>
</table>
</form>
</body>
</html>
Hi All,
I am a website developer.
I need to take demo video of my website without sound for representing it to the client.
I also want to add text callout or help notes along with screen capture(e.g. 'click on submit button','Fill username'..etc like snagIt).
I am looking for such software but didn't found any useful.
Please advice me some name of software for this.
Thanks.
Vibha
Okay.. i think its a live server...
Do you have wamp/xamp?
If wamp, Can you see this tray icon options as attached image?
Also refer this link http://www.mkyong.com/apache/php-file-display-as-downloading-instead-of-interpreted-by-apache-windows/
This is server issue. Ask hosting guy.
function resizeImage($sourceFile,$destFile,$width = '',$height ='')
{
$proportional = true;
$output = 'file';
copy($sourceFile,$destFile);
$file = $destFile;
if ( $height <= 0 && $width <= 0 ) return false;
# Setting defaults and meta
$info = getimagesize($file);
$image = '';
list($width_old, $height_old) = $info;
$final_width = 0;
$final_height = 0;
$dims = getImageBound($width_old, $height_old,$width,$height);
$final_height=$dims['height'];
$final_width=$dims['width'];
if ( $width_old == $final_width && $height_old == $final_height ) return true;
# Loading image to memory according to type
switch ( $info[2] ) {
case IMAGETYPE_GIF: $image = imagecreatefromgif($file); break;
case IMAGETYPE_JPEG: $image = imagecreatefromjpeg($file); break;
case IMAGETYPE_PNG: $image = imagecreatefrompng($file); break;
default: return false;
}
# This is the resizing/resampling/transparency-preserving magic
$image_resized = imagecreatetruecolor( $final_width, $final_height );
if ( ($info[2] == IMAGETYPE_GIF) || ($info[2] == IMAGETYPE_PNG) ) {
$transparency = imagecolortransparent($image);
if ($transparency >= 0) {
$transparent_color = imagecolorsforindex($image, $trnprt_indx);
$transparency = imagecolorallocate($image_resized, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
imagefill($image_resized, 0, 0, $transparency);
imagecolortransparent($image_resized, $transparency);
}
elseif ($info[2] == IMAGETYPE_PNG) {
imagealphablending($image_resized, false);
$color = imagecolorallocatealpha($image_resized, 0, 0, 0, 127);
imagefill($image_resized, 0, 0, $color);
imagesavealpha($image_resized, true);
}
}
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $final_width, $final_height, $width_old, $height_old);
# Preparing a method of providing result
switch ( strtolower($output) ) {
case 'browser':
$mime = image_type_to_mime_type($info[2]);
header("Content-type: $mime");
$output = NULL;
break;
case 'file':
$output = $file;
break;
case 'return':
return $image_resized;
break;
default:
break;
}
# Writing image according to type to the output destination
switch ( $info[2] ) {
case IMAGETYPE_GIF: imagegif($image_resized, $output); break;
case IMAGETYPE_JPEG: imagejpeg($image_resized, $output); break;
case IMAGETYPE_PNG: imagepng($image_resized, $output); break;
default: …
definitely www.#.com was just for example.
$siteurl = "http://localhost/xampp/website/";
if ($session_name) {
echo '<a href="'.$siteurl.'/newsletter.php">Newsletter </a>\n';
echo '<a href="'.$siteurl.'/admin/add.user.php">Add Admin </a>\n';
echo '<a href="'.$siteurl.'/admin/logout.php">Logut </a><br>\n';
} else {
echo '<a href="'.$siteurl.'/newsletter.php">Newsletter </a>\n ';
echo '<a href="'.$siteurl.'/admin/login.php">Login </a>\n';
Try above code.
and whenever you upload files to live don't forget to change $siteurl.
Have you tried as ardav said?
echo "<a href=\"http://www.#.com/newsletter.php\">Newsletter </a>\n";
echo "<a href=\"http://www.#.com/admin/add.user.php\">Add Admin </a>\n";
echo "<a href=\"http://www.#.com/admin/logout.php\">Logut </a><br>\n";
} else {
echo "<a href=\"http://www.#.com/newsletter.php\">Newsletter </a>\n ";
echo "<a href=\"http://www.#.com/admin/login.php\">Login </a>\n";
(By Mistake)
Try this.
<script type="text/javascript">
window.onload=function() {
if (document.getElementById("country")) {
document.getElementById("country").onchange=function() { switchme(this); }
}
}
function switchme(SNewSel) {
var ind = SNewSel.selectedIndex;
var txt = document.getElementById('country_code');
switch (ind) {
case 1: txt.value = "+93"; break;
case 2: txt.value = "+358"; break;
case 3: txt.value = "+355"; break;
default:
txt.value='';
break;
}
}
</script>
<form action="output.php" method="post" name="myform" id="myform">
<input id="country_code" name="country_code" size="4" maxlength="6" class="boxinput">
<select name="country" id="country">
<option value="Choose One" selected="selected" >Choose One</option>
<option value="AFG">Afghanistan</option>
<option value="ALA">Aland Islands</option>
<option value="ALB">Albania</option>
</select>
is this page outside of admin folder?
When you edit mark then you are passing its id 0253 to edit page.
Now again you want to edit 'stick' then pass mark id(0253) and stick id so when you update 'stick' you can back to last page using mark's id.
You can do this by htaccess.
This is a file named '.htaccess' which you have to put at root of your required project.
You have to write rules in htaccess to generate url.
Visit http://www.generateit.net/mod-rewrite/ to generate simple rules.
Hey m not sir.. m mam :)
Try user.username in where condition.
$result = mysql_query("SELECT user.password, data1.dob FROM user INNER JOIN data1 ON user.username = data1.username WHERE user.username = '" . $_SESSION['username'] . "'");
If you want to learning then its good, otherwise there are thousands of ready script.
Better to use them. phpclasses have good classes.
index.php?showforum=2 won't redirect you at forum-2.html.
You have to make your href and redirection such that forum-2.html will comes in url.
Just looked http://www.3gphone.in/acer/27.
CSS is working right..
Same way you have to give URL for product images.
e.g phonepics/956_1.jpg should be http://www.3gphone.in/phonepics/953_1.jpg
You can define site url in config file and append it in all images and css so if your domain transfer you have only change in config file.
Dont give relative path use absolute path while including css or images.
e.g. http://www.3gphone.in/css.css
Can you post live URL that you are referring?
No..
If you don't pass both variable you can't use brandid in coding.
There is one option just pass pname(Acer) and on top of page use select query and get brandid from database table having model 'Acer'.
And if you want SEO friendly url then you have to also save seo friendly product name in php. space is not SEO friendly.
http://www.3gphone.in/Lemon IT 20717 should be http://www.3gphone.in/lemon-it-20717
Refere this link http://htmlblog.net/seo-friendly-url-in-php/ for php function.
Okay.The rule is :
RewriteRule ^([^/]*)$ /products.php?pname=$1 [L]
http://www.3gphone.in/Acer TO http://www.3gphone.in/products.php?pname=Acer
But as i said before if you want this url you can not use brandid in coding.
Place that rule and let me know output.
RewriteEngine On
RewriteRule ^brandid/([^/]*)/([^/]*)$ /products.php?brandid=$1&pname=$2 [L]
Above code will rewrite
http://www.3gphone.in/brandid/27/Acer
to
http://www.3gphone.in/products.php?brandid=27&pname=Acer
If your coding is fetching list from brandid then you have to pass it in URL.
Ohh man... Big code.
Try to minimize your question thread.
You will get more answers.Its bit tidy to read all your code.
suppose a user check the checkbox & there is some validation error while submiting,
Are you validating form in PHP side?