Компьютерный форум NoWa.cc Здесь может быть Ваша реклама
Правила Форума
редакция от 22.06.2020
Форум .::NoWa.cc::.
Вернуться   Компьютерный форум NoWa.cc > В помощь вебмастеру > Веб - Программирование > PHP

Уважаемые пользователи nowa.cc. Мы работаем для вас более 20 лет и сейчас вынуждены просить о финансовой помощи по оплате за сервер.
Окажите посильную поддержку, мы очень надеемся на вас. Реквизиты для переводов ниже.
Webmoney Webmoney WMZ: Z021474945171 Webmoney WME: E159284508897 Webmoney WMUSDT: T206853643180
Кошелёк для вашей помощи YooMoney 4100117770549562
YooMoney Спасибо за поддержку!

Ответ
 
Опции темы Опции просмотра Language
Старый 20.09.2010, 14:12   #1
Пользователь
 
Аватар для Pazan
 
Пол:Мужской
Регистрация: 01.09.2007
Сообщений: 67
Репутация: 3
По умолчанию Проблемы со скриптом календаря JCal

Нашёл на просторах киберпространства нужный мне скрипт JCal Version 1.0 Beta (Sept. 26, 2002). установил, начал тестировать. И тут... чёта не то
Суть проблемы.
В админпанели есть форма с полями Event Title и Event Info. Внизу кнопки Add Event, Delete Event.
При обработке POST в MySQL не записываются данные с этих полей, только дата.

Вот листинг файла index.php:

PHP код:
<html>

    <head>
        <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
        <title>Керування подіями</title>
        <link rel="stylesheet" href="style.css">
    <script language="JavaScript">
<!--
function confirm_del($url) {
    var return_value = confirm('УВАГА!!!\n\nТи дійсно хочеш скасувати цю подію.\n\nДІЙСНО ВПЕВНЕНИЙ????') ;
    if ( return_value == true ) {
        window.location = $url;
    }
}
-->
</script>
    </head>
<body bgcolor="#f0f0f0">



<?php
require ("../config/config_inc.php");

// connect to the database
$conn mysql_connect($db_host$db_user$db_pass) or die("Бляха-муха, чогось не можу приєднатись до бази даних!");
mysql_select_db($db$conn);


//clean input
if (isset($_GET['month'])) { $month $_GET['month']; $month ereg_replace ("[[:space:]]"""$month); $month ereg_replace ("[[:punct:]]"""$month); $month ereg_replace ("[[:alpha:]]"""$month); }
if (isset(
$_GET['year'])) { $year $_GET['year']; $year ereg_replace ("[[:space:]]"""$year); $year ereg_replace ("[[:punct:]]"""$year); $year ereg_replace ("[[:alpha:]]"""$year); if ($year 1990) { $year 1990; } if ($year 2035) { $year 2035; } }
if (isset(
$_GET['today'])) { $today $_GET['today']; $today ereg_replace ("[[:space:]]"""$today); $today ereg_replace ("[[:punct:]]"""$today); $today ereg_replace ("[[:alpha:]]"""$today); }


$month = (isset($month)) ? $month date("n",time());
$year = (isset($year)) ? $year date("Y",time());
$today = (isset($today))? $today date("j"time());
$daylong date("l",mktime(1,1,1,$month,$today,$year));
$monthlong date("F",mktime(1,1,1,$month,$today,$year));
$dayone date("w",mktime(1,1,1,$month,1,$year));
$numdays date("t",mktime(1,1,1,$month,1,$year));
$alldays = array('Нед','Пон','Вів','Сер','Чет','П’ят','Суб');
$next_year $year 1;
$last_year $year 1;
if (
$today $numdays) { $today--; }


//begin outer table structure
echo "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\" width=\"528\">
                <tr>
                    <td>
                        <table border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"311\" bgcolor=\"black\">
                            <tr>
                                <td bgcolor=\"white\" valign=\"middle\" align=\"center\"><b>
$daylong$monthlong $today$year</b></td>
                            </tr>
                        </table>
                    </td>
                    <td valign=\"middle\" align=\"center\">
                        <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
                            <tr>
                                <td valign=\"middle\" align=\"center\"><a href=\""
