Jump to content
php.lv forumi

JavaScript funkcijā MySQL pieprasījums


reGative

Recommended Posts

Sveiki. Uzrakstīju nelielu javascript funkciju

<script type='text/javascript'>
function speeleet(video_id){
kods=
'<object width="550" height="340"><param name="movie" value="http://www.youtube.com/v/'+video_id+'?version=3&hl=lv_LV&rel=0&autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+video_id+'?version=3&hl=lv_LV&rel=0&autoplay=1" type="application/x-shockwave-flash" width="550" height="340" allowscriptaccess="always" allowfullscreen="true"></embed></object>';
document.getElementById('video_speeleet').innerHTML = kods;}
</script>

ir div elements, uz kura uzspiežot, parādās video. Vajadzētu funkcijā ielikt MySQL pieprasījumu, kurš izvelk video nosaukumu un aprakstu no datubāzes. Tā nebūtu problēma, ja vien varētu video_id uztaisīt par PHP mainīgo un taj embed kodā ielikt php mainīgos. Lūdzu, palīdziet.

Link to comment
Share on other sites

Pārtaisīju funkciju

<script type='text/javascript'>
function speeleet(video_id){
document.getElementById('video_speeleet').innerHTML=request.open("GET", 'pages/video.php?video_id='+video_id, true);
}
</script>

 

video.php fails

<?php$video_id = $_GET['video_id'];$kverijs = mysql_query("SELECT * FROM video WHERE video_id='$video_id'");
$video=mysql_fetch_array($kverijs);?>
<div class='virsraksts'><?=$video['title']?></div>
<object width="550" height="340"><param name="movie" value="http://www.youtube.com/v/<?=$video['video_id']?>?version=3&hl=lv_LV&rel=0&autoplay=1"></param>
<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/<?=$video['video_id']?>?version=3&hl=lv_LV&rel=0&autoplay=1" type="application/x-shockwave-flash" width="550" height="340" allowscriptaccess="always" allowfullscreen="true"></embed></object>
<div class='info'><?=$video['about']?></div>

 

kkas nav kārtībā ar to PHP include, bet kā to uzrakstīt savādāk?

Edited by reGative
Link to comment
Share on other sites

Kas ir 'request'?

 

Javascript konsole kljuudas nemet? (paarbaudiit var ar Inspector uz Webkit paarluukiem vai Firebug uz Firefox)

 

P.S.

 

SQL injekcijas ir iespeejamas...

 

P.S.S

 

100% tu vareeji uzrakstiit vairaak par 'kaut kas nav kaartiibaa ar php include'. Piemeeram pastaastot kas nestraadaa vai kaadas kljuudas redzi. Programmeetaaji nav ziilnieki...

Edited by rATRIJS
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...