Monday, June 30, 2014
PERCENT FROM MYSQL DATABASE
PERCENT FROM MYSQL DATABASE
SELECT group_name, employees, surveys, COUNT( surveys ) AS percentage,
((COUNT( * ) / ( SELECT COUNT( * ) FROM db_test)) * 100 ) AS percentage
FROM db_test
ORDER BY surveys
SELECT group_name, employees, surveys, COUNT( surveys ) AS percentage,
((COUNT( * ) / ( SELECT COUNT( * ) FROM db_test)) * 100 ) AS percentage
FROM db_test
ORDER BY surveys
PERCENT FROM MYSQL IN A GIVEN VALUE
PERCENT FROM MYSQL IN A GIVEN VALUE
voter total count
Nominees
% Allocation to Max 3 members
Joann
%
Lee
%
Aab
%
Neon
%
--
==============================================================================================================================
Red = Over budget | Yellow = read only zone
++++++++++++++++++++++++++++++++++++++++++++++++++++++
Stock
Buy Price
Increase
Total Buy
Sell Price
Decrease
Total Sold
Result
PERCENT MARKS CALCULATE IN MYSQL
PERCENT MARKS CALCULATE IN MYSQL
select avg(marks)
from exam-class-section-subject-student
where student_ID = @yourInput
select avg(marks)
from exam-class-section-subject-student
where student_ID = @yourInput
select student_ID, avg(marks)
from exam-class-section-subject-student
group by student_ID
PERCENT FROM MYSQL
PERCENT FROM MYSQL
mysql_select_db("freeskat_promail") or die(mysql_error());
$result = mysql_query("SELECT *
FROM `users`
WHERE `user8` LIKE '%Georgia%'
");
$num_rows = mysql_num_rows($result);
echo $num_rows - Georgia\n;
?>
mysql_select_db("freeskat_promail") or die(mysql_error());
$result = mysql_query("SELECT *
FROM `users`
WHERE `user8` LIKE '%Georgia%'
");
$num_rows = mysql_num_rows($result);
echo $num_rows - Georgia\n;
?>
mysql_select_db("freeskat_promail") or die(mysql_error());
$result = mysql_query("SELECT user8, COUNT(*) AS Total, SUM(in) AS TotalIn, SUM(in)*100/COUNT(*) AS Percent FROM lm_users GROUP BY user8
");
$num_rows = mysql_num_rows($result);
echo $num_rows \n;
?>
PHP CALCULATION FROM MYSQL
PHP CALCULATION FROM MYSQL
require_once('functions.php');
$user = new User;
if (!$user->isLoggedIn) {
die(header("location: login.php"));
}
$cid = $_GET['cid'];
$sql11 = "SELECT * FROM customer where cid = '$cid' ";
$result11 = mysqli_query($connect, $sql11);
$rs = mysqli_fetch_object($result11);
$ob = $rs->cob;
// select customer
$sql0 = "SELECT * FROM customer WHERE cid = '$cid'";
$result0 = mysqli_query($connect, $sql0) or die("Error: " . mysqli_error($connect));
$row0 = mysqli_fetch_array($result0);
//select sales num
$result2 = mysqli_query($connect, "SELECT * FROM tran WHERE cid='$cid' AND ssn != 0") or die("Error: " . mysqli_error($connect));
$row2 = mysqli_fetch_array($result2);
$n = mysqli_num_rows($result2);
//select receipt num
$result3 = mysqli_query($connect, "SELECT * FROM tran WHERE cid='$cid' AND rsn != '0'") or die("Error: " . mysqli_error($connect));
$row3 = mysqli_fetch_array($result3);
$n1 = mysqli_num_rows($result3);
$result4 = mysqli_query($connect, "SELECT sum(samt), sum(ramt) FROM tran WHERE cid='$cid'") or die("Error: " . mysqli_error($connect));
$row4 = mysqli_fetch_array($result4);
$TotalSales = $row4['sum(samt)'];
$TotalReceipt = $row4['sum(ramt)'];
$balance = $ob + $TotalSales - $TotalReceipt;
echo "
";// select tran
$sql = "SELECT * FROM tran WHERE cid = '$cid' ORDER BY date";
$result = mysqli_query($connect, $sql) or die("Error: " . mysqli_error($connect));
while($row = mysqli_fetch_array($result)) {
echo "
if ($row['sref'] > 0) {
echo "" . $row['sref'];
} else {
echo " ";
}
echo "
if ($row['rref'] > 0) {
echo "" . $row['rref'] . "";
} else {
echo " ";
}
echo "
"; if ($row['samt'] > 0) {
echo "
} else {
echo "
}
if ($row['ramt'] > 0) {
echo "
} else {
echo "
}
echo "
"
"; }
echo "
";?>
SEARCH MULTIPLE TABLE IN HTML
SEARCH MULTIPLE TABLE IN HTML
Please dont live any blank space while searching
Search Reservation Number
**this part is the searching
searchresult.php**
$table=$_POST['table'];
$search=$_POST['search'];
if ($search == "" or $table=="")
{
echo" back ";
echo "You forgot to enter the reservation number";
exit;
}
$dbhost = 'localhost';
$dbuser = 'europcar_msic';
$dbpass = 'msictran';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'europcar_msic';
mysql_select_db($dbname);
if ($table=="cd")
{
$sql = mysql_query("select * from cd where Rnum like '$search'");
}
if ($table=="sd")
{
$sql = mysql_query("select * from sd where Rnum like '$search'");
}
if ($table=="ch")
{
$sql = mysql_query("select * from ch where Rnum like '$search'");
}
if ($table=="pudo")
{
$sql = mysql_query("select * from pudo where Rnum like '$search'");
}
if ($table=="sdti")
{
$sql = mysql_query("select * from sdtexas where Rnum like '$search'");
}
if ($table=="chti")
{
$sql = mysql_query("select * from chtexas where Rnum like '$search'");
}
if ($table=="cdti")
{
$sql = mysql_query("select * from cdtexas where Rnum like '$search'");
}
if ($table=="pudoti")
{
$sql = mysql_query("select * from pudotexas where Rnum like '$search'");
}
while ($row=mysql_fetch_array($sql))
{
echo "
echo "
echo "
"; echo "
"; echo "
"; echo "
"; echo "
"; echo "
"; echo "
"; echo "
"; echo "
"; echo "
"; echo "
"; echo "
"; echo"
echo" back ";
echo"
echo "
echo "
echo "
echo "
echo "
echo "
echo "
echo "
echo "
echo "
echo "
echo '
';
}
//This counts the number or results - and if there wasn't any it gives them a little message explaining that
$anymatches=mysql_num_rows($sql);
if ($anymatches == 0)
{
echo" back ";
echo "Sorry,Invalid Reservation Number or you are looking at the wrong place double check the number and search it again";
}
{
}
?>
SEARCH Php Code Search & Display Record in HTML
SEARCH Php Code Search & Display Record in HTML
// Find out which form/action we need to load. I have created some
// hidden input fields to help identifying the forms.
// echo 'The following data has been submitted:
'; print_r($_POST); echo '';
if(!$_POST['form_name'])
//if(!$_POST['search'])
{
//* No search query has been submitted yet. Display the search form.
?>
Search
}
elseif($_POST['form_name'] == 'search' && $_POST['search'])
{
//* The search form has been submitted. Display the update form(s).
$search = $_POST["search"];
$result = mysql_query("SELECT * FROM saudi_journal WHERE SO like '%$search%'")or die(mysql_error());
while($row = mysql_fetch_array($result))
{
?>
Author
Title
Source
Fulltext Link
}
}
elseif($_POST['form_name'] == 'update')
{
//* The update form has been submitted. Update the database.
// Let's see if we actually arrive at this part:
$RID = $_POST['RID'];
$AU = $_POST['AU'];
$TI = $_POST['TI'];
$SO = $_POST['SO'];
$FULTEXT = $_POST['FULTEXT'];
// In your query, $FULTEXT is probably null, or does it get defined somewhere else?
$query = "UPDATE saudi_journal SET AU ='$AU' , SO='$SO', FULTEXT='$FULTEXT' WHERE RID = '$RID'";
//echo 'The query that was executed, is as follows:
' . $query . '
';
mysql_query($query);
$error = mysql_error();
if($error)
echo $error;
else
echo "
**
// I need the search form back after this messege
}
?>
SEARCH HTML TABLE in HTML
SEARCH HTML TABLE
include ('connect.php');
error_reporting(E_ALL);
ini_set('display_errors', '1');
$submit = $_GET['submit'];
$search = $_GET['search'];
$x=0;
$construct='';
$foundnum=0;
if (!$submit)
echo "you didnt submit a keyword.";
else
{
if (strlen($search)<=2)
echo "search term to short.";
else
{
echo " You searched for $search
";
//connect to our database
$search_exploded = explode(" ",$search);
foreach($search_exploded as $search_each)
{
// construct query
$x++;
if ($x==1)
$construct .= " location LIKE '%$search_each%'";
else
$construct .= " OR location LIKE '%$search_each%'";
}
// echo out construct
$construct = "SELECT * FROM flats WHERE $construct";
$run = mysql_query($construct);
$foundnum = mysql_num_rows($run);
if ($foundnum==0)
echo "No results found.";
else
{
echo "$foundnum result found!";
while ($runrows = mysql_fetch_assoc($run))
{
// get data
$select = $runrows['type'];
$title = $runrows['title'];
$location = $runrows['location'];
$rent = $runrows['rent'];
$description = $runrows['description'];
$contactEmail = $runrows['contactEmail'];
$number = $runrows['number'];
echo "
$title
$select
$rent
$location
$description
$contactEmail
$number
";
}
}
}
}
?>
Sunday, June 29, 2014
Subscribe to:
Posts (Atom)