Ne, die Meldung kommt leider weiterhin
Jetzt kommt auch nicht mehr Code:
Notice: Undefined variable: banner in /home/schulbuc/public_html/includes/functions.php on line 66
Notice: Undefined variable: banner in /home/schulbuc/public_html/includes/functions.php on line 67
sondern Code:
Notice: Undefined offset: 0 in /home/schulbuc/public_html/includes/functions.php on line 90
Notice: Undefined offset: 0 in /home/schulbuc/public_html/includes/functions.php on line 92
Notice: Undefined offset: 0 in /home/schulbuc/public_html/includes/functions.php on line 92
Notice: Undefined offset: 0 in /home/schulbuc/public_html/includes/functions.php on line 101
Nur noch kurz zur Erklärung des Script.
Mit
PHP-Code:
$sql = "SELECT
`id`,
`clickurl`,
`imageurl`,
`name`,
`banner_count`,
`banner_max`
FROM
`bero_banner`
WHERE
`check` = '1'
AND
`banner_count` <= `banner_max`
AND
`position` = '". $position ."'";
$result = mysql_query($sql);
while($row = mysql_fetch_assoc($result))
$banner[] = $row;
Rufe ich die vorhandenen Banner aus der Datenbank ab und speichere sie in einem Array.
PHP-Code:
$rand = rand (0, mysql_num_rows($result)-1);
$url = $banner[$rand]['clickurl'];
$id = $banner[$rand]['id'];
$name = $banner[$rand]['imageurl'];
$path = $banner[$rand]['id'];
Dann wähle ich mit rand() ein zufälliges Element aus dem Array aus.
PHP-Code:
print "<a href=\"". $url ."\" target=\"_blank\">\n";
print "<div id=\"promotion-field-right\">\n";
print "<img alt=\"". $name ."\" height=\"600\" border=\"0\" src=\"". $path ."\" width=\"160\">\n";
print "</div>\n";
print "</a>\n";
Hier soll nun der Banner ausgegeben werden.
Lesezeichen