Jump to content

Yohanne

Members
  • Posts

    216
  • Joined

  • Last visited

Posts posted by Yohanne

  1. Hi coders,

     

    how mysql works to find duplicate entry or  ignore duplicate entry in a series number. example below

     

     |---     id    ---|---    series_stack_num     -----|

     |------------------------------------------------------|

     |-       1       -|-    0000,0001,0002,0003      -|

     |------------------------------------------------------|

     |-       1       -|-    0000,0004,0003,0006      -|

     |------------------------------------------------------|

     |-       1       -|-     0007,0007,0005,0008      -|

     |------------------------------------------------------|

     

    if you notice 0000, 0003 and 0007 are duplicate and now it is possible mysql can trigger duplicate in like this situation?  

     

          

  2. Hi coders,

     

    help to get correct alignment of the following, below is the output that i need to set column.

     

    psc.png

    <?php
    
    
    require('fpdf.php');
    include ('config.php');
    $pdf=new FPDF(); 
    $pdf->Open(); 
    $pdf->AddPage();
    $pdf->SetFont('Arial','B',10);
    $pdf->Cell(40,1,'Hello World!');
    	$str = "SELECT * FROM code_number"; 
    		$result = mysql_query($str);
    			while($row = mysql_fetch_array($result))
    				{ 
    					$pdf->MultiCell(60,5,$row['code'],50,'L',0,1);
    					$pdf->MultiCell(60,5,$row['code_id'],0,'L',0,;
    					$pdf->MultiCell(60,5,$row['yy'],40,'L',0,10);
    				}
    		ob_end_clean();
    	$pdf->Output();
    ?>
    
  3. Hi kova,

     

    try this and hope it will help you.

     

    pdf_lib.php

    <?php	
    	function phptopdf_url($source_url,$save_directory,$save_filename)
    	{		
    		$API_KEY = 'egtyuhes66r8rb3v5';
                    $url = 'http://phptopdf.com/urltopdf.php?key='.$API_KEY.'&url='.urlencode($source_url);
    		$resultsXml = file_get_contents(($url)); 		
    		file_put_contents($save_directory.$save_filename,$resultsXml);
    	}
    	function phptopdf_html($html,$save_directory,$save_filename)
    	{		
    		$API_KEY = 'egtyuhes66r8rb3v5';
                    $postdata = http_build_query(
    			array(
    				'html' => $html,
    				'key' => $API_KEY
    			)
    		);
    		
    		$opts = array('http' =>
    			array(
    				'method'  => 'POST',
    				'header'  => 'Content-type: application/x-www-form-urlencoded',				
    				'content' => $postdata
    			)
    		);
    		
    		$context  = stream_context_create($opts);
    		
    		
    		$resultsXml = file_get_contents('http://phptopdf.com/htmltopdf.php', false, $context);
    		file_put_contents($save_directory.$save_filename,$resultsXml);
    	}
    ?>
    

    index.php

    <?php
     include_once('pdf_lib.php') ;
    
    $html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    <body> 
    <p>page page page page</p>
    </body>
    </html>';
    
    phptopdf_html($html,'my_pdf_filename.pdf');
    echo "<a href='filename.pdf'>Download PDF</a>";
    ?> 
    
    
    phptopdf_html($html,'pdf/', 'my_pdf_filename.pdf');
    echo "<a href='pdf/my_pdf_filename.pdf'>Download PDF</a>";
    
  4. try this..

    <table width="1001" border="0" align="center" cellpadding="0" cellspacing="0">
    
     <?php
      	include('database.php');
    	
    	$sql = mysql_query("SELECT s.nama, s.noic, s.jabatan, s.jawatan, s.gred, s.nostaf, OT.otl_tkh_m FROM staf s, ot_line OT WHERE s.nostaf='NA4451'")or die(mysql_error());
    	
    		if(mysql_num_rows($sql) < 1)
    			{
    			  echo "<p>Currently, there are no content in the database to display at the moment.</p>";
    			}
    		else
    			{
    				while($dataot = mysql_fetch_array($sql))
    	?>
      <tr>
        <td><p><span id="form2">Saya mengakui bahawa saya telah diarah membuat kerja lebih masa untuk bulan <?php echo $dataot['OT.otl_tkh_m'];?>  seperti butir-butir tercatat di bawah dan</span><span> tuntutan ini adalah mengikut peraturan di Lampiran D Pekeliling Perkhidmatan Bil. 1 Tahun 1977</span>. </p></td>
      </tr>
    </table>
    <table width="1001" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td> </td>
      </tr>
    </table>
    
    <table width="1001" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><table width="1001" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="133">Nama</td>
            <td width="348">:<?php echo $dataot['nama'];?></td>
            <td width="23"> </td>
            <td width="115">Jawatan</td>
            <td width="150">:<?php echo $dataot['jawatan'];?></td>
            <td width="102">Gred Gaji</td>
            <td colspan="2">:<?php echo $dataot['gred']; ?></td>
            </tr>
          <tr>
            <td>No Kad Pengenalan</td>
            <td>:<?php echo $dataot['noic']; ?></td>
            <td> </td>
            <td>Gaji Pokok</td>
            <td>:</td>
            <td>No Kakitangan</td>
            <td colspan="2">:<?php echo $dataot['nostaf'];?></td>
            </tr>
          <tr>
            <td>Fakulti/Jabatan:</td>
            <td>:<?php echo $dataot['jabatan'];?></td>
            <td colspan="6"> </td>
            </tr>
        </table></td><?php } ?>
      </tr>
    </table>
    
  5. Hi Coders,

     

    any body can help to work this?

    <select id="mylist">
        <option selected></option>
        <option value="1" >aaaa</option>
         <option value="2">bbb</option>
        <option value="3">ccc</option>
    </select>
    
    $('#mylist').change(function(){
        if( $(this).val() == '1'){
            $('body').append('<input id="myInput" type="text" />');
        }else{
            $('#myInput').remove();
        }
    });
    
  6. Hi.

     

    to your index put this code to autoload all your your classis and you dont need to use require tag. hope it helps.

    <?php
    	
      class loadclasses
    	{
    	   public static function autoLoader($className)
    		{
    		  $value = '/foldername/foldername1/' .$className. '.php';  require $value; 
    		}	
    	}
      spl_autoload_register('loadclasses::autoLoader');  $new_value = new ClassName(); $new_value->ClassProperty();
    
    <?php
    
  7. Hi Coders,

     

    any idea how to avoid duplicate entry? ex.. numbers below that i want to insert in just one entry or single line and now i don't want to duplicate the numbers inside the comma? is this possible to trigger to avoid duplicate batch numbers.   

     

    9887455,12612511,00122211,78875545,1122223 

     

    Thanks

  8. Something like this below but i want the value is show up in the new page.

    <body>
    
    <form>
    First Name: <input type="text" id="myText" name="fname" value="Mickey"><br>
    </form>
    
    <p>Click the button to return the value of the value attribute of the text field.</p>
    
    <p id="demo"></p>
    
    <button onclick="myFunction()">Try it</button>
    
    <script>
    function myFunction()
    {
    var x = document.getElementById("myText").value;
    document.getElementById("demo").innerHTML=x;
    }
    </script>
    
    </body>
    
  9. Hi coders,

     

    i have search box, and i want to show the result from db into javascript message alert box with option yes and cancel botton. please any help and idea how it to work?

     

    same like below but it's not working.

    if (isset($_POST['search'])) {
    
        $word = mysql_real_escape_string($_POST['search']);
      
        $sql = "SELECT code FROM code_number WHERE code like '%" . $word . "%' ORDER BY code LIMIT 2";
    
    	$row = mysql_query($sql) or die(mysql_error());
    	    echo '<script type="text/javascript">';
             while($result = mysql_fetch_array($row))
    		{
    			echo 'alert(\'' + $result[code] + '\');';
    		}
    	echo '</script>';
    		
    }
    

    thanks

  10. Hi coders,

     

    any body explain y class not found and i use extends function:

     

    home.php

    <?php
    	class home extends facility
    		{
    			public function s()
    				{
    					$this->x();
    				}
    		}
    		
    

    facility.php

    <?php
    
    class facility
    	{
    		public static function x()
    		{
    			echo "hello";
    		}	
    }
    
    

    Thanks

  11. Hi everyOne.

     

    im done using mysql connection with this code: 

    <?php
    	define ('DB_SERVER_', 'localhost');
    	define ('DB_USER_', 'root');
    	define ('DB_PASS_', '');
    	define ('DB_NAME_', 'protondb');
    	
    	
    	class connection
    		{
    			function __construct()
    				{
    					$Conn = mysql_connect(DB_SERVER_, DB_USER_, DB_PASS_) or die("Server not Conneceted -> $Conn". sha1(mysql_error()));
    							mysql_select_db(DB_NAME_, $Conn) or die("database not connected -> $Conn". sha1(mysql_error()));
    				}
    		}
    ?> 

    and now any body here to know, how to connect php to sql server 2000? if yes please share us you knowledge of it.  thanks 

  12. yes...i want to spy someone. and yes  i want only receive text message from phone without knowing him. ex. when im done creating website, i want to register her number from a site i created to able receive text message from her phone. and she can also receive text message from her phone but somehow its two copy. i can receive and she can receive. 

  13. Hi Coders,

     

     i search in many times in Google oh how to insert data. but i did not found what i'm looking.

     

    please any body can share how to manage in how to insert data. i have the following below and i really don't know what is next steps.

    class ModelRegistration extends CI_Model 
    	{ 
    		function __construct 
    			{
    				parent::__construct();
    			{
    		function i_account()
    			{        
    			   
    			} 
    	}
    
    class Form extends CI_Controller {
    
    	
    	function index()
    	{
    		$this->load->helper(array('form','url'));
    
    		$this->load->library('form_validation');
    
    		$this->form_validation->set_rules('fname', 'First Name', 'required');
    		$this->form_validation->set_rules('lname', 'Last Name', 'required');
    		$this->form_validation->set_rules('emailadd', 'Email Address', 'required');
    		$this->form_validation->set_rules('avatar', 'Avatar', 'required');
    		$this->form_validation->set_rules('month', 'month', 'required');
    		$this->form_validation->set_rules('year', 'Year', 'required');
    		$this->form_validation->set_rules('day', 'Day', 'required');
    		$this->form_validation->set_rules('gender', 'Gender', 'required');
    		$this->form_validation->set_rules('username', 'Username', 'required');
    		$this->form_validation->set_rules('password', 'Password', 'required');
    		$this->form_validation->set_rules('password_c', 'Password Confirmation', 'required');
    		
    		if ($this->form_validation->run() == FALSE)
    		{
    			$this->load->view('myform');
    		}
    		else
    		{
    			$this->load->model('ModelRegistration');
    			$this->ModelRegistration->i_account();
    			
    			$this->load->view('formsuccess');
    		}
    	}
    }
    
  14. Okay, Thank you for your response. and here is the code for producs.php

    <? include("top.inc.php")?>
    <?
    
    $cate_ar = array();
    $sql = "select * from stcms_products_cate where markasdelete = 0 and is_post = 1 order by ordernum";
    $res = mysql_query($sql);
    while ($row = mysql_fetch_array($res)){
     $temp = array();
     $temp['id'] = $row['id'];
     $temp['image_1'] = $row['image_1'];
     $temp['image_2'] = $row['image_2'];
     
     $temp['hotitemlist'] = array();
     $sql2 = "select sp.id,sp.image_hot";
     $sql2 .= " from stcms_products sp, stcms_products_highlight sph";
     $sql2 .= " where sp.parent = '".$row['id']."' and sp.is_post = 1 and sp.markasdelete = 0 and sph.product_id = sp.id";
     $sql2 .= " order by sph.ordernum";
     $res2 = mysql_query($sql2);
     while ($row2 = mysql_fetch_array($res2)){
        $temp['hotitemlist'][] = $row2;
     }
     
     $cate_ar[] = $temp;
    }
    
    $product_banner = "";
    $sql = "select image_1 from stcms_products_banner where id = 1";
    $res = mysql_query($sql);
    $row = mysql_fetch_array($res);
    
    if (file_exists($bannerpath.$row['image_1']) && $row['image_1'] != ""){
       $product_banner = $bannerpath.$row['image_1'];
    }
    
    
    $type_photo_ar = array();
    $sql = "select * from stcms_products_type_photo where id = 1";
    $res = mysql_query($sql);
    $row = mysql_fetch_array($res);
    
    foreach ($_pro_type_ar2 as $key => $value){
      if (file_exists($bannerpath.$row['image_'.$key]) && $row['image_'.$key] != ""){
         $type_photo_ar[$key] = $bannerpath.$row['image_'.$key];
      }
      
      if (file_exists($bannerpath.$row['image_'.$key.'_over']) && $row['image_'.$key.'_over'] != ""){
         $type_photo_ar[$key.'_over'] = $bannerpath.$row['image_'.$key.'_over'];
      } else if (file_exists($bannerpath.$row['image_'.$key]) && $row['image_'.$key] != ""){
         $type_photo_ar[$key.'_over'] = $bannerpath.$row['image_'.$key];
      }
      
    }
    ?>
    <!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" />
    <? include("title.php")?>
    <link href="includes/css/style.css" rel="stylesheet" type="text/css">
    <link href="includes/css/contentslider.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="includes/js/contentslider.js"></script>
    <script>
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    function chhotitem(id){
      if (id == 2){
         document.getElementById('hotitemlist_1').style.display = "none";
    	 document.getElementById('hotitemlist_2').style.display = "";
      } else {
         document.getElementById('hotitemlist_1').style.display = "";
    	 document.getElementById('hotitemlist_2').style.display = "none";
      }
    }
    
    var current_cate = "<?=$cate_ar['0']['id']?>";
    
    
    function chhotitem2(id){
       if (current_cate != id){
    	   document.getElementById('hotitemlist_c'+id).style.display = "";
    	   document.getElementById('hotitemlist_c'+current_cate).style.display = "none";
    	   current_cate = id;
       }
    }
    </script>
    </head>
    <body onload="MM_preloadImages(
    <? foreach ($cate_ar as $key => $value){?>
     <? if ($key == 0){?>
       '<?=$productcatepath.$value['image_2']?>'
     <? } else {?>
       ,'<?=$productcatepath.$value['image_2']?>'
     <? } ?>
    <? } ?>
    <? foreach ($_pro_type_ar2 as $key => $value){?>
       ,'<?=$type_photo_ar[$key.'_over']?>'
    <? } ?>
    );">
    <table border="0" cellspacing="0" cellpadding="0" class="mainw">
       <tr>
         <td align="center"><? include "header.php"?></td>
       </tr>
       <tr>
            <td align="center" valign="top" style="padding-top:5px;">
              <table border="0" cellspacing="0" cellpadding="0" width="100%">
                <? if ($product_banner != ""){?>
                <tr>
                  <td align="center"><img src="<?=$product_banner?>" width="1000" border="0" /></td>
                </tr>
               <? } ?>
                <tr>
                  <td style="padding-top:10px;">
                    <table border="0" cellspacing="0" cellpadding="0" width="100%">
                      <tr>
                       <? foreach ($cate_ar as $key => $value){?>
                        <td align="center"><div><a href="productslist.php?cid=<?=$value['id']?>" onmouseover="chhotitem2('<?=$value['id']?>');MM_swapImage('Image<?=$key?>','','<?=$productcatepath.$value['image_2']?>',1)" onmouseout="MM_swapImgRestore()"><img src="<?=$productcatepath.$value['image_1']?>" width="320" border="0" name="Image<?=$key?>" id="Image<?=$key?>" /></a></div>
                        <div class="hotstr1"> </div>
                        </td>
                       <? } ?>
                      </tr>
                     </table>
                  </td>
                </tr>
                
      <tr>
        <td style="padding-left:18px;">
          <table border="0" cellspacing="0" cellpadding="0" width="100%">
            <tr>
              <td valign="bottom"><a href="productslist.php?ctype=MO" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('pImage_mo','','<?=$type_photo_ar['mo_over']?>',1)"><img src="<?=$type_photo_ar['mo']?>" name="pImage_mo" border="0" id="pImage_mo" /></a></td>
              <td valign="bottom"><a href="productslist.php?ctype=LA" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('pImage_la','','<?=$type_photo_ar['la_over']?>',1)"><img src="<?=$type_photo_ar['la']?>" name="pImage_la" border="0" id="pImage_la" /></a></td>
              <td valign="bottom"><a href="productslist.php?ctype=BA" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('pImage_ba','','<?=$type_photo_ar['ba_over']?>',1)"><img src="<?=$type_photo_ar['ba']?>" name="pImage_ba" border="0" id="pImage_ba" /></a></td>
              <td valign="bottom"><a href="productslist.php?ctype=AD" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('pImage_ad','','<?=$type_photo_ar['ad_over']?>',1)"><img src="<?=$type_photo_ar['ad']?>" name="pImage_ad" border="0" id="pImage_ad" /></a></td>
            </tr>
            <tr>
              <td valign="bottom"><a href="productslist.php?ctype=EA" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('pImage_ea','','<?=$type_photo_ar['ea_over']?>',1)"><img src="<?=$type_photo_ar['ea']?>" name="pImage_ea" border="0" id="pImage_ea" /></a></td>
              <td valign="bottom"><a href="productslist.php?ctype=SP" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('pImage_sp','','<?=$type_photo_ar['sp_over']?>',1)"><img src="<?=$type_photo_ar['sp']?>" name="pImage_sp" border="0" id="pImage_sp" /></a></td>
              <td valign="bottom"><a href="productslist.php?ctype=CA" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('pImage_ca','','<?=$type_photo_ar['ca_over']?>',1)"><img src="<?=$type_photo_ar['ca']?>" name="pImage_ca" border="0" id="pImage_ca" /></a></td>
              <td valign="bottom"><a href="productslist.php?ctype=MOU" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('pImage_mou','','<?=$type_photo_ar['mou_over']?>',1)"><img src="<?=$type_photo_ar['mou']?>" name="pImage_mou" border="0" id="pImage_mou" /></a></td>
            </tr>
          </table>
        </td>
      </tr>
                
                <? foreach ($cate_ar as $key => $value){?>
                <tr id="hotitemlist_c<?=$value['id']?>" <? if ($key > 0){?>style="display:none"<? } ?>>
                  <td class="pro_hotitemlist">
                   <table border="0" cellspacing="0" cellpadding="0" width="100%">
                      <tr>
                       <? foreach ($value['hotitemlist'] as $key2 => $value2){?>
                      <td align="center"><a href="products_detail.php?id=<?=$value2['id']?>"><img src="<?=$productpath.$value2['image_hot']?>" width="243" border="0" /></a></td>
                        <? if (($key2+1) % 3 == 0){?>
                          </tr><tr>
                        <? } ?>
                       <? } ?>
                      </tr>
                    </table>
                  </td>
                </tr>
                <? } ?>
                
                <? /*<tr id="hotitemlist_1" style="display:none">
                  <td class="pro_hotitemlist">
                   <table border="0" cellspacing="0" cellpadding="0" width="100%">
                      <tr>
                      <td align="center"><a href="products_detail.php?id=22"><img src="temp/4.png" width="243" height="152" border="0" /></a></td>
                        <td align="center"><a href="products_detail.php?id=20"><img src="temp/5.png" width="243" height="152" border="0" /></a></td>
                        <td align="center"><a href="products_detail.php?id=21"><img src="temp/6.png" width="243" height="152" border="0" /></a></td>
                        
                      </tr>
                    </table>
                  </td>
                </tr>
                
                <tr id="hotitemlist_2" style="display:none">
                  <td class="pro_hotitemlist">
                   <table border="0" cellspacing="0" cellpadding="0" width="100%">
                      <tr>
                        <td align="center"><a href="products_detail.php?id=31"><img src="temp/1.png" width="243" height="152" border="0" /></a></td>
                        <td align="center"><a href="products_detail.php?id=34"><img src="temp/2.png" width="243" height="152" border="0" /></a></td>
                        <td align="center"><a href="products_detail.php?id=38"><img src="temp/3.png" width="243" height="152" border="0" /></a></td>
                      </tr>
                    </table>
                  </td>
                </tr> */ ?>
              </table>
              
            </td>
      </tr>
      
      <tr>
                       <td align="center" valign="bottom" height="120"><? include "logo.php"?></td>
                     </tr>
                     
                     
        <tr>
         <td><? include "footer.php"?></td>
        </tr>
    </table>
    </body>
    </html>
    
×
×
  • 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.