ehpratah 48 Posting Whiz in Training

Hey Guys finally problem solve after 3 cups of coffee:))

for anyone out there that face or in the future will face the same issues as me and give up trying to make it work inside the query itself you can just put the computation inside the while loop like this and echo the total amount. simple as that yet took me almost 3hrs..:((

while($rows = mysql_fetch_assoc($query))
{


 $total += $rows['Grand_total'];




}
ehpratah 48 Posting Whiz in Training

Hi just a thought try putting the $_SESSION['id']=$row['id']; inside the while statement in your first script.

ehpratah 48 Posting Whiz in Training

So what should i do..?how do i assign it inside the query..?

when i try ORDER BY Payment_type AS payment not also assigning

this is my 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=iso-8859-1" />
<title>Untitled Document</title>
</head><body>
<?php
//$connection = mysql_connect('localhost', 'svcseuro_TRF', 'pcdoktor');
//$db = mysql_select_db('svcseuro_TRF', $connection);

$connection = mysql_connect('localhost', 'root', '');
$db = mysql_select_db('svcseuro_davao', $connection);

$from = $_POST['From'];
$to = $_POST['To'];
$from = mysql_escape_string($from); 
$to = mysql_escape_string($to); 

if($from=="" && $to=="")
echo "Enter Something to search";
else{
$query = mysql_query("SELECT SUM(Grand_total) AS `total` from advance where SDate between '" . $from . "' AND '" . $to . "' ORDER BY `Payment_type`" , $connection);


$string = '';

echo "<table border='1' width='100%' color='green'><tr><th width='5%'>Ref. No.</th><th width='5%'>Name</th><th width='5%'>Make</th><th width='5%'>Plate</th><th width='5%'>Service</th><th width='5%'>Service Fee</th><th width='5%'>Payment_type</th></tr>";

if (mysql_num_rows($query)){

while($rows = mysql_fetch_assoc($query))
{

$total=$rows['total'];


$string .= "<tr><td align='center'>".$rows['RA']."</td><td align='center'>".$rows['Name']."</td><td align='center'>".$rows['Model']."</td><td align='center'>".$rows['Plate']."</td><td align='center'>".$rows['Service']."<td align='center'>".$rows['Grand_total']."</td><td align='center'>".$rows['Payment_type']."</td></tr>";


}

}else{
$string = "No matches found!";
}

echo $string;


}

echo"<tr><td align='center'></td><td align='center'>&nbsp;</td><td align='center'></td><td align='center'></td><td align='center'><td align='center'></td><td align='center'></td></tr>";

?>
total:<?php echo $total;  ?>
</body>
</html>
ehpratah 48 Posting Whiz in Training

Hi guys im having a progress now when i run this query in my phpmyadmin

SELECT SUM(Grand_total) AS `total` from advance where SDate between '2013-08-01' AND '2013-08-24'

it is working but when in my actual page im having this error

Notice: Undefined index: RA in C:\xampp\htdocs\daterange\ifind.php on line 37

but the only thing that i add in my query is the ORDER BY

whick look like this

SELECT SUM(Grand_total) AS `total` from advance where SDate between '" . $from . "' AND '" . $to . "'  ORDER BY  `Payment_type`

any idea what happening..?

ehpratah 48 Posting Whiz in Training

Hi there are tons of good tut our there on d net regarding forms and email you just need to pick the simpliest one

heres a good sample

http://www.freecontactform.com/email_form.php

try not just to copy it but also understand whats the meaning of very line

also you need to configure first your php.ini if your working locally

http://roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.html

ehpratah 48 Posting Whiz in Training

Good Day everyone(even if its already 10pm here) i know its seems very easy to some of you guys but seems i cant get an hold onto it.. so i have this query that search data between 2 date range(which is working fine) and another query that add all data from a specific field in my table(whic is also working). The thing is now what i needed to do is to combine the two queries in one

here's the first query

select * from advance WHERE SDate BETWEEN '" . $from . "' AND '" . $to . "'  ORDER BY  `Payment_type`

and the other

select SUM(Grand_total) AStotal_sales_todayfrom advance

thanks

ehpratah 48 Posting Whiz in Training

Hi Guys, been very busy the past few days..thank you all for your time helping me out..my question is already answered and i just stick with what i came up base on your suggestions which is this one

    $gas=$POST['Fuel'];
    if($gas!=0){
    echo"Gas:$gas";
    }
    else{
    }
ehpratah 48 Posting Whiz in Training

hi first you need to change you form action

from
<form action="#" method="post" id="sendemail">
to

<form action="youraction.php" method="post" id="sendemail">

then can you show as your script on sending email as you've said you already have the script for it and by the way what you've posted is not yet the code its just markup..we need to see your actual script the one that will process all the data that the user inputted on your form.

ehpratah 48 Posting Whiz in Training

OK. I've had forms like this in the past and have wondered "do I really need the checkbox?" if the user enters a value in the text box would this be enough to say that they have selected "Gas: 200" ?

hi do you mean something like this?

in my process form i'll make an if statement something like

$gas=$POST['Fuel'];

if($gas!=0){
echo"Gas:$gas";
}
else{

}

well haven't tested it yet but i thing this will work..thanks for the idea guys

ehpratah 48 Posting Whiz in Training

Hi everyone thanks by the way for all your response and sorry for the late update having a really nasty weather here in our place.

Does you page use JavaScript to add a text field if a checkbox is checked?

yes my form do have js for showing the textbox

Also, please provide your HTML and form processing code so we can see where you're having a problem.

the part im having problem right now is getting the grasp on how can i make only the checkbox with value show in my process form. im still lost on how can i make it work..

here is my form by the way

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script language="javascript">
$(function() {

  // hide all text inputs
  hideAllTextInputs();

  // radio click
  $("ul input[type='checkbox']").click(function() {

    // current <li>
    var li = $(this).closest("li");

    // show it's text
    li.find("input[type='text']").show();

    // hide all again
    hideAllTextInputs();
  });

});

function hideAllTextInputs() {
  // hide all text inputs
  $("ul input[type='checkbox']")
    .not(":checked")
    .closest("li")
    .find("input[type='text']")
    .hide();
}
</script>
<meta charset=utf-8 />
<title></title>
  <style>
    ul { list-style: none; }
    ul li { line-height: 26px; }
  .style1 {
    font-size: 14px;
    color: #FF0000;
}
  </style>
</head>
<body>
<span class="style1">Add Ons</span>
<form name="form1" method="post" action="process.php">
  <ul>
    <li>
      <label for="fuel">
        <input type="checkbox" id="Fuel" name="Fuel" /> Gas
      </label>
      <input type="text" id="Gasprice" name="Gasprice" />
    </li>
    <li>
      <label for="toll">
        <input type="checkbox" id="Tollfee" name="Tollfee" /> Toll Fee
      </label>
      <input type="text" id="Tollprice" name="Tollprice" />
    </li>
    <li>
      <label for="gps">
        <input type="checkbox" id="GPS" name="GPS" /> GPS …
ehpratah 48 Posting Whiz in Training

Hi No im not using db. the intended process of that is when you check the checkbox the textbox will be shown and the user will input a value which is easy. but the tricky part for me is just to show only the selected checkbox on the preview page without the others

ehpratah 48 Posting Whiz in Training

Move this from JavaScript / DHTML / AJAX

Good Day everyone i'm having a hardtime figuring out how to make this certain idea of mine to work basically im trying to capture the checkbox value and its label but im not getting anyluck..and also im having problem explaning what im trying to do so i decided to attached an image of what will be the output..

Im not asking for any script but just an idea how can i achieved it but if somebody's generous enough i wont reject it either:))

the form part 9ba01e73fbf743c827029b1c945651c1

and the expected result

40d3fe71abf64af739553febc1e2461c

ehpratah 48 Posting Whiz in Training

Good Day everyone i'm having a hardtime figuring out how to make this certain idea of mine to work basically im trying to capture the checkbox value and its label but im not getting anyluck..and also im having problem explaning what im trying to do so i decided to attached an image of what will be the output..

Im not asking for any script but just an idea how can i achieved it but if somebody's generous enough i wont reject it either:))

44466e83794f8593d7208aa8a7b889f9

ehpratah 48 Posting Whiz in Training

ok no prob..the array is not really the issue but my IF and OR statement

this part or specifically the $service

if ((in_array($destination, $destination_10_to_12km_away) && ($branch=="Davao International Airport") && ($service=="Transfer In") || ($service=="Drop Off") && ($vehicle=="Vios")))

the correct statement is this one

if(in_array($destination, $destination_10_to_12km_away) && ($branch=="Davao International Airport") && ($service=="Transfer In" || $service=="Drop Off") && ($vehicle=="Vios"))

notice the $service it is included in just one ( )

and also i just combine the two if statement in one

pritaeas commented: Thanks for sharing. +14
ehpratah 48 Posting Whiz in Training

He guys nevermind figured out already the problem...

thanks anyway

ehpratah 48 Posting Whiz in Training

Good Day everyone

im having trouble in script right now basically im trying to make an if statement that will assign rate base on the destination, branch ,service and vehicle. which is working fine just a moment ago but when i add another array for another destination it seems that its not using the assigned array but keeps on using the first assigned array

heres the script

`

    $destination ="SM";
    $branch = "Davao International Airport";
    $service = "Transfer In";
    $vehicle = "Vios";
    $destination_10_to_12km_away = array( "WATERFRONT HOTEL" => "WATERFRONT HOTEL",
     "HOTEL ELENA" => "HOTEL ELENA",
      "GRAND REGAL HOTEL" => "GRAND REGAL HOTEL", );

     $destination_13_to_15km_away = array( "MATINA CROSSING" == "MATINA CROSSING",
     "GSIS SUBDIVISION" => "GSIS SUBDIVISION",
      "TIBUNGCO" => "TIBUNGCO",
       "COCA-COLA PLANT" => "COCA-COLA PLANT",
        "ROYAL VALLEY" => "ROYAL VALLEY",
         "SM" => "SM", );


if ((in_array($destination, $destination_10_to_12km_away) && ($branch=="Davao International Airport") && ($service=="Transfer In") || ($service=="Drop Off") && ($vehicle=="Vios"))){
    $rate="350";
    }
   else if ((in_array($destination, $destination_10_to_12km_away) && ($branch=="Davao International Airport") && ($service=="Transfer In") || ($service=="Drop Off") && ($vehicle=="Innova"))){
    $rate="450";
   }
   else if ((in_array($destination, $destination_10_to_12km_away) && ($branch=="Davao International Airport") && ($service=="Transfer In") || ($service=="Drop Off") && ($vehicle=="Van"))){
    $rate="600";
   }
   else{
   $rate="00";
   }

 if ((in_array($destination, $destination_13_to_15km_away) && ($branch=="Davao International Airport") && ($service=="Transfer In") || ($service=="Drop Off") && ($vehicle=="Vios"))){
    $rate="450";
    }
   else if ((in_array($destination, $destination_13_to_15km_away) && ($branch=="Davao International Airport") && ($service=="Transfer In") || ($service=="Drop Off") && ($vehicle=="Innova"))){
    $rate="550";
   }
   else if ((in_array($destination, $destination_13_to_15km_away) && ($branch=="Davao International Airport") && ($service=="Transfer In") || ($service=="Drop Off") && ($vehicle=="Van"))){
    $rate="650";
   }
   else{
   $rate="00";
   }


   echo $rate;

`

ehpratah 48 Posting Whiz in Training

Hi you can use google charts its easy to integrate to your php and mysql script as mmc told you need javascript to accomplish it although you can also use plane php to achieved it but i will not really recommend it..

ehpratah 48 Posting Whiz in Training

ok thanks got it...

ehpratah 48 Posting Whiz in Training

Hey thanks for the help..getting it now. although my problem is already answered just wondering am i doing it correctly or theres is an alternative solution for this?

ehpratah 48 Posting Whiz in Training

Good Day Everone

Just wanna ask for a suggestion if it is possible to Save data in DB and at the same time Print the form when the submit button is clicked? and if possible how can i obtain it?

Here's what ive tried

form.php

<!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=iso-8859-1" />
<title>test</title>
<style type="text/css">
<!--
.style1 {
    font-size: 18px;
    font-weight: bold;
}
-->
</style>
</head>

<body>
<span class="style1">Sample RA</span><br><br>
<form action="save.php" method="post">
I <input name="Name" type="text"  placeholder="State your Name"/> certified that the info on this form is true and legitimate<br><br><br>
<input name="" type="submit"  value="Print/Save"/>


</form>
</body>
</html>

and this part is the Save file

<?php

    require_once('config.php');



    $errmsg_arr = array();


    $errflag = false;


    $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
    if(!$link) {
        die('Failed to connect to server: ' . mysql_error());
    }


    $db = mysql_select_db(DB_NAME);
    if(!$db) {
        die("Unable to select database");
    }


    function clean($str) {
        $str = @trim($str);
        if(get_magic_quotes_gpc()) {
            $str = stripslashes($str);
        }
        return mysql_real_escape_string($str);
    }


    //Sanitize the POST values

    $name = clean($_POST['Name']);


    $sql="INSERT INTO data(name) VALUES('$name')";

if (!mysql_query($sql,$link))
  {
  //ERROR MESSAGE
 echo "<script type='text/javascript'>alert('There was an error processing your request, Please Try Again'); window.location.href = 'index.php';</script>";
  }

  //SUCCESS WILL REDIRECT TO PRINT.php ///////////////////////////
header("location:print.php");




mysql_close($conn)

?>

and the print file

<!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=iso-8859-1" />
<title>test</title>
<style type="text/css">
<!--
.style1 {
    font-size: 18px;
    font-weight: bold;
}
-->
</style>
</head>

<body onload="window.print()"> …
ehpratah 48 Posting Whiz in Training

How about www.w3schools.com

ehpratah 48 Posting Whiz in Training

Hi everyone just got back from a Goodnight sleep. thank you all for the effort and response to my SOS i really appreciate it so much...its working fine now using Zagga script..thank you all again:))

