|
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 |
|
|
|
|
|
|
|
try n.. kot boleh jalan
- function DatesInterconv($DateFormat1, $DateFormat2, $DateStr)
- {
- $base_struc = split('[:/.\ \-]', $DateFormat1);
- $date_str_parts = split('[:/.\ \-]', $DateStr );
- $date_elements = array();
- $p_keys = array_keys( $base_struc );
- foreach( $p_keys as $p_key )
- {
- if( !empty( $date_str_parts[$p_key] ))
- {
- $date_elements[$base_struc[$p_key]] = $date_str_parts[$p_key];
- }
- else
- return false;
- }
- if(array_key_exists('M', $date_elements))
- {
- $Mtom=array(
- "Jan"=>"01",
- "Feb"=>"02",
- "Mar"=>"03",
- "Apr"=>"04",
- "May"=>"05",
- "Jun"=>"06",
- "Jul"=>"07",
- "Aug"=>"08",
- "Sep"=>"09",
- "Oct"=>"10",
- "Nov"=>"11",
- "Dec"=>"12",
- );
- $date_elements['m']=$Mtom[$date_elements['M']];
- }
- $dummy_ts = mktime(
- $date_elements['H'],
- $date_elements['i'],
- $date_elements['s'],
- $date_elements['m'],
- $date_elements['d'],
- $date_elements['Y']
- );
- return date($DateFormat2, $dummy_ts );
- }
- echo DatesInterconv('Y-m-d','d/m/Y','2009-10-28');
Copy the Code |
|
|
|
|
|
|
|
Habis variable $datestart tu nak letak mana? <--- soalan inesen |
|
|
|
|
|
|
|
$datestart tu value dari oracle kan
so $datestart letak kat value
DatesInterconv([source format],[out_put format],[value]); |
|
|
|
|
|
|
|
board...kat coding ni...mane nak selit order by..?
$sql="SELECT * FROM $tbl_name WHERE nokp = '". $_SESSION['nokp'] ."' LIMIT ". $offset .",". $rowsPerPage; |
|
|
|
|
|
|
|
kena ikut urutan
SELECT * FROM table WHERE 1 GROUP BY field ORDER BY field LIMIT 0,10 |
|
|
|
|
|
|
|
tq |
|
|
|
|
|
|
|
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? |
|
|
|
|
|
|
|
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']; |
|
|
|
|
|
|
|
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 validate is_numeric($_POST['phone'])) xpe ke?....
aku just buat script utk reminder  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
 if (IsNumeric(document.s.phone.value)==false) 
  {
  alert("Masukkan angka sahaja bagi No Telefon!");
  document.s.phone.focus();
  return false;
  }
  else
  return true; 
  }
 
function IsNumeric(strString)
  // check for valid numeric strings 
  {
  var strValidChars = "0123456789";
  var strChar;
  var blnResult = true;
  if (strString.length == 0) return false;
  // test strString consists of valid characters listed above
  for (i = 0; i < strString.length && blnResult == true; i++)
  {
  strChar = strString.charAt(i);
  if (strValidChars.indexOf(strChar) == -1)
  {
  blnResult = false;
  }
  }
  return blnResult;
  } |
|
|
|
|
|
|
|
board..naper bile aku wat nie...dier error...rasenye mcm dah betull..
if(isset($_POST['delete'])){
  if(sizeof($_POST['chkbx'])){
  foreach($_POST['chkbx'] AS $val){
  $sql = mysql_query("DELETE FROM loginkaunselor,kaunselor WHERE loginkaunselor.nokp2 = kaunselor.nokp2 AND loginkaunselor.nokp2 =".(int)$val)or die(mysql_error());
  }
  }
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 ] |
|
|
|
|
|
|
|
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()); |
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
$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 ] |
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
sory beb.....
maksud aku javascript |
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
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()); |
|
|
|
|
|
|
|
xpela board n slier81...aku dah buat mcm kat atas tu..wat 1 1...dah jadi...thankss yaaa |
|
|
|
|
|
|
|
G
board...yg pasal papar gred tu kan...mcm mane nak jadikan table mcm nie...dah puas cube tp xjadi jugakkk
 Subjek | Markah |  Gred |  Sains |  90 |  A |
|
|
|
|
|
|
|
| |
|