MySQL liefert nicht ALLE Datensätze zurück

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MySQL liefert nicht ALLE Datensätze zurück

    Hallo,

    ich bin ein Anfänger in php und mySQL und habe folgendes Problem und bin schon am Verzweifeln!!!!

    1) meine DB spuckt nicht alle Daten aus der DB, liegt dies an meiner while-Schleife????

    PHP Code:
    <?php

    require_once "grab_globals.inc.php";
    include 
    "config.inc.php";
    include 
    "functions.inc";
    include 
    "$dbsys.inc";


    $sql "SELECT start_time, end_time, (end_time - start_time), $tbl_entry.firma, $tbl_entry.contact, $tbl_entry.description, name, $tbl_room.room_name, $tbl_entry.catering_index, $tbl_entry.drive FROM $tbl_entry$tbl_room WHERE $tbl_entry.room_id = $tbl_room.id ";


    $res sql_query($sql);
    if (! 
    $resfatal_error(0sql_error());

    $row_count 0;

    while(
    $row=mysql_fetch_array($res))
    {

    if( 
    $enable_periods )
        list( 
    $start_period$start_date) =  period_date_string($row[0]);
    else
            
    $start_date time_date_string($row[0]);

    if( 
    $enable_periods )
        list( , 
    $end_date) =  period_date_string($row[1], -1);
    else
            
    $end_date time_date_string($row[1]);
            
    $duration         $row[2] - cross_dst($row[0], $row[1]);
    $firma              htmlspecialchars($row[3]);
    $description     htmlspecialchars($row[4]);        
    $contact         htmlspecialchars($row[5]);
    $name            htmlspecialchars($row[6]);
    $room            htmlspecialchars($row[7]);
    $catering_index  htmlspecialchars($row[8]);
    $drive            htmlspecialchars($row[9]);

    $row_count++;
    }

    $enable_periods toPeriodString($start_period$duration$dur_units) : toTimeString($duration$dur_units);

    ?>

    <h3><?php echo get_vocab("visitor"?></h3>

     <table class="mrbs_visitors" border="1" cellpadding="0" cellspacing="0" style="width:100%; vertical-align:top;text-align:center; background-color:none; padding:5px;">
       <tr>
        <td style="width:130px;white-space:nowrap;text-align:center;"><?php echo get_vocab("start_date"?></td>
          <td style="width:130px;white-space:nowrap;text-align:center;"><?php echo get_vocab("end_date"?></td>
        <td style="width:100px;text-align:center;"><?php echo get_vocab("duration"?></td>
        <td style="width:130px;text-align:center;"><?php echo get_vocab("firma"?></td>
        <td style="width:130px;text-align:center;"><?php echo get_vocab("description"?></td>
           <TD CLASS=CR style="width:230px; white-space:nowrap; text-align:center;"><?php echo get_vocab("contact")?></TD>
           <TD CLASS=CR style="width:130px;text-align:center;"><?php echo get_vocab("namebooker")?></TD>
        <TD CLASS=CR style="width:130px;text-align:center;"><?php echo get_vocab("room")?></TD>
           <TD CLASS=CR style="width:90px;text-align:center;"><?php echo get_vocab("catering_index")?></TD>
           <TD CLASS=CR style="width:90px;text-align:center;"><?php echo get_vocab("drive")?></TD>
       </tr>
       
       <tr>
        <td><?php    echo $start_date ?></td>
        <td><?php    echo $end_date ?></td>
        <td><?php    echo $duration " " $dur_units ?></td>
        <td><?php    echo nl2br($firma?></td>
        <td><?php    echo nl2br($contact?></td>
        <td><?php    echo nl2br($description?></td>
        <td><?php    echo nl2br($name?></td>
        <td><?php    echo nl2br($room?></td>
        <td><?php
        
    if ($catering_index == 0)

     { echo 
    get_vocab("catering_index_0"); }

    elseif (
    $catering_index == 1)

     { echo 
    get_vocab("catering_index_1"); }

    elseif (
    $catering_index == 2)

     { echo 
    'Erweiterte Bewirtung'; } 
        
     
    ?></td>
        

    <td><?php  
        
    if($drive == 0) { 
        echo 
    get_vocab("NO") ; 
        } else { echo 
    get_vocab("YES"); 
        } 
    ?></td>

    </tr>
    </table>

    <BR>
    <?php if (isset($HTTP_REFERER)) //remove the link if displayed from an email
    ?>
    <a href="<?php echo $HTTP_REFERER ?>"><?php echo get_vocab("returnprev"?></a>
    <?php
    }
    include 
    "trailer.inc"?>
    2) Ich möchte alle Daten ab dem heutigen Zeitpunkt sehen (hat was mit timestamp zu tun???)

    Wie bekomme ich das denn hin????

    Vielen Dank!!!!

  • #2
    hallo,

    das kann mehrere Ursachen sein, die erste die mir einfällt wegen deiner Abfrage

    PHP Code:
    WHERE $tbl_entry.room_id $tbl_room.id "; 
    wenn in der Tabelle $tbl_room die id nicht vorhanden ist wird der ganze Datensatz nicht geladen also auch nicht der datensatz aus $tbl_entry

    hier muß mit LEFTt JOIN geabrbeitet werden

    da ich selbst noch auf Kriegsfuß mit LEFT JOIN bin, denn manche Abfragen haben auch bei mir nicht funktioniert

    es müsste aber ungefähr so aus sehen

    PHP Code:
    $sql "SELECT start_time, end_time, (end_time - start_time), $tbl_entry.firma, $tbl_entry.contact, $tbl_entry.description, name,
    $tbl_room.room_name, $tbl_entry.catering_index, $tbl_entry.drive FROM $tbl_entry LEFT JOIN $tbl_room ON $tbl_room.id=$tbl_entry.room_id"
    [COLOR=#0000cc][COLOR=black]einfach mal ausprobieren[/COLOR][/COLOR]
    Last edited by phpsven; 22-05-2011, 12:14.

    Comment


    • #3
      Bitte beachten: PHP-Scripte PHP-Tutorials PHP-Jobs und vieles mehr - Ankündigungen im Forum : SQL / Datenbanken

      PHP+MySQL-Probleme - php.de
      PHP+MySQL-Probleme - PHP Forum: phpforum.de

      *close*
      I don't believe in rebirth. Actually, I never did in my whole lives.

      Comment

      Working...
      X