.$_SERVER['PHP_SELF']."?year=$last_year&today=$today&month=$month\" onmouseover=\"document.calb2.src='../img/ltab2over.gif'\" onmouseout=\"document.calb2.src='../img/ltab2.gif'\"><img src=\"../img/ltab2.gif\" border=\"0\" name=\"calb2\"></a></td><td>&nbsp;</td>
                                <td valign=\"middle\" align=\"center\">
                                    <table border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"180\" bgcolor=\"black\">
                                        <tr>
                                            <td bgcolor=\"white\" valign=\"middle\" align=\"center\"><b>
$year</b></td>
                                        </tr>
                                    </table>
                                </td>
                                <td>&nbsp;</td><td valign=\"middle\" align=\"center\"><a href=\""
.$_SERVER['PHP_SELF']."?year=$next_year&today=$today&month=$month\" onmouseover=\"document.calb1.src='../img/rtab2over.gif'\" onmouseout=\"document.calb1.src='../img/rtab2.gif'\"><img src=\"../img/rtab2.gif\" border=\"0\" name=\"calb1\"></a></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td valign=\"top\">

                            <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"445\">
                            <tr>
                                <td class=\"cellbg\" valign=\"top\">"
;

//load and display day title and content in fields
$sql_date "$year-$month-$today";
$eventQuery "SELECT title, event FROM cal WHERE eventdate = '$sql_date';";
$eventExec mysql_query($eventQuery);
while(
$row mysql_fetch_array($eventExec)) 
{
   
$event_title stripslashes($row["title"]);
   
$event_event stripslashes($row["event"]);
}



echo 
"<form name=\"post\" action=\"post.php?year=$year&today=$today&month=$month&event_title=$event_title\" method=\"post\">
            Event Title<br><input type=\"text\" name=\"day_title\" value=\"
$event_title\" size=\"40\" maxlength=\"30\"><br>
            <br>
            Event Info<br><textarea name=\"day_event\" cols=\"40\" rows=\"14\">
$event_event</textarea>
            <input type=\"hidden\" value=\"
$year\" name=\"year\">
            <input type=\"hidden\" value=\"
$month\" name=\"month\">
            <input type=\"hidden\" value=\"
$today\" name=\"today\">
            <br><br>
            <input type=\"image\" src=\"../img/addevent.gif\">
        </form>\n"
;

echo 
"<a href=\"javascript:void(null)\" onClick=\"confirm_del('post.php?year=$year&today=$today&month=$month&del=1'); return false\"><img src=\"../img/delevent.gif\" border=\"0\"></a>\n";


                 echo 
"</td>
                        </tr>
                        </table>

                    <td valign=\"top\">

    <table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" bgcolor=\"black\" width=\"250\">
            <tr>
                <td valign=\"middle\" align=\"center\" onClick=\"window.location='" 
.$_SERVER['PHP_SELF']. "?year=$year&today=1&month=1';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=1\" class=\"normal\">Січ</a> </td>
                <td valign=\"middle\" align=\"center\" onClick=\"window.location='" 
.$_SERVER['PHP_SELF']. "?year=$year&today=1&month=2';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=2\" class=\"normal\">Лют</a> </td>
                <td valign=\"middle\" align=\"center\" onClick=\"window.location='" 
.$_SERVER['PHP_SELF']. "?year=$year&today=1&month=3';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=3\" class=\"normal\">Бер</a> </td>
                <td valign=\"middle\" align=\"center\" onClick=\"window.location='" 
.$_SERVER['PHP_SELF']. "?year=$year&today=1&month=4';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=4\" class=\"normal\">Кві</a> </td>
                <td valign=\"middle\" align=\"center\" onClick=\"window.location='" 
.$_SERVER['PHP_SELF']. "?year=$year&today=1&month=5';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=5\" class=\"normal\">Тра</a> </td>
                <td valign=\"middle\" align=\"center\" onClick=\"window.location='" 
.$_SERVER['PHP_SELF']. "?year=$year&today=1&month=6';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=6\" class=\"normal\">Чер</a> </td>
            </tr>
            <tr>
                <td valign=\"middle\" align=\"center\" onClick=\"window.location='" 
.$_SERVER['PHP_SELF']. "?year=$year&today=1&month=7';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=7\" class=\"normal\">Лип</a> </td>
                <td valign=\"middle\" align=\"center\" onClick=\"window.location='" 
