Have an account? Sign in
Login  Register  Facebook
How can i make this search engine please?
*table in sql
*search form - for putting in a html page
*result from search to be in a new window like popup
*to have some panel/admin/ with password and captcha to replace data from table in database.
-tabel must contain:
Nr.Ap.(numbers)
Etaj (numbers)
Nume (text)
Nr. Pers. (numbers)
Nr. Persoane Permanente (numbers)
Apa Rece (2 sub table -> MC |  Suma ) ( all numbers)
Apa Calda (2sub table -> MC | SUMA ) ( all numbers)
Caldura (3sub table-> Citire | Consum | Comun )(allnumbers)
Energie Electrica (numbers)
Ascensor (numbers)
Gaze (numbers)
Gunoi (numbers)
Salarii Personal (numbers)
Fond Reparatii (numbers)
Fond Rulment (numbers)
TOTAL Luna Curenta (numbers)
Penalitati (numbers)
Restante (numbers)
TOTAL General (numbers)
i want to put the . 3 decimals if i want in numbers field -search form contain:
Nume: [___only text_______]
Etaj: [_____only number______]
Nr. Apartament: [____only number_____]
[Serach button] - search button must be named "Cauta"

*(all 3 field must be complete to make the search criteria - otherwise - to apear a popup "*Nume" must be added / "*Etaj" must be added /"*Nr.Ap." must be added ...you understand ...)
*(if all fields are ok to apear a like popup with tabel from data base - full tables - for that person - one on top of the other ex:

ouside the table:

Nr Ap / Etaj / Nume - write bold, big outside the table

in table:

Nr. Ap. - field nr. ap.
Etaj - field etaj
Nume - field nume
Nr.Pers - field nume pers
...... and so on ) until the final table - Total General

*(if database has error connect or anything error to apear a like popup to says : "Eroare baza de date reveniti mai tarziu. Daca eroarea persista va rugam sa ne trimiteti un email" )

*the Search script must be put in a html page and connected to database (here i may require some additional help :))
Started: September 18, 2011 Latest Activity: September 18, 2011 sql form html
1 Answer
ok this is very big script and made me creacy to done it
here the main pages index.php | result.php | db.php | show.php
ok lets start with the

mysql Structure


CREATE TABLE IF NOT EXISTS `apa_calda` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `intretinere_id` int(11) NOT NULL,
  `mc` int(11) NOT NULL,
  `suma` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=2 ;

--
-- Dumping data for table `apa_calda`
--

INSERT INTO `apa_calda` (`id`, `intretinere_id`, `mc`, `suma`) VALUES
(1, 1, 10, 20);

-- --------------------------------------------------------

--
-- Table structure for table `apa_rece`
--

CREATE TABLE IF NOT EXISTS `apa_rece` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `intretinere_id` int(11) NOT NULL,
  `mc` int(11) NOT NULL,
  `suma` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=2 ;

--
-- Dumping data for table `apa_rece`
--

INSERT INTO `apa_rece` (`id`, `intretinere_id`, `mc`, `suma`) VALUES
(1, 1, 20, 20);

-- --------------------------------------------------------

--
-- Table structure for table `caldura`
--

CREATE TABLE IF NOT EXISTS `caldura` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `intretinere_id` int(11) NOT NULL,
  `citire` int(11) NOT NULL,
  `consum` int(11) NOT NULL,
  `comun` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=2 ;

--
-- Dumping data for table `caldura`
--

INSERT INTO `caldura` (`id`, `intretinere_id`, `citire`, `consum`, `comun`) VALUES
(1, 1, 30, 30, 30);

-- --------------------------------------------------------

--
-- Table structure for table `intretinere`
--

