Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - jlmloves2007

Pages: [1]
1
MySQL database / Help with Database Triggers
« on: May 29, 2012, 08:54:46 AM »
I have two table having the column name as -
Service, Numbers, Prefer, Ops, Phone
in both the tables.
Table1 is my main table and table2 is my temporary table. I wanted to perform add and delete operation for table1 from taking the values of table2.
In table2 there is a column by name Ops which Contains 2 Alphabets 'A' and 'D'.
'A' states to add and 'D' states to delete. Deletions of records would happen by comparing the values of table2 where ops=D and numbers='somevalue'. And addition of records would be Ops=A.


This is my main table1
Service   Numbers Prefer Ops Phone
1   9032386097   0   A   2
1   9032394808   0   A   2
1   9032404942   0   A   2
1   9032460716   0   A   2
1   9032499004   0   A   2
1   9032499792   0   A   2
1   9032558059   0   A   2
1   9032660138   0   A   2
1   9032813579   0   A   2
6   9033019137   0   A   2
6   9033033245   0   A   2
6   9033034368   0   A   2
6   9033116875   0   A   2
6   9033136727   0   A   2
6   9033206822   0   A   2
6   9033208315   0   A   2
6   9033215658   0   A   2
6   9033237464   0   A   2
6   9033237813   0   A   2


And my table2 values are

Service   Numbers Prefer Ops Phone   
1   9032386097   0   D   2
1   9032394808   0   D   2
1   9032404942   0   D   2
1   9032460716   0   D   2
1   9032499004   0   D   2
1   9032499792   0   D   2
1   9032558059   0   D   2
1   9032660138   0   D   2
1   9032813579   0   D   2
6   9033019137   0   D   2
6   9033033245   0   D   2
6   9033034368   0   D   2
6   9033116875   0   D   2
6   9033136727   0   D   2
6   9033206822   0   D   2
6   9033208315   0   D   2
6   9033215658   0   D   2
6   9033237464   0   D   2
6   9033237813   0   D   2
6   9033365313   0   A   2
6   9033365574   0   A   2
6   9033369490   0   A   2
6   9033376618   0   A   2
6   9033378227   0   A   2
20   9952150169   0   A   2
14   9970109189   0   A   2
20   9600752426   0   A   2
20   9600754180   0   A   2
14   9730338185   0   A   2
21   9935065993   0   A   2
20   9952230466   0   A   2
20   9952243714   0   A   2
14   8600934625   0   A   2
20   9944420104   6   A   2
20   8220108573   0   A   2
19   8890460161   0   A   2
20   9003353109   0   A   2
14   9730259052   0   A   2
20   9566655870   0   A   2
18   9815443588   0   A   2
20   9597828908   0   A   2
14   8600911952   0   A   2
14   9665163795   0   A   2
19   8290405048   0   A   2
14   9960100145   0   A   2
20   9677386495   0   A   2
20   9677386057   0   A   2
20   8754243340   0   A   2
12   9163618066   0   A   2
20   9791884063   0   A   2
20   8754229154   0   A   2
20   8754981004   0   A   2
20   9500312700   0   A   2
20   8056706367   0   A   2
23   9679796176   0   A   2
14   7709643320   0   A   2
20   9600794571   0   A   2
20   9600794487   0   A   2
20   9894612914   0   A   2
20   8754975355   0   A   2
20   9789346233   0   A   2
20   8056692388   0   A   2
18   8146691300   0   A   2
1   8978270235   0   A   2
20   9597894970   0   A   2
20   9629501290   0   A   2
20   9894030102   0   A   2
20   9629601257   0   A   2


I want to add and delete records where there is A and D respectively.

2
General PHP Help / Database Numbers
« on: May 08, 2012, 08:02:09 AM »
I have a list of database in which there are 5 columns, namely -  Service Area Code, Phone Numbers, Preferences, Opstype, Phone Type. And the data is as follows.

13   9907655320   0   A   2
17   9861445262   0   A   2
17   9861395056   0   A   2
13   9827772718   0   A   2
17   9861003374   0   A   2
13   9827340346   0   A   2
17   9861037312   0   A   2
17   9861144351   0   A   2
17   9861208733   0   D   2
17   9861308927   0   A   2
17   9861012494   1   A   2
17   9861251159   0   A   2
17   9861444225   0   D   2
13   9827233765   0   A   2

