Jump to content

How to add button


MirceaLzr

Recommended Posts

Hello again.I have one simple question.Look here.

My script right now looks like that.After i press "Cautare" buttons the results list like that.Image 2.1

1-1.jpg

2-1.jpg

 

How can i add button image with some link for my Update data script??I want to look like this.

2copy.jpg

 

I need only the code.The  script for this search is.

 

 

<?php
/*****************************
*  Simple SQL Search Tutorial by Frost
*  of Slunked.com
******************************/

$dbHost = 'localhost'; // localhost will be used in most cases
// set these to your mysql database username and password.
$dbUser = 'root'; 
$dbPass = 'root';
$dbDatabase = 'moob'; // the database you put the table into.
$con = mysql_connect($dbHost, $dbUser, $dbPass) or trigger_error("Failed to connect to MySQL Server. Error: " . mysql_error());

mysql_select_db($dbDatabase) or trigger_error("Failed to connect to database {$dbDatabase}. Error: " . mysql_error());

// Set up our error check and result check array
$error = array();
$results = array();

// First check if a form was submitted. 
// Since this is a search we will use $_GET
if (isset($_GET['search'])) {
   $searchTerms = trim($_GET['search']);
   $searchTerms = strip_tags($searchTerms); // remove any html/javascript.
   
   if (strlen($searchTerms) < 3) {
      $error[] = "Produsul trebui sa contina minim 3 litere sau cifre.";
   }else {
      $searchTermDB = mysql_real_escape_string($searchTerms); // prevent sql injection.
   }
   
   // If there are no errors, lets get the search going.
   if (count($error) < 1) {
      $searchSQL = "SELECT numar, nume_produs, cod_oeu, uretici, cod_producator, stoc_produs, pret_ronfaratva, pret_rontva, firma_produs, pozitionare_raft FROM mbz WHERE ";
   
      // grab the search types.
      $types = array();
      $types[] = isset($_GET['nume_produs'])?"`nume_produs` LIKE '%{$searchTermDB}%'":'';
      $types[] = isset($_GET['cod_oeu'])?"`cod_oeu` LIKE '%{$searchTermDB}%'":'';
      $types[] = isset($_GET['cod_producator'])?"`cod_producator` LIKE '%{$searchTermDB}%'":'';
      
      $types = array_filter($types, "removeEmpty"); // removes any item that was empty (not checked)
      
      if (count($types) < 1)
         $types[] = "`nume_produs` LIKE '%{$searchTermDB}%'"; // use the body as a default search if none are checked
      
          $andOr = isset($_GET['matchall'])?'AND':'OR';
      $searchSQL .= implode(" {$andOr} ", $types) . " ORDER BY `nume_produs`"; // order by title.
  
  

      $searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}");
      
      if (mysql_num_rows($searchResult) < 1) {
         $error[] = "Produsul dumneavoastra  {$searchTerms} nu a fost gasit.";
      }else {
         $results = array(); // the result array
         $i = 1;
         while ($row = mysql_fetch_assoc($searchResult)) {
            $results[] = "<font color=red><hr><b>{$i}.</b></hr></font>  <td><b>Nume Piesa:</b></td> <b><font color=red>{$row['nume_produs']}</font></b> <p><b>-Cod Oeu: </b>  <b><font color=red>{$row['cod_oeu']}</font></b> <p><b>-Cod Producator: </b>  <b><font color=red>{$row['cod_producator']}</font></b> <p><b>-Stoc Produs: </b>  <b><font color=red>{$row['stoc_produs']}</font></b> <p><b>-Pret (Ron) Fara Tva: </b>  <b><font color=red>{$row['pret_ronfaratva']}</font></b> <p><b>-Pret (Ron) Tva: </b>  <b><font color=red>{$row['pret_rontva']}</font></b>   <p><b>-Pozitionare Raft: </b>  <b><font color=red>{$row['pozitionare_raft']}</font></b>   <p><b>-Modifica Produs: </b>  <b><font color=red>{$row['pozitionare_raft']}</font></b> <br /><br />";
            $i++;
         }
      }
   }
}



function removeEmpty($var) {
   return (!empty($var)); 
}
?>
<html>
   <title>Stoc produse Mbz Real Truck</title>
   <style type="text/css">
      #error {
         color: red;
      }
  
  
   body {
background-color: #000066;
background-image: url(ice-cool-white-picture.jpg);
background-repeat: repeat;
}
.style2 {
color: #000000;
font-weight: bold;
}
   </style>
   <body>
      <div align="center"><?php echo (count($error) > 0)?"Cautarea dumneavoastra a intampinat o problema<br /><span id=\"error\">" . implode("<br />", $error) . "</span><br /><br />":""; ?>
   </div>
      <form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm">
         <div align="center">
           <p class="style2">Cauta Produs 
             <input type="text" name="search" value="<?php echo isset($searchTerms)?htmlspecialchars($searchTerms):''; ?>" />
             <br>
           Alege campul dorit de cautare </p>
           <p class="style2">Nume Produs: 
             <input type="checkbox" name="nume_produs" value="on" <?php echo isset($_GET['nume_produs'])?"checked":''; ?> /> 
         | 
         Cod Oeu: 
         <input type="checkbox" name="cod_oeu" value="on" <?php echo isset($_GET['cod_oeu'])?"checked":''; ?> /> 
         | 
         Cod Producator: 
         <input type="checkbox" name="cod_producator" value="on" <?php echo isset($_GET['cod_producator'])?"checked":''; ?> />
         <br />

                 Cauta in toate campurile <input type="checkbox" name="matchall" value="on" <?php echo isset($_GET['matchall'])?"checked":''; ?><br />
                 <br />
              <input type="submit" name="submit" value="Cautare" />
		   
           </p>
        </div>
      </form>
      <div align="">
  
        <p><?php echo (count($results) > 0)?"" . implode("", $results):""; ?></p>
        <p> </p>
        <p> </p>
        <p>  </p>
      </div>
   </body>
</html>

 

Best regards.

 

Link to comment
https://forums.phpfreaks.com/topic/245022-how-to-add-button/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.