.$_SERVER['PHP_SELF']. "?year=$year&today=1&month=8';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=8\" class=\"normal\">Сер</a> </td>
                <td valign=\"middle\" align=\"center\" onClick=\"window.location='" 
.$_SERVER['PHP_SELF']. "?year=$year&today=1&month=9';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=9\" class=\"normal\">Вер</a> </td>
                <td valign=\"middle\" align=\"center\" onClick=\"window.location='" 
.$_SERVER['PHP_SELF']. "?year=$year&today=1&month=10';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=10\" class=\"normal\">Жов</a> </td>
                <td valign=\"middle\" align=\"center\" onClick=\"window.location='" 
.$_SERVER['PHP_SELF']. "?year=$year&today=1&month=11';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=11\" class=\"normal\">Лис</a> </td>
                <td valign=\"middle\" align=\"center\" onClick=\"window.location='" 
.$_SERVER['PHP_SELF']. "?year=$year&today=1&month=12';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=1&month=12\" class=\"normal\">Гру</a> </td>
            </tr>
        </table><br>\n"
;


//display name of month
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"1\" bgcolor=\"black\" width=\"250\">\n<tr>\n";
echo 
"<td class=\"cellbg\" colspan=\"7\" valign=\"middle\" align=\"center\"><font class=\"regheading\"><b>" date("F",mktime(1,1,1,$month,1,$year)) . "</b></font>\n</td>\n";
echo 
"</tr>\n<tr>\n";


//display day names
foreach($alldays as $value) {
  echo 
"<td class=\"cellbg\" valign=\"middle\" align=\"center\" width=\"10%\"><font class=\"normaltext\"><b>$value</b></font></td>\n";
}
echo 
"</tr>\n<tr>\n";


//display blank days as nbsp's
for ($i 0$i $dayone$i++) {
  echo 
"<td class=\"cellbg\" valign=\"middle\" align=\"center\"><font class=\"normaltext\">&nbsp;</font></td>\n";
}


//display days
for ($zz 1$zz <= $numdays$zz++) {
  if (
$i >= 7) {  print("</tr>\n<tr>\n"); $i=0; }
  
//check current day for an event
  
$result_found 0;
     if (
$zz == $today) { //mark todays cell regardless
    
echo "<td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=$zz&month=$month';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='celltoday'\" class=\"celltoday\"><a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=$zz&month=$month\" class=\"today\">$zz</a></td>\n";
      
$result_found 1;
  }
  if (
$result_found != 1) {//search for event on this day and mark cell if title not empty
      
$sql_currentday "$year-$month-$zz";
      
$eventQuery "SELECT title FROM cal WHERE eventdate = '$sql_currentday';";
      
$eventExec mysql_query($eventQuery);
      while(
$row mysql_fetch_array($eventExec)) {
          if (
strlen($row["title"]) > 0) {
              echo 
"<td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=$zz&month=$month';\"  onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellevent'\" class=\"cellevent\"><a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=$zz&month=$month\" class=\"normal\">$zz</a></td>\n";
              
$result_found 1;
          }
      }
  }

  if (
$result_found != 1) {//show default cell style for day
      
echo "<td valign=\"middle\" align=\"center\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$year&today=$zz&month=$month';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"><a href=\"".$_SERVER['PHP_SELF']."?year=$year&today=$zz&month=$month\" class=\"normal\">$zz</a></td>\n";
  }

  
$i++; $result_found 0;
}

$create_emptys - (($dayone $numdays) % 7);
if (
$create_emptys == 7) { $create_emptys 0; }

//display blank remaining cells
if ($create_emptys != 0) {
  echo 
"<td class=\"cellbg\" valign=\"middle\" align=\"center\" colspan=\"$create_emptys\"><font class=\"normaltext\">&nbsp;</font></td>\n";
}

echo 
"</tr>\n";
echo 
"</table><br>\n";
//add weekly glance here if needed
echo "<center><a href=\"".$_SERVER['PHP_SELF']."\" class=\"normal\">Сьогодні</a></center>";



//end outer table
echo "</td>
                </tr>
            </table>\n"
;
mysql_close($conn);

?>

</body>
</html>
и листнг файла post.php:

PHP код:
<?php