These are basically do not disturb numbers. I want to code for uploading this file, and delete the numbers where the alphabet "D" is there and add the numbers where alphabet "A" is there in the fourth column.



And i also want a code in which i can compare a list of numbers from this database, in which if there alphabet "A" the output of that number is "DND" but if the number is not there in the database the result of that number should be Ok.

I can help out with a website which is similar to to my functionality.
www.dndcheck.in
I had pasted few numbers in the text box and compared these numbers with the above database where all the numbers and DND.

9907655320
9861445262
9861395056
9827772718
9861003374
9827340346
9861037312
9861144351
9861208733
9861308927
9861012494
9861251159
9861444225
9827233765

The result of the numbers are as follows -

Sr No   Request Number   Processed Number   Status   Preference   Opr   Circle
1   9907655320   9907655320   Registered   Full   RG   MP
2   9861445262   9861445262   Registered   Full   RG   OR
3   9861395056   9861395056   Registered   Full   RG   OR
4   9827772718   9827772718   Registered   Full   RG   MP
5   9861003374   9861003374   Registered   Full   RG   OR
6   9827340346   9827340346   Registered   Full   RG   MP
7   9861037312   9861037312   Registered   Full   RG   OR
8   9861144351   9861144351   Registered   Full   RG   OR
9   9861208733   9861208733   Not Registered   NA   RG   OR
10   9861308927   9861308927   Registered   Full   RG   OR
11   9861012494   9861012494   Registered   1   RG   OR
12   9861251159   9861251159   Registered   Full   RG   OR
13   9861444225   9861444225   Not Registered   NA   RG   OR
14   9827233765   9827233765   Registered   Full   RG   MP

The numbers which are status of Not Registered these numbers and not there in the database.

Can anyone help me out...
I am not able to figure it out how will i do this....

3
Hi,

I am still not able to execute it properly. If you don't mind can you help me out by sending me the source code.

I think i am not able to figure it out properly in the code. So can you help me out with the coding. Please...

I am not able to figure it out properly just because i am a beginner..... So can you help me out with the source code please...

4
Tats right wat u said. Since i am just a beginner i am not able to figure it out properly. So can you help me by creating a login form and the seesion where the user name can also be stored in the database

5
General Database / Please help Its urgent.....
« on: February 27, 2012, 12:48:57 PM »
Taking a variable from the login form and using it in another form and store the same variable in the database table, and retrieve the same values when that person logs in.
For example if there are two users - user1 and user2
when user1 log in only the values entered by user1 should be visible to him.
when user2 log in only the values entered by user1 should be visible to him.

My source code would be

Table source code -