ehpratah 48 Posting Whiz in Training

Still not having the right result

here's a more simplier script

<?php

date_default_timezone_set('Asia/Manila');
$current_time= "18:05";
$serving_time="18:00";
if (strtotime($current_time) >= (strtotime($serving_time) - 3600 ))
{
echo "red";
}
    else if (strtotime($current_time) >= (strtotime($serving_time) - 3900 ))
{
echo "orange ";
}
else
{
echo "default";
}

?>
ehpratah 48 Posting Whiz in Training

hi i tried putting = sign already but still no luck yes it is better if it will change back to default when the time is 18.06 but even the else statement is not working its always in red color

ehpratah 48 Posting Whiz in Training

Hey Everyone

Im having a lil trouble rightnow making this script work. What im trying to do is make a script that will change the bgcolor color to red if the Serving time is less than or equal to 1 hr left which is working now but in the long run while testing the script i found a bug which is if the current time is already 5min past the Serving time the bgcolor needs to turn to color orange. but its not working properly

Here's the script

 <?php 
    date_default_timezone_set('Asia/Manila');
    $current_time= "18:10";
    $serving_time="18:05";


    if (strtotime($current_time) >= (strtotime($serving_time) - 3600 ))
    {

    echo "<tr bgcolor='red'><td align='center'>".$rows['FO']." / ".$rows['FoName']."/ ".$rows['Branch']."</td><td align='center'>".$rows['RA']."</td><td>".date('j F, Y', strtotime($rows['SDate']))." / ".$rows['Time']."</td><td align='center'>".$rows['Vehicle']."</td><td align='center'>".$rows['Service']."</td><td width='12%'>".$rows['Name']."</td><td align='center'>".$rows['Room']."</td><td align='center'>".$rows['Flight']."</td><td width='18%'>".$rows['Destination']."</td><td width='15%'>".$rows['Via']."</td><td width='8%'>".$rows['Remarks']."</td></tr> "; 


    }
    else if (strtotime($current_time) > (strtotime($serving_time) - 3900 ))

    {

    echo "<tr bgcolor='orange'><td align='center'>".$rows['FO']." / ".$rows['FoName']."/ ".$rows['Branch']."</td><td align='center'>".$rows['RA']."</td><td>".date('j F, Y', strtotime($rows['SDate']))." / ".$rows['Time']."</td><td align='center'>".$rows['Vehicle']."</td><td align='center'>".$rows['Service']."</td><td width='12%'>".$rows['Name']."</td><td align='center'>".$rows['Room']."</td><td align='center'>".$rows['Flight']."</td><td width='18%'>".$rows['Destination']."</td><td width='15%'>".$rows['Via']."</td><td width='8%'>".$rows['Remarks']."</td></tr> ";

    }
    else
    {
    echo "<tr><td align='center'>".$rows['FO']." / ".$rows['FoName']."/ ".$rows['Branch']."</td><td align='center'>".$rows['RA']."</td><td>".date('j F, Y', strtotime($rows['SDate']))." / ".$rows['Time']."</td><td align='center'>".$rows['Vehicle']."</td><td align='center'>".$rows['Service']."</td><td width='12%'>".$rows['Name']."</td><td align='center'>".$rows['Room']."</td><td align='center'>".$rows['Flight']."</td><td width='18%'>".$rows['Destination']."</td><td width='15%'>".$rows['Via']."</td><td width='8%'>".$rows['Remarks']."</td></tr> ";
    }





    ?>