require ("../config/config_inc.php");
// connect to the database
$conn mysql_connect($db_host$db_user$db_pass) or die("Бляха-муха, чогось не можу приєднатись до бази даних!");
mysql_select_db($db$conn);

//clean input
if (isset($_GET['month'])) { $month $_GET['month']; $month ereg_replace ("[[:space:]]"""$month); $month ereg_replace ("[[:punct:]]"""$month); $month ereg_replace ("[[:alpha:]]"""$month); }
if (isset(
$_GET['year'])) { $year $_GET['year']; $year ereg_replace ("[[:space:]]"""$year); $year ereg_replace ("[[:punct:]]"""$year); $year ereg_replace ("[[:alpha:]]"""$year); if ($year 1990) { $year 1990; } if ($year 2035) { $year 2035; } }
if (isset(
$_GET['today'])) { $today $_GET['today']; $today ereg_replace ("[[:space:]]"""$today); $today ereg_replace ("[[:punct:]]"""$today); $today ereg_replace ("[[:alpha:]]"""$today); }

$month = (isset($month)) ? $month date("n",time());
$year = (isset($year)) ? $year date("Y",time());
$today = (isset($today))? $today date("j"time());
$sql_date "$year-$month-$today";


if (
$_GET['del'] == 1) {
    
$eventQuery "DELETE FROM cal WHERE eventdate = '$sql_date';";
    
$eventExec mysql_query($eventQuery)or die("Йопрст, не можу знайти скасовану подію");
    
header("Location: index.php?year=$year&month=$month&today=$today");
    exit();
}



//no title, no comply
if (strlen($_POST['day_title']) < 1) {
    
header("Location: index.php?year=$year&month=$month&today=$today");
    exit();
}



//determine if date holds data for proper sql call on unique
//echo  "SELECT id FROM cal WHERE eventdate = '$sql_date'";
$eventQuery "SELECT id FROM cal WHERE eventdate = '$sql_date';";
$eventExec mysql_query($eventQuery); $event_found "";
while(
$row mysql_fetch_array($eventExec)) {
  
//$echo = $row["id"];
    
$event_found 1;
}

$day_title_safe addslashes($day_title);
$day_event_safe addslashes($day_event);

if (
$event_found == 1
    {
    
//UPDATE
        
$postQuery "UPDATE cal SET title = '$day_title_safe', event = '$day_event_safe' WHERE eventdate = '$sql_date';";
        
$postExec mysql_query($postQuery) or die("Та що ж таке?! Не можу ОНОВИТИ подію в базі даних!");
        
mysql_close($conn);
        
header("Location: index.php?year=$year&month=$month&today=$today");
    } 
else 
    {
    
//INSERT
        
$postQuery "INSERT INTO cal (eventdate,title,event) VALUES ('$sql_date','$day_title_safe','$day_event_safe');";
    
//$postQuery = "INSERT INTO cal (eventdate,title,event)    VALUES ('$sql_date','$day_title_safe','$day_event_safe');";
        
$postExec mysql_query($postQuery) or die("Ну, йо-ма-йо, не можу надіслати подію для запису в базі даних!");
        
mysql_close($conn);
        
header("Location: index.php?year=$year&month=$month&today=$today");
        
}
?>
в чём может быть заковыка?
Pazan вне форума
 
Ответить с цитированием Вверх
Здесь может быть Ваша реклама
Здесь может быть Ваша реклама


Реклама: Кольцо из серебра с ониксомимплантация все на 4 в москвеМебельный магазин: детский спортивный комплекс юный атлет - Переходи на сайт!катышев сергейМебельный магазин: зеркало настенное - Переходи на сайт!


Ответ


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Проблема со скриптом! WebStronG PHP 5 08.08.2009 05:38
Помогите со скриптом! simolin Java Script 4 20.09.2008 10:58
Выбор даты из календаря средствами PHP alexmil PHP 5 02.05.2008 00:51
Помогите со скриптом банера Vinni_incorp Java Script 5 16.01.2008 16:12

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.

Быстрый переход


Текущее время: 13:43. Часовой пояс GMT +3.


Copyright ©2004 - 2026 NoWa.cc

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2026, vBulletin Solutions, Inc. Перевод: zCarot
Время генерации страницы 0.04090 секунды с 11 запросами