CREATE TABLE IF NOT EXISTS `books` (
  `BookID` int(11) NOT NULL AUTO_INCREMENT,
  `Title` varchar(150) NOT NULL,
  `Author` varchar(150) NOT NULL,
  `PublisherName` varchar(150) NOT NULL,
  `CopyrightYear` year(4) NOT NULL,
  PRIMARY KEY (`BookID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;

--
-- Dumping data for table `books`
--

INSERT INTO `books` (`BookID`, `Title`, `Author`, `PublisherName`, `CopyrightYear`) VALUES
(1, 'Algebra', 'Almel', 'Chun Sa', 2007),
(2, 'Algebra', 'Almel', 'Chun Sa', 2007),
(3, 'Algebra', 'Almel', 'Chun Sa', 2007),
(4, 'Algebra', 'Almel', 'Chun Sa', 2007),
(5, 'Algebra', 'Almel', 'Chun Sa', 2007),
(6, 'Algebra', 'Almel', 'Chun Sa', 2007),
(7, 'Algebra', 'Almel', 'Chun Sa', 2007),
(8, 'Algebra', 'Almel', 'Chun Sa', 2007);



Database Connection code-

<?php 
   $conn = mysql_connect('localhost', 'root', '');
    if (!$conn)
    {
    die('Could not connect: ' . mysql_error());
   }
   mysql_select_db("adddel", $conn);
?>


Delete Source Code -

<?php
  include("db.php"); 

   $id =$_REQUEST['BookID'];
   
   
   // sending query
   mysql_query("DELETE FROM books WHERE BookID = '$id'")
   or die(mysql_error());     
   
   header("Location: index.php");
?>


My index page Source code -

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Books</title>
</head>

<body>
<form method="post">
<table>

   <tr>
      <td>Title:</td>
      <td><input type="text" name="title" /></td>
   </tr>
   <tr>
      <td>Author</td>
      <td><input type="text" name="author" /></td>
   </tr>
   <tr>
      <td>Publisher Name</td>
      <td><input type="text" name="name" /></td>
   </tr>
   <tr>
      <td>Copyright Year</td>
      <td><input type="text" name="copy" /></td>
   </tr>
   <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="submit" value="add" /></td>
   </tr>
</table>
<?php
if (isset($_POST['submit']))
   {      
   include 'db.php';
   
                $title=$_POST['title'] ;
               $author= $_POST['author'] ;               
               $name=$_POST['name'] ;
               $copy=$_POST['copy'] ;
                                    
       mysql_query("INSERT INTO `books`(Title,Author,PublisherName,CopyrightYear)
       VALUES ('$title','$author','$name','$copy')");
            
            
           }
?>
</form>
<table border="1">
   
         <?php
         include("db.php");
         
            
         $result=mysql_query("SELECT * FROM books");
         
         while($test = mysql_fetch_array($result))
         {
            $id = $test['BookID'];   
            echo "<tr align='center'>";   
            echo"<td><font color='black'>" .$test['BookID']."</font></td>";
            echo"<td><font color='black'>" .$test['Title']."</font></td>";
            echo"<td><font color='black'>". $test['Author']. "</font></td>";
            echo"<td><font color='black'>". $test['PublisherName']. "</font></td>";
            echo"<td><font color='black'>". $test['CopyrightYear']. "</font></td>";   
            echo"<td> <a href ='view.php?BookID=$id'>Edit</a>";
            echo"<td> <a href ='del.php?BookID=$id'><center>Delete</center></a>";
                           
            echo "</tr>";
         }
         mysql_close($conn);
         ?>
</table>

</body>
</html>


Page View Source code

<?php
require("db.php");
$id =$_REQUEST['BookID'];

$result = mysql_query("SELECT * FROM books WHERE BookID  = '$id'");
$test = mysql_fetch_array($result);
if (!$result)
      {
      die("Error: Data not found..");
      }
            $Title=$test['Title'] ;
            $Author= $test['Author'] ;               
            $PublisherName=$test['PublisherName'] ;
            $CopyrightYear=$test['CopyrightYear'] ;

if(isset($_POST['save']))
{   
   $title_save = $_POST['title'];
   $author_save = $_POST['author'];
   $name_save = $_POST['name'];
   $copy_save = $_POST['copy'];

   mysql_query("UPDATE books SET Title ='$title_save', Author ='$author_save',
       PublisherName ='$name_save',CopyrightYear ='$copy_save' WHERE BookID = '$id'")
            or die(mysql_error());
   echo "Saved!";
   
   header("Location: index.php");         
}
mysql_close($conn);
?>
<!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>
<form method="post">
<table>
   <tr>
      <td>Title:</td>
      <td><input type="text" name="title" value="<?php echo $Title ?>"/></td>
   </tr>
   <tr>
      <td>Author</td>
      <td><input type="text" name="author" value="<?php echo $Author ?>"/></td>
   </tr>
   <tr>
      <td>Publisher Name</td>
      <td><input type="text" name="name" value="<?php echo $PublisherName ?>"/></td>
   </tr>
   <tr>
      <td>Copyright Year</td>
      <td><input type="text" name="copy" value="<?php echo $CopyrightYear ?>"/></td>
   </tr>
   <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="save" value="save" /></td>
   </tr>
</table>

</body>
</html>





Can anyone help me by creating a simple login page and adding the value of that person who is logged on into the books table for which ever record he creates. Please not multiple user would access the same database at the same time..


Can anyone please help me.....

Pages: [1]