ehpratah 48 Posting Whiz in Training

Hi i've tried what you told on on the first post and separated my js and php and it came up with a better and understandble script but im having some issue regarding your second post. I cant get the head and tails out of it can you elaborate it clearly..

by the way here's my current 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" />

<link href="jquery.notice.css" type="text/css" media="screen" rel="stylesheet" />
  <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js' type='text/javascript'></script>
            <script src='jquery.notice.js' type='text/javascript'></script>


     <?php

    date_default_timezone_set('Asia/Manila');
    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpass = '';

    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die 

    ('Error connecting to mysql');

    $dbname = 'newworld';
    mysql_select_db($dbname);
        //get the function



               $date=date('Y-m-d ');
              $query = mysql_query("SELECT * FROM advance where Guest_type='VIP' AND SDate= '" . $date . "' ");

                while ($rows = mysql_fetch_assoc($query))
                  {
                 if($rows['A1_Time']!=='00:00:00' || $rows['A2_Time']!=='00:00:00')
                       {
                       $a1=$rows['A1_Time']; // time of arrival to a designated 1ST AREA
                       $a2=$rows['A2_Time']; // time of arrival to a designated 2ND AREA
                       $name=$rows['Name'];
                   ?>


               <script type='text/javascript'>

               var name='<?php echo $name ?>';

               $(document).ready(function(){
               jQuery.noticeAdd({
               text: ' Name is '+ name,
               stay: true});
               });
               </script>

             <?php
             }
             }

             ?>



