CariDotMy

 Forgot password?
 Register

ADVERTISEMENT

Author: bender

tumpang tanye psl html n php

[Copy link]
Post time 5-3-2009 07:09 PM | Show all posts
Thanks board manager dan siler81.

Ni ada soalan simple tapi aku dah cari kat net, tanya mr google tapi tak jumpa, maybe aku cari guna keywords yang salah.

AKu ada satu field yang diimport dari database lain (oracle) dalam bentuk tarikh.

Camna aku nak paparkan tarikh dari field tu dalam bentuk month, year.

Contoh: January, 2007

aku cuba buat <?php echo $datestart ?> tapi dia keluar dalam bentuk 2007-01-15
Reply

Use magic Report


ADVERTISEMENT


Post time 5-3-2009 11:10 PM | Show all posts
try n.. kot boleh jalan
  1. function DatesInterconv($DateFormat1, $DateFormat2, $DateStr)
  2. {
  3.     $base_struc     = split('[:/.\ \-]', $DateFormat1);
  4.     $date_str_parts = split('[:/.\ \-]', $DateStr );
  5.     $date_elements     = array();

  6.     $p_keys = array_keys( $base_struc );
  7.     foreach( $p_keys as $p_key )
  8.     {
  9.         if( !empty( $date_str_parts[$p_key] ))
  10.         {
  11.             $date_elements[$base_struc[$p_key]] = $date_str_parts[$p_key];
  12.         }
  13.         else
  14.               return false;
  15.     }

  16.     if(array_key_exists('M', $date_elements))
  17.     {
  18.         $Mtom=array(
  19.             "Jan"=>"01",
  20.             "Feb"=>"02",
  21.             "Mar"=>"03",
  22.             "Apr"=>"04",
  23.             "May"=>"05",
  24.             "Jun"=>"06",
  25.             "Jul"=>"07",
  26.             "Aug"=>"08",
  27.             "Sep"=>"09",
  28.             "Oct"=>"10",
  29.             "Nov"=>"11",
  30.             "Dec"=>"12",
  31.         );
  32.         $date_elements['m']=$Mtom[$date_elements['M']];
  33.     }

  34.     $dummy_ts = mktime(
  35.         $date_elements['H'],
  36.         $date_elements['i'],
  37.         $date_elements['s'],
  38.         $date_elements['m'],
  39.         $date_elements['d'],
  40.         $date_elements['Y']
  41.     );
  42.     return date($DateFormat2, $dummy_ts );
  43. }


  44. echo DatesInterconv('Y-m-d','d/m/Y','2009-10-28');
Copy the Code
Reply

Use magic Report

Post time 6-3-2009 12:00 PM | Show all posts
Habis variable $datestart tu nak letak mana? <--- soalan inesen
Reply

Use magic Report

Post time 6-3-2009 02:22 PM | Show all posts
$datestart tu value dari oracle kan

so $datestart letak kat value

DatesInterconv([source format],[out_put format],[value]);
Reply

Use magic Report

Post time 6-3-2009 04:32 PM | Show all posts
board...kat coding ni...mane nak selit order by..?

$sql="SELECT * FROM $tbl_name WHERE nokp = '". $_SESSION['nokp'] ."' LIMIT ". $offset .",". $rowsPerPage;
Reply

Use magic Report

Post time 6-3-2009 05:16 PM | Show all posts
kena ikut urutan
SELECT * FROM table WHERE 1 GROUP BY field ORDER BY field LIMIT 0,10
Reply

Use magic Report

Follow Us
Post time 6-3-2009 11:55 PM | Show all posts
tq
Reply

Use magic Report

Post time 7-3-2009 02:40 PM | Show all posts
board..nak tny pasal mysql la.....kan kalo kite insert data dlm tu./..cth no tepon...017222222...tp mase papar dier kuar 172222222...cane nak bg kuar 0 tu ek?
Reply

Use magic Report


ADVERTISEMENT


Post time 7-3-2009 02:52 PM | Show all posts
kalau ko set field tu as "int" memang la....
satu cara ko set as "varcha" & masa nk masukkan data buat validate is_numeric($_POST['phone']))

cara lain
if(substr($row['phone'],0,1) != '0'))
   echo '0'.$row['phone'];
else
  echo $row['phone'];
Reply

Use magic Report

Post time 7-3-2009 03:06 PM | Show all posts
Originally posted by BorderManager at 7-3-2009 14:52
kalau ko set field tu as "int" memang la....
satu cara ko set as "varcha" & masa nk masukkan data buat validate is_numeric($_POST['phone']))

cara lain
if(substr($row['phone'],0,1) != '0')) ...



validate is_numeric($_POST['phone'])) ni utk ape?..

kalo aku set as varchar...tp mase nak masuk data tu..aku xletak&#160;validate is_numeric($_POST['phone'])) xpe ke?....

aku just buat script utk reminder &#160;user je...

cth..kalo mase user isi abjad kat no tepon tu..n bile dier tekan submit..kuar msgbox btau yg just masukkan nombor sahaja...
aku pakai script nie

