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

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

   
|!|

 
 
כלים לאשכול תצורת הצגה
Prev הודעה קודמת   הודעה הבאה Next
ישן 29-11-10, 19:33   # 1
morsrh
חבר מתקדם
 
morsrh's Avatar
 
מיני פרופיל
תאריך הצטרפות: Feb 2010
מיקום: אשקלון.
גיל: 31
הודעות: 444
שלח הודעה באמצעות MSN אל morsrh

morsrh לא מחובר  

MYSQLI ועוד שטויות.

טוב אז יש לי את הקוד הזה.
PHP קוד:
<?php

/**
 * @author Mor Sela
 * @copyright 2010
 */

class test{
    private 
$text;
    private 
$sqli;
    private 
$result;
    private 
$number;
    private 
$result2;
    private 
$num;
    private 
$counter;
    private 
$holder;
    
    function 
coon(){
        
$this->sqli = new mysqli("localhost""root""""test");
        
$this->number=2;
        if(
mysqli_connect_errno()){
            echo 
'Could not connect to data base , Error : '.mysqli_connect_error();
            exit;
        }
    }
    function 
getText(){
        
$this->result=$this->sqli->query("SELECT * FROM `tests`");
        
$this->num=$this->result->num_rows;
        while (
$this->result->fetch_object()) {
           
$this->result2=$this->result->fetch_assoc();
           
$this->echoText($this->result2['test1']);
        }
    }
    function 
echoText($text){
        echo 
'<div class="smalldiv">'.$text.'</div>';
    }
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Check Divs With PHP!</title>
    <style>
    .smalldiv{
        text-align:center;
        width: 99%;
        border-style:solid;
        border-color:blue;
        border-width:1.5px;
    }
    </style>
</head>

<body>

<?php

$control 
= new test();
$control -> coon();
$control->getText();

?>

</body>
</html>

דבר ראשון , זה אפשרי שהוא מוציא לי 6 תוצאות ומדפיס רק 3?
והוא מדפיס רק את הזוגיים ולא את האי זוגיים , מה הבעיה פה?

דבר שני , האם זה אפשרי לקצר את הפעולה עם ה- while?
שזה קודם עושה fetch_object ואחרי זה עושים fetch_assoc , איך אפשר לקצר את זה אם אפשר והאם זה יעיל כמו שעשיתי? (אני בא מmysql רגיל וזה קצת שונה לי להריץ 2 פקודות על אותו מערך.)

תודה.
  Reply With Quote
 

חברים פעילים הצופים באשכול זה: 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. הזמן כעת הוא 16:45.

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