hi check your form action you are sending your data in a .html file try making a .php file
ehpratah 48 Posting Whiz in Training
ehpratah 48 Posting Whiz in Training
ehpratah 48 Posting Whiz in Training
hi check your form action you are sending your data in a .html file try making a .php file
you are assigning a number when you use = only. try Using == iN yOUr if statement not = like $row['roleID'] == 1
Hi one simple solution is use windows.confirm javascript just put your delete query inside the js like
<script>
if (window.confirm('are you sure you want to delete this data?')) {
.. your delete query
}else{
do anything
}
</script>
Hi you can use a condition statement inside your query that check whether your row contain the data that you wanna count..
SELECT
COUNT(DISTINCT CASE WHEN approved = '0' THEN id END) 'zero',
COUNT(DISTINCT CASE WHEN approved = '1' THEN id END) 'ones'
FROM business_details
your script pls?
Can you post the connection.php? also change $_POST['password'] to $_POST['n_password'] as password is not define
from
if(isset($_POST['old_password']) && isset($_POST['password']) && isset($_POST['new_password']))
to
if(isset($_POST['old_password']) && isset($_POST['n_password']) && isset($_POST['new_password']))
try removing ". sign on line 97 like this and retry
$change_pass = "UPDATE users SET user_pass = '$new_pass' WHERE user_name = '$_SESSION[user_name]'";
An Ajax reload would be great
hi a simple solution to that is when the user click submit direct the user to your form.php and after the process in form.php is completed redirect the data from form.php to form1.php. you can use several approch to achieve this the most simple one is use GET to pass the data from form to form1 using the url which will look like this
form1.php?name=Michael Jordan&age=100
and another way is to use session like
form.php
<?php
session_start();
$name=$_SESSION['Sess_name'] = $_GET['name'];
$age=$_SESSION['Sess_age'] = $_GET['age'];
?>
form1.php
<?php
session_start();
echo $_SESSION['Sess_name'];
echo $_SESSION['Sess_age'];
?>
Hi Try something like this
$mysql_hostname="localhost";
$mysql_database="";
$mysql_user="";
$mysql_password="";
$con = mysqli_connect($mysql_hostname,$mysql_user, $mysql_password, $mysql_database);
$name=trim(mysql_real_escape_string($_POST['name']));
$sql=("CREATE TABLE IF NOT EXISTS `$name` ( `sender` varchar(30), `message` varchar(300), `dateposted` date )");
if (mysqli_query($con,$sql)) {
echo "Table $name created successfully";
} else {
echo "Error creating table: " . mysqli_error($con);
}
and refer to this link
Got It..
I use IF statement inside the query like this
SELECT SDate,
SUM(IF(Payment_type = 'Cash', Grand_total, 0)) AS 'Cash',
SUM(IF(Payment_type = 'Credit', Grand_total, 0)) AS 'Credit Card',
SUM(IF(Payment_type = 'Bill', Grand_total, 0)) AS 'Bill',
SUM(Grand_total) AS Total FROM info WHERE SDate BETWEEN '2014-05-18' AND '2014-05-19' GROUP BY SDate
Hi Do you mean
("select SDate, Payment_type, SUM( Grand_total ) AS 'total_daily' from info WHERE SDate BETWEEN '2014-05-18' AND '2014-05-19' GROUP BY `SDate`, Payment_type")
Still not getting it.
How can i put it in my table? normally you just put the rows value like $rows['Cash'] $rows['Credit'] and $rows['Bill'] in your TD. but for me this rows doesnt exist. when i tried adding the payment type in the Group by clause the group by date is not working. what am i doing wrong?
Hi all
I need some advice making my query work properly. I already played around it a dozen of times and still can't get it work. So as my last option im here:) . what im trying to achieve is sum all amount of a particular rows and display the Grandtotal which is working fine but I get stuck in this last requirement which is.. see screenshot below as I cant really explain it properly..:D
here are my table dump
CREATE TABLE IF NOT EXISTS `info` (
`SDate` varchar(255) NOT NULL,
`Grand_total` varchar(255) NOT NULL,
`Payment_type` varchar(7) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
--
-- Dumping data for table `info`
--
INSERT INTO `info` (`SDate`, `Grand_total`, `Payment_type`) VALUES
('2014-05-18', '100', 'Cash'),
('2014-05-18', '200', 'Cash'),
('2014-05-18', '200', 'Bill'),
('2014-05-19', '100', 'Credit ');
and my test page
<?php
include 'config.php';
$query = ("select SDate, Payment_type, SUM( Grand_total ) AS 'total_daily' from info WHERE SDate BETWEEN '2014-05-18' AND '2014-05-19' GROUP BY `SDate`");
$string = '';
echo "<table border='1' width='50%' color='green'>
<tr>
<th width='5%' align='center'>Trans. Date</th>
<th width='5%' align='center'>Cash</th>
<th width='5%' align='center'>Credit Card</th>
<th width='5%' align='center'>Invoice</th>
<th width='5%' align='center'>Daily Sales</th>
</tr>";
if ($result=mysqli_query($con,$query))
{
$Grandtotal=0;
while($rows = mysqli_fetch_assoc($result))
{
$Grandtotal += $rows['total_daily'];
$string .= "<tr>
<td align='center'>".date("M d, Y", strtotime($rows['SDate']))."</td>
<td align='center'></td>
<td align='center'></td>
<td align='center'></td>
<td align='center'>".$rows['total_daily']."</td></tr> ";
}
}
echo $string;
echo"</table><br><br>";
echo "<BR><b>Grand Total: $Grandtotal";
?>
Hope you that you can help me
thanks
Neil
On line 46 change header('Location: http://www.google.com/');
to
echo'<script>window.location.href="https://www.google.com.ph"; </script>';
unfortunately remote mysql is not available on my Cpanel. i just ask my provider to whitelist and allow my ip so i can connect to mysql data.
Good day everyone Not sure if this is the right place to ask this but im trying to connect to my database online "Control Panel of my hosting site" from my local machine basically the webpage is running locally. but i want the data to be fetch online. my question is do i need to configure my CP? if yes what do i need to change?
heres the config That im working with
$mysql_hostname="***.***.*.***"; // IP ADD OF MY CP i also tried the webaddress
$mysql_database="****";
$mysql_user="****";
$mysql_password="***";
$con = mysqli_connect($mysql_hostname,$mysql_user, $mysql_password, $mysql_database);
mysqli_select_db($con,"svcseuro_nwh")or die(mysql_error());
date_default_timezone_set('Asia/Manila');
the original config on localhost is
$mysql_hostname="localhost";
$mysql_database="nwh";
$mysql_user="nwh";
$mysql_password="password";
$con = mysqli_connect($mysql_hostname,$mysql_user, $mysql_password, $mysql_database);
mysqli_select_db($con,"svcseuro_nwh")or die(mysql_error());
date_default_timezone_set('Asia/Manila');
thanks neil
Hi have you tried using js for redirection? just for debugging purpose try
window.location.href="thankyou.php";
see if its working
Hi Sorry about that its just that i am using it here in philippines and have no problem when it comes to leaf year or daylight. anyway base on the manual.
date_default_timezone_set('Asia/Manila');
$startdate=date_create("2014-03-30");
$endDate=date_create("2014-04-02");
$diff=date_diff($startdate,$endDate);
echo $diff->format("%a");
You can try
$endDate='2014-04-11';
$startdate='2014-04-01';
$daydiff = floor( ( strtotime( $endDate ) - strtotime( $startdate ) ) / 86400);
echo $daydiff;
it will count the day difference between the 2 dates
there are really other way to do it. i just show you a simple solution. can you elavorate what your trying to achieve without using this and this. from what i understand you just wanna know what page send the contact info and when the info is emailed succesfully it will return to the form where the info originated.
hi you can use something like an identifier that will be send together with the data in contactsGo.php where you will use a simple IF statement to check if the data is from that specific form or not. and base on the IF Statement you can use a simple header redirect
something like
if ($identifier=="from_form1"){
header("Location: form1.php")
}
else{
header("Location: form2.php")
}
want an honest answer? You Can't. if you have an answer Pls DO share it with US....
Hi Just echo your submitted data in another page if you want something like a preview page before inserting it to DB as rhodoscoder suggested..
something like
preview.php
<?php
echo $_POST['name'];
?>
Hi for client side you can add Javascript for form validation. when the submit button is click it will check your form element if its is empty or not..or if your using html5 just use the new required attribute and for a server side validation use (PHP) just to be sure.
for html5<input type="text" name="name" required>
for the JS Part something like this
<script language="javascript">
function validate()
{
var x=document.forms["formname"]["name"].value;
if (x==null || x=="" )
{
alert("Name is Required");
return false;
}
var x=document.forms["formname"]["email"].value;
else if (x==null || x=="" )
{
alert("email is Required");
return false;
}
var x=document.forms["formname"]["phone"].value;
else if (x==null || x=="" )
{
alert("phone is Required");
return false;
}
var x=document.forms["formname"]["message"].value;
else if (x==null || x=="" )
{
alert("message is Required");
return false;
}
}
</script>
and for the php validation part just convert it to php:D
usually when you want to redirect to a page automatically you just need to put a header tag after your email been send like
header("Location:index.php");
Hi if your gonna insert new data in the db why are you using UPDATE query?
you need to use INSERT query like
$query= "INSERT INTO studio(name,phone,`date`,time_from,time_till,studio) VALUES ('$name','$phone','$date','$time_from','$time_till','$studio')";
also mysql_real_escape_string is already deprecated refer to this link and you better use mysqli or pdo for the same reason
then u better find someone that is willing to write it for you. coz no one here will just shove the answer in your mounth. better yet show us what u have and lots of guys here will be willing to help you out.
@João_5 i revise my script to this
<td align='center'>
<a href='#' onclick=window.open('overview.php?id=".$rows['Id']."','mywindow','menubar=0,resizable=0,width=600,height=615')>".$rows['RA']."
</td>
notice that im not using the js function win() antmore
Nevermind guys found a way already:)
Thanks neil,
Good Day Guys
Im Having a hardtime getting this simple script working, basically im trying to open pop up windows when a link is click(which work fine until i found out that the same data is being fetch over and over again which is the last data inserted in the DB)
this the part of the script
while ($rows = mysql_fetch_assoc($query))
{
echo"
<script language='javascript'>
function win()
{
window.open('overview.php?id=$rows[Id]','Window3','menubar=no,width=600,height=610,toolbar=yes,scrollbars=yes,');
}
</script>";
echo "
<tr>
<td align='center'><a href='javascript:win()' >".$rows['RA']."</td>
<td width='12%'>".$rows['Name']."</td>
<td>".date('j F, Y', strtotime($rows['SDate']))." / ".$rows['Time']."</td>
<td align='center'>".$rows['Service']."</td>
<td width='3%'>".$rows['Remarks']."</td>
</tr> ";
}
What am i doing wrong?
Thanks neil,
@pritaeas - thanks for the suggestion i'll give it a try and see the difference on the bandwidth consumption
@paulks
What is it's purpose in refreshing every 10 seconds?
one of my page have this function that change color if the serving time is less than 1hr before the actual time the service will be rendered, also i need to keep track of newly process reservations status and No im not recording it..
Good Day Guys
So im having this issue with this site that i develop which is running 24/7 that eats a huge amount of bandwidth every time the page reload every 10sec using META TAG that is affecting our operations specifically our net connection. What i wanna know is if i switch to a AJAX reload would it solved my problem? Hope to hear you're opinion about it so i can made the necessary changes as soon as possible.
Thanks Neil
Sorted it out using different approach..
Good Day everyone
I have 3 forms index.html , parent.html and popup.html just wondering how can i close parent.html and redirect it to index.html when the popup.html submit button is click? i already tried searching on google but i cant get any clear solution on how to achieved it. i know that i would be needing js to make it possible but it seems that i cant find any article on it. can anybody point me on the right track
Thanks
Hi as JorgeM said you need a js for it to be done...my suggestion is
like
on page load
<html>
<head>
</head>
<body onload="window.print()">
<?php
DATA FROM DB
?>
</body>
</html>
or using an image or button
<html>
<head>
</head>
<body>
<?php
DATA FROM DB
?>
<img src="printer.png" width="28" height="28" onclick="window.print()" />
<input type="button" value="Print this page" onclick="printpage()">
</body>
</html>
Hi as JorgeM and diafol said you need to check if the user has the rights to access a certain page you need something like
$level=$_SESSION['SESS_ACCESS_LEVEL'];
if($level=='1')
{
header("location: access-denied.php");
exit();
}
that would be result if you will be using a meta tag it will refresh the whole page.. ajax would be your best option in achieving this.
for it to show automatically you need a trigger to execute the query e.g page refresh or an ajax function that will refresh every x second . Care to shed us more details about it..? also can you show as your script ?
Hi what have you tried so far..?just a suggestion 1st make a html / Php file with 4 radio button per question for the selection of answer then another file to handle the process when the submit button is click.maybe if you can show us something to start of we can help you with your question but if your looking for a ready made script think again no one will go that far providing you everything..remember this is a forum site where different mind collaborate, everyone needs to participate in someway or another..
Hi can you show us a sample output base on your form..
hi guys so theres still hope for me.. i'll try what you both suggested and find a way to make it work.i'll be intouch if i have another question on this matter. until then thanks to both of you
hi thats what i keep on telling to my superior that its not possible to search between two date range with two diff time range. but he told me to find a way to make it happen such a pain...:((
Hi i have this query that search data between two date range
select RA, Name, Model, Plate, Service, Grand_total, Payment_type from advance WHERE SDate BETWEEN '" . $from . "' AND '" . $to . "' ORDER BY Payment_type
which is working great but i need to alter it so that it will also search for specific time range between that date range but seems not working properly
"select RA, Name, Model, Plate, Service, Grand_total, Payment_type from advance WHERE SDate BETWEEN '" . $from . "' AND '" . $to . "' AND Time BETWEEN '" . $fromtime . "' AND '" . $totime . "' ORDER BY Payment_type
my table structure for SDate is date and for Time is time
what am i doing wrong..?
Thanks for the link although i already found a way to do it..i made it playing around with my while loop and query like this
$sql = "SELECT Payment_type, sum(Grand_total) type_total FROM advance WHERE SDate BETWEEN '" . $from . "' AND '" . $to . "' GROUP BY Payment_type";
$result = mysql_query($sql);
while($row = mysql_fetch_array( $result )){
echo"<tr colspan='3'><td align='center' >Total ".$row['Payment_type']."</td><td align='center' width='1000px';>".$row['type_total'] ."</td></tr>";
}
echo"<tr colspan='3'><td align='center' >Grand Total</td><td align='center'>$total</td></tr>";
a lil bet messy but it make the work done
ok heres the link for it
http://s2.postimg.org/647493o6h/Untitled.jpg
still not having any good progress..
weired the snapshot is not clickable i'll attached it again here
sorry about that im trying to add snapshot on my post but its not showing.ill try again
the total cash, total charge, total invoice came from a specific date range that the user search in the db
Hey guys im here again with another question on how to solve this specific problem i have, Whic is also releated on my last thread which is http://www.daniweb.com/web-development/php/threads/461702/cant-combine-two-sql-statement .. so the question now is
i have this table
Name Payment_type Service_charge
test 1 Cash 10
test 2 Cash 20
test 3 Charge 100
test 4 Charge 100
test 5 Invoice 50
output is
total Cash: 30
total Charge: 200
totaL Invoice: 50
Grandtotal :280
I can already get the Grandtotal but i can find a way to get the total cash,charge and invoice
what query should i use..? do i need a computation to achieve this?what is the best and easiest way to do it..?without affecting much in my current sql queries
thanks in advance