Subversion-Projekte lars-tiefland.shop_ns

Revision

Revision 14 | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?php
    $indexes = array(
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        );
    mysql_connect( "localhost", "root", "NcC2007" );
    mysql_select_db( "mediaran_de" );
    foreach ( $indexes as $index )
    {
        $typ = "Bild";
        if ( $index == 3 )
        {
            $typ = "Video";
        }
        elseif ( $index == 4 )
        {
            $typ = "Dokument";
        }
        $sql = "SELECT
                id,
                bild_" . $index . "_url AS bild_url,
                bildunterschrift_" . $index . " AS bild_unterschrift,
                bild_position_" . $index . " AS bild_position
            FROM
                artikel
            WHERE
                bild_" . $index . "_url <> ''
            AND
                language = 'DE'
        ";
        $res = mysql_query( $sql );
        if ( ! $res )
        {
            die( mysql_error() . "\n" . $sql . "\n" );
        }
        while ( $row = mysql_fetch_assoc( $res ) )
        {
            echo "Artikel " . $row["id"] . "\n";
            $sql_i = "
                INSERT INTO
                    artikel_bild
                SET
                    artikel = " . $row["id"] . ",
                    bild_index = $index,
                    url = '" . mysql_real_escape_string( $row["bild_url"] ) .
                "',
                    position = '" . mysql_real_escape_string( $row["bild_position"] ) .
                "',
                    text = '" . mysql_real_escape_string( $row["bild_unterschrift"] ) .
                "',
                    typ = '" . $typ . "'
            ";
            $res_i = mysql_query( $sql_i );
            if ( ! $res_i )
            {
                die( mysql_error() . "\n" . $sql_i . "\n" );
            }
        }
    }
?>