</body>
</html>

just the same still just dispalying 1 Name two times..

thanks

ehpratah 48 Posting Whiz in Training

Hi thanks i'll try what you've told me and be back when i have another question or something not making any sense with what im doing..

ehpratah 48 Posting Whiz in Training

Hi Guys wanna ask some assistance/ help

I'm making something like notification with jquery and php and its working fine now the only problem that i encounter is on the notification its only show one data repeatedly its not showing the other data that supposed to be showed

Here's my script on showing the notification

<!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" />

<link href="jquery.notice.css" type="text/css" media="screen" rel="stylesheet" />


     <?php

    date_default_timezone_set('Asia/Manila');
    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpass = '';

    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die 

    ('Error connecting to mysql');

    $dbname = 'newworld';
    mysql_select_db($dbname);
        //get the function


            $page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
            $limit = 10;
            $startpoint = ($page * $limit) - $limit;


            //to make pagination
            $statement = "`advance` where `active` = 1 ";
            $date=date('Y-m-d '); // Current Date
              $query = mysql_query("SELECT * FROM advance where Guest_type='VIP' AND SDate= '" . $date . "'  ORDER BY Id DESC LIMIT {$startpoint} , {$limit}");

                while ($rows = mysql_fetch_assoc($query))
                {
            if($rows['A1_Time']!=='00:00:00' || $rows['A2_Time']!=='00:00:00')
            {
              $a1=$rows['A1_Time']; // time of arrival to a designated 1ST AREA
              $a2=$rows['A2_Time']; // time of arrival to a designated 2ND AREA
              $name=$rows['Name'];



              echo"<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js' type='text/javascript'></script>";
             echo "<script src='jquery.notice.js' type='text/javascript'></script>";
              echo"<script type='text/javascript'> ";

             echo"var name='$name '; ";




              echo "$(document).ready(function()";
               echo"{";

                echo"jQuery.noticeAdd({text: ' Name is '+ name
                ,stay: true}); ";


        echo"});";
    echo"</script>";


            }

            else
            {

            }

            ?>


        <?php    
                }
            ?>



