< ? php
$DBConnect = mysqli_connect('localhost', 'root', '', 'phpbb');
mysqli_select_db($DBConnect, "phpbb");
$sql = "SELECT topic_title, topic_views, topic_id, forum_id FROM phpbb_topics";
$sql_execute=mysqli_query($DBConnect, $sql)or die(mysqli_error());
while ($row = mysqli_fetch_row($sql_execute)) {
echo "Topic Id: ".$row[2]." - Topic Title:".$row[0]."
";
$oldText="Ask the Analyst";
$newText="Analyst Corner";
$formattedData = str_replace($oldText, $newText, $row[0]);
echo $formattedData;
$updateQuery = "UPDATE phpbb_topics SET topic_title='".$formattedData."' WHERE topic_id='".$row[2]."'";
mysqli_query($DBConnect, $updateQuery) or die(mysqli_error());
}
? >
Monday, March 23, 2009
Wednesday, March 18, 2009
MySQL DATE FORMAT Function for date display
DATE_FORMAT(date,format) |
The following script uses
the DATE_FORMAT() function to display different formats. We will use the NOW() function to get the current date/time:
DATE_FORMAT(NOW(),'%b %d %Y %h:%i %p') |
The result would look something like this:
| Nov 04 2008 11:45 PM 11-04-2008 04 Nov 08 04 Nov 2008 11:45:34:243 |
Where date is a valid date and format specifies the output format for the date/time.
The formats that can be used are:
| Format | Description |
|---|---|
| %a | Abbreviated weekday name |
| %b | Abbreviated month name |
| %c | Month, numeric |
| %D | Day of month with English suffix |
| %d | Day of month, numeric (00-31) |
| %e | Day of month, numeric (0-31) |
| %f | Microseconds |
| %H | Hour (00-23) |
| %h | Hour (01-12) |
| %I | Hour (01-12) |
| %i | Minutes, numeric (00-59) |
| %j | Day of year (001-366) |
| %k | Hour (0-23) |
| %l | Hour (1-12) |
| %M | Month name |
| %m | Month, numeric (00-12) |
| %p | AM or PM |
| %r | Time, 12-hour (hh:mm:ss AM or PM) |
| %S | Seconds (00-59) |
| %s | Seconds (00-59) |
| %T | Time, 24-hour (hh:mm:ss) |
| %U | Week (00-53) where Sunday is the first day of week |
| %u | Week (00-53) where Monday is the first day of week |
| %V | Week (01-53) where Sunday is the first day of week, used with %X |
| %v | Week (01-53) where Monday is the first day of week, used with %x |
| %W | Weekday name |
| %w | Day of the week (0=Sunday, 6=Saturday) |
| %X | Year of the week where Sunday is the first day of week, four digits, used with %V |
| %x | Year of the week where Monday is the first day of week, four digits, used with %v |
| %Y | Year, four digits |
| %y | Year, two digits |
Tuesday, March 17, 2009
Show Hide DIV Webpage
<script language="JavaScript">
function hidediv() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('mysubmenuarea').style.visibility = 'hidden';
document.getElementById('mysubmenuarea').style.display = "none";
}
else {
if (document.layers) { // Netscape 4
document.mysubmenuarea.visibility = 'hidden';
document.getElementById('mysubmenuarea').style.display = "none";
}
else { // IE 4
document.all.mysubmenuarea.style.visibility = 'hidden';
document.getElementById('mysubmenuarea').style.display = "none";
}
}
}
function showdiv() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('mysubmenuarea').style.visibility = 'visible';
document.getElementById('mysubmenuarea').style.display = 'block';
}else {
if (document.layers) { // Netscape 4
document.mysubmenuarea.visibility = 'visible';
}else { // IE 4
document.all.mysubmenuarea.style.visibility = 'visible';
}
}
}
</script>
----| CALL IN EVENT |---------
onmouseover="javascript: return showdiv();" onmouseout="javascript: return showdiv();"
function hidediv() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('mysubmenuarea').style.visibility = 'hidden';
document.getElementById('mysubmenuarea').style.display = "none";
}
else {
if (document.layers) { // Netscape 4
document.mysubmenuarea.visibility = 'hidden';
document.getElementById('mysubmenuarea').style.display = "none";
}
else { // IE 4
document.all.mysubmenuarea.style.visibility = 'hidden';
document.getElementById('mysubmenuarea').style.display = "none";
}
}
}
function showdiv() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('mysubmenuarea').style.visibility = 'visible';
document.getElementById('mysubmenuarea').style.display = 'block';
}else {
if (document.layers) { // Netscape 4
document.mysubmenuarea.visibility = 'visible';
}else { // IE 4
document.all.mysubmenuarea.style.visibility = 'visible';
}
}
}
</script>
----| CALL IN EVENT |---------
onmouseover="javascript: return showdiv();" onmouseout="javascript: return showdiv();"
Thursday, March 12, 2009
Yesterday, Today, One week for MySQL - PHP
$today=date("Y-m-d");
$m= date("m"); // Month value
$de= date("d"); //today's date
$y= date("Y"); // Year value
$sevenDaysBefore = date('Y-m-d', mktime(0,0,0,$m,($de-7),$y));
$thirtyDaysBefore = date('Y-m-d', mktime(0,0,0,$m,($de-30),$y));
$m= date("m"); // Month value
$de= date("d"); //today's date
$y= date("Y"); // Year value
$sevenDaysBefore = date('Y-m-d', mktime(0,0,0,$m,($de-7),$y));
$thirtyDaysBefore = date('Y-m-d', mktime(0,0,0,$m,($de-30),$y));
Subscribe to:
Posts (Atom)