لا ابشرك تقهويت الحين ..
كود PHP:
slideshowcontent[0]=["wallpapers/b5/46.jpg", "show.php?cat=wallpapers&catid=30", "_new"]
وعندك
كود PHP:
function getslidehtml(theslide){
var slidehtml=""
if (theslide[1]!="")
slidehtml='<a href="'+theslide[1]+'" target="'+theslide[2]+'">'
slidehtml+=theslide[0]
if (theslide[1]!="")
slidehtml+='</a>'
return slidehtml
}
مالعلاقه بينهم ؟
العلاقة ان كل عنصر من المصفوفة slideshowcontent يمرر كparameter للدالة getslidehtml
لاحظ
slideshowcontent[0]=["wallpapers/b5/46.jpg", "show.php?cat=wallpapers&catid=30", "_new"]
عند استدعاء الدالة getslidehtml فان
theslide[0] =>>> wallpapers/b5/46.jpg
theslide[1] =>>> show.php?cat=wallpapers&catid=30
theslide[2] =>>>_new
كود PHP:
slidehtml='<a href="'+theslide[1]+'" target="'+theslide[2]+'">'
مثال لتغيير في الكود :
كود PHP:
slideshowcontent[0]=["نص الخبر", "linkرابط الخبر", "_new"]
والدالة
getslidehtml
تصير :
كود PHP:
function getslidehtml(theslide){
var slidehtml=""
if (theslide[1]!="")
slidehtml='<a href="'+theslide[1]+'" target="'+theslide[2]+'">'
slidehtml+= theslide[0];
if (theslide[1]!="")
slidehtml+='</a>'
return slidehtml
}
اما جلب الاخبار من قاعده البيانات
فاكتبها داخل كود الجافاسكربت كانك تطبع اكواد html عادية
كود PHP:
while(etc.....){
echo "slideshowcontent[0]=['$row[news]','$row[link]','_blank']\n"
}