</body>
</html>

In my query it supposed to display

Name is Kurosaki Ichigo

Name …

ehpratah 48 Posting Whiz in Training

hi just add another variable on the js which contain the php variable like this

<?php
$meat="cow";

?>
<script type="text/javascript">
var meat="<?php echo $meat; ?>";
document.write(meat);
</script>
ehpratah 48 Posting Whiz in Training

you should put first the form inside a div and add a javascript to print only the object inside the div you can search google or other search engine to give you some ideas on how to do it..

ehpratah 48 Posting Whiz in Training

i dont get what you're saying..if you just wanna retain the value of the textfield after submittion you just need to put in the textfield value like value="<?php echo "$tS"; ?>"

like this

 <input type="text" name="tString1" value="<?php echo"$ts"; ?>"/>
ehpratah 48 Posting Whiz in Training

Hi i figured a way already by altering the query from this

    select * from advance WHERE Icm_active=2 AND RA like '{$term}%' OR CONCAT_WS(' ',SDate,'/',Time) like '{$term}%' OR Remarks like '{$term}%' ORDER BY Id DESC

to this

select * from advance where Icm_active=2 AND RA like '{$term}%' OR Icm_active=2 AND CONCAT_WS(' ',SDate,'/',Time) like '{$term}%' OR Icm_active=2 AND Remarks like '{$term}%'  ORDER BY Id DESC

