473,549 Members | 2,626 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to search in mysql databse using php?

127 New Member
i need store the details of a hike in salary details into the database. if its employee's first hike, then i have to insert the employee hike details.

for second hike, third hike and so on means, i have a count variable i have to check that and based on the counter variable i have used if else statements... and i have to update the existing emplyoee hike details.

Expand|Select|Wrap|Line Numbers
  2. $query="SELECT * FROM hike where empid='$empid'";
  3.   $result1=mysql_query($query);
  5.   $i=0;
  6.   $empid=mysql_result($result1,$i,"empid");
  7.   $count=mysql_result($result1,$i,"count");*/
  11. if ( $row = mysql_fetch_array( $result1 ) ) {
  12.    do {
  13.       $cid=mysql_result($result1,$i,"empid");
  14.   $hikedate=mysql_result($result1,$i,"hikedate");
  15.   $nexthike=mysql_result($result1,$i,"nexthike");
  16.   $count=mysql_result($result1,$i,"count");
  17.    }
  18.    while( $row = mysql_fetch_array( $result1 ) );
  19.   }
  20. else {
  21.     // add 6 months to date if first hike...
  22.     $count=1;
  23.     $hikedate= Date('Y.m.d');
  24.     $nexthike=Date('Y.m.d', strtotime("+180 days"));
  25. $query1= "insert into hike (empid,hike,hikedate,nexthike,count) values ('$empid','$hike','$hikedate','$nexthike','$count')";
  26. mysql_query($query1);
  27. }
  30.   if ('$count'=='1')
  31.   {
  32.       // add 8 months to date if second hike....
  33.      $hikedate= Date('Y.m.d');
  34.      $nexthike=Date('Y.m.d', strtotime("+240 days"));
  35.      $query2= "update hike set count='2', hikedate='$hikedate', nexthike='$nexthike' where empid='$empid'";
  36.      mysql_query($query2);
  38.   }
  39.   else if ('$count'=='2')
  40.   {
  41.      // thrid hike
  42.      $hikedate= Date('Y.m.d');
  45.   }
so please help, how to check all these conditions...
May 4 '11 #1
0 1016

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Torsten Schmidt | last post by:
Hi, I'm trying to connect to a mysql-Server using PHP's mysql-function mysql_connect. The host on which the mysql-server is running is not the same as the host apache and php are running on. The two computers are connected in an IPv6-network. No matter if I give the hostname (defined in /etc/hosts), the IPv6-address ("fec0::4") or the...
by: Nikola Skoric | last post by:
Hi there, Is it possible to force PHP to connect to MySQL server using SSL? Or is there no way for PHP to connect to MySQL server on another machine by encrypted connection? -- "Now the storm has passed over me I'm left to drift on a dead calm sea And watch her forever through the cracks in the beams
by: Rubal Jain | last post by:
Hello, How do I upload images under MySQL DB using PHP Script. Any Sample script to upload and retrive images to MySQL DB would be appreciated. Thanks Rubal Jain www.Rubal.Net
by: buster100 | last post by:
I am looking for an example of php code that accesses a mysql table using SSL (php v4.3.10). I have php code on serverA and some mysql tables on serverB (located on the other side of the internet ;-) to serverA). I want to retrieve data in the php script on serverA using normal selects etc over a ssl connection from serverB. Any help would...
by: menmysql | last post by:
i am not bale to solve this problem since two weeks i am trying to access records from mysql database using jsp. inside this jsp program i wrote all my JDBC code. it is working very nicely and displaying records. now i wrote all the JDBC code in .java and i am accessing that code in jsp file. but this time i am getting only exceptions not...
by: christopher_board | last post by:
Hi all. I am trying to connect to a MySQL Database using PHP on a local machine using locahost. I am using the following code <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
by: Suresh P | last post by:
Hi All, I tried to access the mysql database in ODBC using ip address and username/password. It returns, "cannot connect to MySQL server on IP ADDRESS(10060)". This could be related to Firewall on the server. Is there anyway to access MySQL database using ODBC without opening port 3306?
by: yenfa | last post by:
I've done a simple PHP-thing which adds data into my mySQL database, using that "PHP $_POST" thing, now I want to do editing that data through PHP form again, but I don't know how to do that. I've tried once, but it failed. <?php $author=$_POST; $date=$_POST; $shortstory=$_POST; mysql_connect ("dbserver", "user", "pass") or die...
by: mahesan | last post by:
How you connect to mySQL Server using PHP: we have a mySQL server in one host,say, I am trying a program from, How do I make use of the databases in the mySQL Server? thanks Ma
by: rthcupid | last post by:
Hi all I need help to update a remote mysql database from a local mysql database using php run in remote site. Use of application 1. The local database and the reomote database are same structure 2. Some part of updation are done localy and then manully export the the local file and import in remote site . I need help to change this...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.