CREATE TABLE IF NOT EXISTS `intretinere` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nr_ap` int(11) NOT NULL,
  `etaj` int(11) NOT NULL,
  `nume` varchar(255) COLLATE utf8_bin NOT NULL,
  `nr_pers` int(11) NOT NULL,
  `nr_permanente` int(11) NOT NULL,
  `en_electrica` int(11) NOT NULL,
  `ascensor` int(11) NOT NULL,
  `gaze` int(11) NOT NULL,
  `gunoi` int(11) NOT NULL,
  `salarii_personal` int(11) NOT NULL,
  `fond_reparatii` int(11) NOT NULL,
  `fond_rulment` int(11) NOT NULL,
  `total_luna` int(11) NOT NULL,
  `penalitati` int(11) NOT NULL,
  `restante` int(11) NOT NULL,
  `total_general` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=2 ;

--
-- Dumping data for table `intretinere`
--

INSERT INTO `intretinere` (`id`, `nr_ap`, `etaj`, `nume`, `nr_pers`, `nr_permanente`, `en_electrica`, `ascensor`, `gaze`, `gunoi`, `salarii_personal`, `fond_reparatii`, `fond_rulment`, `total_luna`, `penalitati`, `restante`, `total_general`) VALUES
(1, 1, 1, 'test', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);

index.php

<form action="result.php" method="get" target="_blank">
    <table>
        <tr>
        	<td><label for="name">Nume:</label></td>
        	<td><input id="name" name="name" type="text" /></td>
        </tr>
        <tr>
        	<td><label for="etaj">Etaj:</label></td>
        	<td><input id="etaj" name="etaj" type="text" /></td>
        </tr>
        <tr>
        	<td><label for="nr_ap">Nr. Apartament:</label></td>
        	<td><input id="nr_ap" name="nr_ap" type="text" /> </td>
        </tr>
    </table>    

    <input type="submit" value="Cauta" />  
    
</form>

result.php

<?php

    require_once ('db.php');
    if (isset($_GET['name'])
             and isset($_GET['etaj'])
                 and isset($_GET['nr_ap'])) {
                    
    $name = addslashes($_GET['name']);               
    $etaj = intval($_GET['etaj']);                
    $nr_ap = intval($_GET['nr_ap']); 
                    
    $query = mysql_query("SELECT * FROM `intretinere`
                             WHERE `nr_ap` = '$nr_ap'
                                 AND `etaj` = '$etaj'
                                     AND `nume` LIKE '%$name%' LIMIT 0 , 30");

        echo '<p><strong>search results</strong>
         about: <strong>'.$name.'</strong> 
         | we have about <strong>'.count($query).'</strong>
           results</p>';
    
        echo '<ul>';
        
            while($Row = mysql_fetch_array($query)) {
            
            	echo '<li><a target="_blank" href="show.php?id='.$Row['id'].'">
                nume: '.$Row['nume'].' | 
                nr_ap: '.$Row['nr_ap'].' | 
                etaj: '.$Row['etaj'].'</a></li>';
            	
            }
        
        echo '</ul>';        


    	
    }else{
        exit('your search have no the correct parms');
    }


	
?>

db.php

//connect to the mysql
$db = @mysql_connect('localhost', 'root', '');
@mysql_select_db('search', $db) or
 die("Eroare baza de date reveniti mai tarziu. Daca eroarea persista va rugam sa ne trimiteti un email");

show.php

<?php
    require_once ('db.php');
    
    if (isset($_GET['id'])) {
        $id = intval($_GET['id']);
        
        $query = mysql_query("SELECT * FROM `intretinere` where id = '$id'");
        $Row = mysql_fetch_array($query, MYSQL_ASSOC );
        if ($Row) {
 ?>  
                <table border="1" bgcolor="silver" width="400"> 
<?php             
            foreach ($Row as $key => $value) {
            ?>
                    <tr>
                    	<td><?php echo $key;?></td>
                    	<td><?php echo $value;?></td>
                    </tr>
            <?php 
            	
            }
 ?> 
                </table>
<?php    
        //select the apa_calda
        $calda_query = mysql_query("SELECT * FROM `apa_calda`
                                         where intretinere_id = '$id'");

 ?> 
                <table border="1" width="400">
                <caption>apa_calda</caption>
<?php 

        foreach (mysql_fetch_array($calda_query, MYSQL_ASSOC ) as $key => $value) {
            ?>
                    <tr>
                    	<td><?php echo $key;?></td>
                    	<td><?php echo $value;?></td>
                    </tr>
            <?php  	
        }

 ?> 
                </table>
<?php    
        //select the apa_rece
        $calda_query = mysql_query("SELECT * FROM `apa_rece`
                                         where intretinere_id = '$id'");

 ?> 
                <table border="1" width="400">
                <caption>apa_rece</caption>
<?php 

        foreach (mysql_fetch_array($calda_query, MYSQL_ASSOC ) as $key => $value) {
            ?>
                    <tr>
                    	<td><?php echo $key;?></td>
                    	<td><?php echo $value;?></td>
                    </tr>
            <?php  	
        }

 ?> 
                </table>                
 
<?php    
        //select the caldura
        $calda_query = mysql_query("SELECT * FROM `caldura`
                                         where intretinere_id = '$id'");

 ?> 
                <table border="1" width="400">
                <caption>caldura</caption>
<?php 

        foreach (mysql_fetch_array($calda_query, MYSQL_ASSOC ) as $key => $value) {
            ?>
                    <tr>
                    	<td><?php echo $key;?></td>
                    	<td><?php echo $value;?></td>
                    </tr>
            <?php  	
        }

 ?> 
                </table>                
     
                               
                
<?php 
        
        	} else {
            echo 'error 1';
        }        
        

    
    	} else {
            echo 'error';
    }
	
?>

Posted: MacOS
In: September 18, 2011

Your Answer

xDo you want to answer this question? Please login or create an account to post your answer