הרשם שאלות ותשובות רשימת חברים לוח שנה הודעות מהיום

חזור   הוסטס - פורום אחסון האתרים הגדול בישראל > עיצוב גראפי, תכנות על כל שפותיו וקידום ושיווק אתרים > פורום תיכנות

   
|!|

 
 
כלים לאשכול תצורת הצגה
Prev הודעה קודמת   הודעה הבאה Next
ישן 01-06-06, 12:30   # 5
-VladK-
הוסטסניון
 
-VladK-'s Avatar
 
מיני פרופיל
תאריך הצטרפות: Apr 2006
גיל: 35
הודעות: 2,182

-VladK- לא מחובר  

בעעע...טוב סתכל...
אני רוצה לאנקלד את העמוד הבא:
PHP קוד:
<?php
define 
("PHP_FILE", true);
///////////////////////
function listpolls( ) {
///////////////////////

include 'db.php';
$sql = "SELECT * FROM master_poll WHERE status = 'Online'";
$res = mysql_query($sql) or die(mysql_error());

// Retrieve the Results
while ($newArray = mysql_fetch_array($res)) {
   
// Convert the Result set into Variables
   
$id = $newArray['id'];
   
$poll_name = $newArray['question'];
   
$status = $newArray['status'];
   
   echo 
"<b>בחר סקר:</b><br />";
   echo 
"<a href=\"poll.php?method=viewpoll&id=$id\">$poll_name</a><br />";
}

}

///////////////////////
function viewpoll( ) {
///////////////////////

$id = $_GET['id'];

include 
'db.php';
$sql = "SELECT * FROM master_poll WHERE id = '$id'";
$res = mysql_query($sql) or die(mysql_error());

// Retrieve the Results
while ($newArray = mysql_fetch_array($res)) {
   
// Convert the Result set into Variables
   
$id = $newArray['id'];
   
$poll_name = $newArray['question'];
   
$status = $newArray['status'];
}

if (
$status == "Offline") {
   echo 
"הסקר שבחרתה אינו פעיל!";
   exit();
}

echo 
"<div style=\"width: 100%;\">
$poll_name
<form action=\"poll.php?method=vote\" method=\"post\">
<div dir=\"rtl\">"
;
$results = "<a href=\"?method=results&id=$id\">";

include 
'db.php';
$sql = "SELECT * FROM poll_answers WHERE poll_id = '$id' ORDER BY id ASC";
$res = mysql_query($sql) or die(mysql_error());

// Retrieve the Results
while ($newArray = mysql_fetch_array($res)) {
   
// Convert the Result set into Variables
   
$id = $newArray['id'];
   
$poll_id = $newArray['poll_id'];
   
$answer = $newArray['answer'];

echo 
"<input type=\"radio\" name=\"answer_id\" value=\"$id\"> $answer<br />";

}
echo 
"</div>
<div dir=\"ltr\" style=\"height:17px;\">
$results<img src=\"2.gif\" width=\"59\" height=\"17\" border=\"0\" /></a> <input type=\"image\" name=\"image\" src=\"1.gif\">
</div>
</div><input type=\"hidden\" name=\"poll_id\" value=\"$id\">\n"
;
echo 
"</form>";

}

///////////////////////
function checkuser( ) {
///////////////////////

$ip = $_SERVER['REMOTE_ADDR'];

include 
'db.php';
$check = mysql_query("SELECT * FROM ban_ip WHERE ipaddress = '$ip' LIMIT 1") or die(mysql_error());
if (
mysql_num_rows($check) <= 0) {
  echo 
"&nbsp;";
} else {
  echo 
"הנהלת האתר החליטה שאין לך זכות להצביע! לפרטים נוספים אנא פנו לצוות ההנהלה.";
  exit();
}

}

///////////////////////
function vote( ) {
///////////////////////

checkuser();

$ip = $_SERVER['REMOTE_ADDR'];
$poll_id = $_POST['poll_id'];
$answer_id = $_POST['answer_id'];
$now = date('Y-m-d g:i:s a');

include 
'db.php';
$check = mysql_query("SELECT * FROM poll_votes WHERE ipaddress = '$ip' AND poll_id = '$poll_id' LIMIT 1") or die(mysql_error());
if (
mysql_num_rows($check) <= 0) {
  
mysql_query("INSERT INTO poll_votes (poll_id, answer_id, ipaddress, time) VALUES ('$poll_id', '$answer_id', '$ip', '$now')") or die (mysql_error());
  echo 
"תודה על ההצבעה! כעת אתה יכול לצפות ב<a href=\"poll.php?method=results&id=$poll_id\">תוצאות הסקר</a>";
} else {
  echo 
"כבר הצבעת בסקר זה!";
}

}

///////////////////////
function results( ) {
///////////////////////

$id = $_GET['id'];
include 
'db.php';

echo 
"<table class=\"content\" width=\"100%\">";
    
$votes = mysql_query("SELECT * FROM poll_votes WHERE poll_id = '$id'") or die(mysql_error());
    
$total = mysql_num_rows($votes);

// Get Available answers
    
$ans_check = mysql_query("SELECT * FROM master_poll, poll_answers WHERE master_poll.id = poll_answers.poll_id AND poll_answers.poll_id = '$id'") or die (mysql_error());
    
$r = mysql_fetch_assoc($ans_check);
    
$answers = mysql_num_rows($ans_check);
    echo 
"<tr><td colspan=3><b>".$r['question']."</b></td></tr>";

// query each answer
for ($i=1; $i <= $answers; $i++)
{
    
$check2 = mysql_query("SELECT poll_answers.id AS ans_id, poll_answers.answer AS answer, master_poll.id AS poll_id, Count(poll_votes.answer_id) AS results
    FROM
    (master_poll INNER JOIN poll_answers ON master_poll.id = poll_answers.poll_id)
    LEFT JOIN poll_votes ON poll_answers.id = poll_votes.answer_id
    WHERE master_poll.id = '$id' and poll_answers.id = '$i'
    GROUP BY master_poll.question, poll_answers.answer"
) or die(mysql_error());
    
$r2 = mysql_fetch_assoc($check2);
    
$a_count = $r2['results'];
    
$a_final = (($r2['results'] / $total)*100);
    echo 
"<tr>
          <td>"
.$r2['answer']."</td>
          <td>$a_count</td>
          <td>"
.number_format($a_final, 0)."%</td>
          </tr>"
;
}

echo 
"</table>";

}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="rtl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<style type="text/css">

.content
{
    margin: .2cm .2cm .2cm .2cm;
    font-family: arial;
    font-size: 10pt;
    color: #000000;
}

.latest
{
    background: #3366CC;
    text-align: center;
    font-family: verdana;
    font-size: 10pt;
    color: #ffffff;
}

.copyright
{
    margin: .2cm .2cm .2cm .2cm;
    font-family: arial;
    font-size: 10pt;
    color: #000000;
}

</style>

</head>

<body>

    <div class="content">
    <?php
        $method 
= $_GET['method'];
        switch (
$method)
        {
            case 
viewpoll:
            
viewpoll();
            break;
            case 
vote:
            
vote();
            break;
            case 
results:
            
results();
            break;
            default:
            
listpolls();
        }
    
?>
    </div>
</body>
</html>
 
 

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 


חוקי פירסום
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


כל הזמנים הם GMT +2. הזמן כעת הוא 01:47.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