Ik ben bezig met een referentie script voor mijn website. In de database zitten ~50 referenties. Het is de bedoeling dat het script 4 random referenties weergeeft.
mijn script:
<?php
$gettestimonials = mysql_query("SELECT name, testimonial FROM testimonials WHERE check = 1 ORDER BY RAND() limit 4");
$testimonials = mysql_fetch_assoc($gettestimonials);
$name1 = $testimonials['name'[0]]; //hier krijg ik een error
$testimonial1 = $testimonials['testimonial'[0]];
$name2 = $testimonials['name'[1]];
$testimonial2 = $testimonials['testimonial'[1]];
$name3 = $testimonials['name'[2]];
$testimonial3 = $testimonials['testimonial'[2]];
$name4 = $testimonials['name'[3]];
$testimonial4 = $testimonials['testimonial'[3]];
?>
<div class="column_one_half">
<blockquote class="theme"><?php echo $testimonial1; ?></p><p class="blockquote_cite"><?php echo $name1; ?></p></blockquote>
</div>
<div class="column_one_half last">
<blockquote class="theme"><?php echo $testimonial2; ?></p><p class="blockquote_cite"><?php echo $name2; ?></p></blockquote>
</div>
<div class="clearfix"></div>
<div class="column_one_half">
<blockquote class="theme"><?php echo $testimonial3; ?></p><p class="blockquote_cite"><?php echo $name3; ?></p></blockquote>
</div>
<div class="column_one_half last">
<blockquote class="theme"><?php echo $testimonial4; ?></p><p class="blockquote_cite"><?php echo $name4; ?></p></blockquote>
</div>
<div class="clearfix"></div>
Waarom krijg ik hier een error? En wat kan ik doen om het script toch werkend te maken?
(Ik ben heel slecht met MSQL)
Alvast bedankt!