literally the problem is solved but when you look into the query it has a repeated process my question is how to simplified the query?

ehpratah 48 Posting Whiz in Training

the CONCAT_WS() will just concatenate string with separator for me it is the " / " it is use to search date and time in the query

i tried it and its now working fine but when i add another search term its showing again all the data on my table

here's my whole query

select * from advance WHERE Icm_active=2 AND RA like '{$term}%' OR CONCAT_WS(' ',SDate,'/',Time) like '{$term}%'  OR Remarks like '{$term}%'  ORDER BY Id DESC

what i observed is if i only put one search term on the query its working fine but when i add another searchterm it will ony read the first search term before the AND statement and the other will not really be invoke but will dispaly all the data even the one that Active_view=1...seems that it is ignoring this part WHRE Icm_active=2 of the query

ehpratah 48 Posting Whiz in Training

OK got it..but still not showing the appropriate data any idea?

ehpratah 48 Posting Whiz in Training

Hi to all just wanna ask how to achieve something like on show all data if a certain field on the table is equal to 2. basically what im trying to make is a search form by the way the searching part is working it just that its showing all the data what i really need to achieve is show the data if tablefiled==2

THE Table structure is

Id    Name        Sdate         Active_view

1     Person 1    2013-04-1          2
2     Person 2    2013-04-5          1
3     Person 3    2013-04-25         1
4     Person 4    2013-04-1          2
5     Person 1    2013-04-1          1