&#160;if (IsNumeric(document.s.phone.value)==false)&#160;
&#160;               {
&#160;                alert("Masukkan angka sahaja bagi No Telefon!");
&#160;                document.s.phone.focus();
&#160;                return false;
&#160;               }
&#160;                else
&#160;                return true;&#160;
&#160;                }
&#160;
function IsNumeric(strString)
&#160;                  //  check for valid numeric strings&#160;
&#160;                {
&#160;                          var strValidChars = "0123456789";
&#160;                var strChar;
&#160;                          var blnResult = true;

&#160;                          if (strString.length == 0) return false;

&#160;                //  test strString consists of valid characters listed above
&#160;                          for (i = 0; i < strString.length && blnResult == true; i++)
&#160;                    {
&#160;                     strChar = strString.charAt(i);
&#160;                if (strValidChars.indexOf(strChar) == -1)
&#160;                {
&#160;                blnResult = false;
&#160;                }
&#160;                     }
&#160;                 return blnResult;
&#160;                          }
Reply

Use magic Report

Post time 7-3-2009 05:55 PM | Show all posts
board..naper bile aku wat nie...dier error...rasenye mcm dah betull..
if(isset($_POST['delete'])){
&#160;   if(sizeof($_POST['chkbx'])){
&#160;       foreach($_POST['chkbx'] AS $val){
&#160;           $sql = mysql_query("DELETE FROM loginkaunselor,kaunselor WHERE loginkaunselor.nokp2 = kaunselor.nokp2 AND loginkaunselor.nokp2 =".(int)$val)or die(mysql_error());
&#160;       }
&#160;   }

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE loginkaunselor.nokp2 = kaunselor.nokp2 AND loginkaunselor.nokp2 =222' at line 1

[ Last edited by  pzan213 at 7-3-2009 18:49 ]
Reply

Use magic Report

Post time 7-3-2009 09:03 PM | Show all posts
ko buat java validate pun dah ok dah...

try n
$sql = "DELETE FROM loginkaunselor,kaunselor WHERE loginkaunselor.nokp2 = kaunselor.nokp2 AND loginkaunselor.nokp2 ='".(int)$val ."'";
mysql_query($sql) or die(mysql_error());
Reply

Use magic Report

Post time 8-3-2009 03:42 AM | Show all posts
Originally posted by BorderManager at 7-3-2009 21:03
ko buat java validate pun dah ok dah...

try n
$sql = "DELETE FROM loginkaunselor,kaunselor WHERE loginkaunselor.nokp2 = kaunselor.nokp2 AND loginkaunselor.nokp2 ='".(int)$val ."'";
mysql_que ...



dier kuar jugak la
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE loginkaunselor.nokp2 = kaunselor.nokp2 AND loginkaunselor.nokp2 ='222'' at line 1
Reply

Use magic Report

Post time 8-3-2009 09:46 AM | Show all posts
$sql = "DELETE FROM loginkaunselor,kaunselor WHERE loginkaunselor.nokp2 = kaunselor.nokp2 AND loginkaunselor.nokp2 ='".(int)$val ."'";



try yg ni

$sql="delete from loginkaunselor.*,kaunselor.* from loginkaunselor inner join kaunselor on loginkaunselor.nokp2=kaunselor.nokp2 where loginkaunselor.nokp2='".(int)$val."'";

[ Last edited by  slier81 at 8-3-2009 09:55 ]
Reply

Use magic Report

Post time 8-3-2009 09:54 AM | Show all posts
Originally posted by BorderManager at 7-3-2009 21:03
ko buat java validate pun dah ok dah...


hati2 java tidak sama dengan javascript
dont get it confused or confused others..
cheers
Reply

Use magic Report

Post time 8-3-2009 11:28 AM | Show all posts
sory beb.....
maksud aku javascript
Reply

Use magic Report


ADVERTISEMENT


Post time 8-3-2009 04:41 PM | Show all posts
Originally posted by slier81 at 8-3-2009 09:46



try yg ni

$sql="delete from loginkaunselor.*,kaunselor.* from loginkaunselor inner join kaunselor on loginkaunselor.nokp2=kaunselor.nokp2 where loginkaunselor.nokp2='".(int)$val."'";



xleh gak..dier kuar

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM loginkaunselor INNER JOIN kaunselor ON loginkaunselor.nokp2=kaunselor.nokp2' at line 1
Reply

Use magic Report

Post time 8-3-2009 04:43 PM | Show all posts
agak2 kalo wat  camnie leh tak?...xyah bridge..buat 2 statement

$sql = mysql_query("DELETE FROM loginkaunselor WHERE nokp2=".(int)$val)or die(mysql_error());
$sql = mysql_query("DELETE FROM kaunselor WHERE nokp2=".(int)$val)or die(mysql_error());
Reply

Use magic Report

Post time 8-3-2009 04:45 PM | Show all posts
xpela board n slier81...aku dah buat mcm kat atas tu..wat 1 1...dah jadi...thankss yaaa
Reply

Use magic Report

Post time 10-3-2009 01:11 AM | Show all posts

G

board...yg pasal papar gred tu kan...mcm mane nak jadikan table mcm nie...dah puas cube tp xjadi jugakkk

&#160;SubjekMarkah&#160;Gred
&#160;Sains&#160;90&#160;A
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

10-1-2025 01:34 PM GMT+8 , Processed in 0.095087 second(s), 27 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list