The process that it undergo is
$searchterm="2013-04-1"

output is

Name          Serving Date  

Person 1      2013-04-1
Person 4      2013-04-1      

and my query is

select * from advance where CONCAT_WS(' ',SDate,'/',Time) like '{$searchterm}%'  ORDER BY Id DESC

i tried also something like this but it now showing anything..

select * from advance where Active_view==2 AND CONCAT_WS(' ',SDate,'/',Time) like '{$searchterm}%'  ORDER BY Id DESC
ehpratah 48 Posting Whiz in Training

Geezz "sheepish" thanks pritaeas didn't notice that im so focus on the query itself that i didn't look on the whole script..now its working fine just need to integrate it to the actual page..

ehpratah 48 Posting Whiz in Training

ive tried it on phpmyadmin and its working fine it show all 6 records..

heres my complete code if you can look what i am doing wrong

<?php

$db = mysql_connect ('localhost', 'root', '');

mysql_select_db ('date');


$query = mysql_query("SELECT * FROM `table1` WHERE `date` BETWEEN '2013-04-01' AND '2013-04-04' ORDER BY `id` DESC");

while($rows= mysql_fetch_row($query)) {
$string = '';

echo "<table border='1'><tr><th '>Guest Name</th><th>date</th></tr>";

if (mysql_num_rows($query)){
while($rows = mysql_fetch_assoc($query)){
$string .= "<tr><td>".$rows['name']."</td><td>".$rows['date']."</td></tr>";

}
$total=mysql_num_rows($query);
echo "<B><h3><br>Total Records : $total";
}else{
$string = "No matches found!";
}

echo $string;
}
?>
ehpratah 48 Posting Whiz in Training

weird im using the table that you've provided and the data on it but im getting just 4 records but when i add another record which is Guest 6 and date 2013-04-04.. it will only show Guest 1 to 5 and Guest 6 will be omitted..or the last record will not be dispalyed but when i add a counter for the record it will show that i have 6 record on my table

ehpratah 48 Posting Whiz in Training

Hi i've tested the query again with the same table structure as what you've posted but it still not including Guest 5 it only show Guest 1 to 4..On your test does it include Guest 5? because from the query it must display all the data from the table cause it is looking for the date with the range of 2013-04-01 to 2013-04-04

the query is

$from_date = "2013-04-01";
$to_date = "2013-04-04";

$query = mysql_query("SELECT * FROM `table1` WHERE `date` between '" . $from_date . "'  AND '" . $to_date . "' ORDER by id DESC");
ehpratah 48 Posting Whiz in Training

Hi thanks pritaeas i think the problem is with my table structure on date im just using varcar not date...theory not yet tested yet but i think i'll get it now..thanks for the help by the way..

ehpratah 48 Posting Whiz in Training

Hi do you mean something like this

<?php
if ($_REQUEST["from"]<>'' and $_REQUEST["to"]<>'') {
    $sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE `SDate` >= '".mysql_real_escape_string($_REQUEST["from"])."' AND `SDate` <= '".mysql_real_escape_string($_REQUEST["to"])."'".$search_string.$search_city;
} else if ($_REQUEST["from"]<>'') {
    $sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE `SDate` >= '".mysql_real_escape_string($_REQUEST["from"])."'".$search_string.$search_city;
} else if ($_REQUEST["to"]<>'') {
    $sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE `SDate` <= '".mysql_real_escape_string($_REQUEST["to"])."'".$search_string.$search_city;
} else {
    $sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE `Id`>0".$search_string.$search_city;
}

$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
if (mysql_num_rows($sql_result)>0) {
    while ($rows = mysql_fetch_assoc($sql_result)) {
?>

still not getting it...

ehpratah 48 Posting Whiz in Training

Hi i thought the script is already ok but it seems that when searching on a larger data its not working properly just like my original post..any help will be appreciated

thanks

ehpratah 48 Posting Whiz in Training

Sure this is the complete and working script

<?php


if ($_REQUEST["from"]<>'' and $_REQUEST["to"]<>'') {
    $sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE Date >= '".mysql_real_escape_string($_REQUEST["from"])."' AND Date <= '".mysql_real_escape_string($_REQUEST["to"])."'".$search_string;
} else if ($_REQUEST["from"]<>'') {
    $sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE Date >= '".mysql_real_escape_string($_REQUEST["from"])."'".$search_string;
} else if ($_REQUEST["to"]<>'') {
    $sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE Date <= '".mysql_real_escape_string($_REQUEST["to"])."'".$search_stringy;
} else {
    $sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE Id>0".$search_string;
}

$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
if (mysql_num_rows($sql_result)>0) {
    while ($rows = mysql_fetch_assoc($sql_result)) {
?>
ehpratah 48 Posting Whiz in Training

Hi nevermind guys found away already

ehpratah 48 Posting Whiz in Training
Hi need some help suggestion 

I am trying to search data form two date range but it seems not working properly when i search for


$from_date = "2013-04-01";
$to_date = "2013-04-04";

$query = mysql_query("SELECT * FROM date WHERE Date between '" . $from_date . "'  AND '" . $to_date . "' ORDER by id DESC");

it will only return

Guest 1           2013-04-01
Guest 2           2013-04-02
Guest 3           2013-04-03
Guest 4           2013-04-01

it is omitting

Guest 5           2013-04-04

and i also try uisng this query

$query = mysql_query("SELECT * FROM date WHERE Date >= '" . $from_date . "' AND Date <= '" . $to_date . "' ORDER by id DESC");

it will show just the same result

Here's my table

id  Name                  Date

1   Guest 1           2013-04-01
2   Guest 2           2013-04-02
3   Guest 3           2013-04-03
4   Guest 4           2013-04-01
5   Guest 5           2013-04-04
ehpratah 48 Posting Whiz in Training

@MarPlo thanks men..it works for me just need to modify it to fit my needs...

ehpratah 48 Posting Whiz in Training

Hi to all
i just cant get the grasp of what im trying to do basically i'm making a script that will higlight a certain data(Date /time) in my table if data < 3 min of current time..

ex

$data="March 12, 2013, 16:18";
$current_time="March 12, 2013, 16:20"

if($data< 3min of $current_time)
{
echo"highlight me im fresh";
}
else if($data > 5min of $current_time)
{
echo"oldies";
}

something like that but i cant find a way to implement

ehpratah 48 Posting Whiz in Training

are you using xampp ,lamp or wamp?if yes is the apache and mysql running?

ehpratah 48 Posting Whiz in Training

Hi well base on your insert statement found nothing wrong with it aside form your not filtering the data that you are posting which is not safe ... well the only thing i found that out of place is ; on line 28

also i prefered doing it this way

mysql_query="INSERT INTO mission (acft, to, from, payload, amount, route, majcom, event, type, admin) VALUES ('$airframeSave', '$icaoT', '$icaoF', '$payload', '$payloadA', '$route', '$majcom', '$event', '$type', '$admin')";

ehpratah 48 Posting Whiz in Training

Hi double check this part

  • "" -make sure it has a opening and closing
  • ; - make sure you put it at the end of your variable and at the end of every echo