النتائج 1 إلى 6 من 6

الموضوع: كيف ادمج كود جافا سكريبت بالبي اتش بي php

  1. #1
    عضو نشيط
    تاريخ التسجيل
    Nov 2005
    المشاركات
    92

    كيف ادمج كود جافا سكريبت بالبي اتش بي php



    السلام عليكم ورحمة الله وبركاته

    أخواني ابي ادمج كود الجافا التالي بكود جلب الاخبار من القاعده ( php )
    بحيث تطلع أخر الأخبار مثل موقع البي بي سي http://news.bbc.co.uk/ عند LATEST فوق

    وليكن كود الجافا في ملف خاص مثلاً java.js

    كود:
    	// Control parameters
    	var theCharacterTimeout = 50;
    	var theStoryTimeout     = 5000;
    	var theWidgetOne        = "_";
    	var theWidgetTwo        = "-";
    	var theWidgetNone       = "";
        var theItemCount = theSummaries.length;
    	var NS6=(document.getElementById && !document.all) ? true : false;
    	
    // Ticker startup
    
    function startTicker()
    {
    
    	// Define run time values
    	theCurrentStory     = -1;
    	theCurrentLength    = 0;
    	// Locate base objects
    	if (document.getElementById) {	
    			runTheTicker();   	
    		 }
    	else {
                document.write("<style>.ticki{display:none;}.ticko{border:0px; padding:0px;}</style>");
                return true;
    	}
    }
    // Ticker main run loop
    function runTheTicker()
    {
    	var myTimeout;  
    	// Go for the next story data block
    	if(theCurrentLength == 0)
    	{
    		theCurrentStory++;
    		theCurrentStory      = theCurrentStory % theItemCount;
    		theStorySummary      = theSummaries[theCurrentStory];
    		theTargetLink        = theSiteLinks[theCurrentStory];
    	}
    	
    	var textTitle = theStorySummary.substring(0,theCurrentLength) + whatWidget();
    	
    	if (theTargetLink ) {
    	
    		if (NS6) {
    	document.getElementById("theTicker").innerHTML  = '<a href="'+ theTargetLink +'" target="_top" class="siteNavigation">'+textTitle+'</a>';
    				 }
    		else {
    	document.all.theTicker.innerHTML  = '<a href="'+ theTargetLink +'" target="_top" class="siteNavigation">'+textTitle+'</a>';
    				}
    						} 	
    	else {
    		if (NS6) {
    	document.getElementById("theTicker").innerHTML = '<span class="tickertext">'+textTitle+'</span>';
    				}
    		else {
    	document.all.theTicker.innerHTML  = '<span class="tickertext">'+textTitle+'</span>';
    				}
    	}
    	
    	// Modify the length for the substring and define the timer
    	if(theCurrentLength != theStorySummary.length)
    	{
    		theCurrentLength++;
    		myTimeout = theCharacterTimeout;
    	}
    	else
    	{
    		theCurrentLength = 0;
    		myTimeout = theStoryTimeout;
    	}
    	// Call up the next cycle of the ticker
    	setTimeout("runTheTicker()", myTimeout);
    }
    
    // Widget generator
    function whatWidget()
    {
    	if(theCurrentLength == theStorySummary.length)
    	{
    		return theWidgetNone;
    	}
    
    	if((theCurrentLength % 2) == 1)
    	{
    		return theWidgetOne;
    	}
    	else
    	{
    		return theWidgetTwo;
    	}
    }
    
    startTicker();
    وهذا الملف الي فيه الجافا عباره عن ملف html
    كود:
    أخر الأخبار&nbsp;
    <SPAN id=theTicker></SPAN>
    <SCRIPT language=javascript type=text/javascript>
    var theSummaries = new Array("Meles oo ka ha");
    var theSiteLinks = new Array("http://www.hhh.shtml");</SCRIPT>
    
    <SCRIPT src="java.js" 
    type=text/javascript></SCRIPT>

    وهذا الكود الي يجلب الأخبار من القاعده

    كود PHP:
    include ("admin/config.php");
    $n=mysql_query("select * from news");
    while (
    $s=mysql_fetch_array($n)) {
    $id=$s['id'];
    $sub=$s['sub'];
    $wr=$s['wr'];
    $txt=$s['txt'];
    $txt1=$s['txt1'];

    echo 
    $sub;

    }
    ?> 
    كيف الحين أخلي أخر الأخبار تطلع بشكل موقع البي بي سي كمثل الأله الطابعه على حرف حرف

    جميع الأكواد المهمه فوق .

    الرجاء من الجميع مساعدتي والخبراء أيضاً

    ولكم جزيل الشكر





    التعديل الأخير تم بواسطة Abderisaq ; 13-03-2007 الساعة 02:53 PM سبب آخر: خطا في العنوان
    __________________
    كود PHP:
    <?php
    $name 
    "w w w . A l m S l o o B . c o m";
    $name .= "من طلب العلا سهر الليالي";
    echo 
    $name;
    ?>
    منتديات المسلوب العربي .. نلتقي لنرتقي

    www.almsloob.com/vb


  2. #2
    عضو نشيط
    تاريخ التسجيل
    Nov 2005
    المشاركات
    92


    UP
    للرفع


    ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟ :eek3:





    __________________
    كود PHP:
    <?php
    $name 
    "w w w . A l m S l o o B . c o m";
    $name .= "من طلب العلا سهر الليالي";
    echo 
    $name;
    ?>
    منتديات المسلوب العربي .. نلتقي لنرتقي

    www.almsloob.com/vb

  3. #3
    عضو نشيط
    تاريخ التسجيل
    Nov 2005
    المشاركات
    73


    وعليكم السلام ورحمة الله وبركاته ..

    اهلين حياك الله ... معليش والله أني مشغول هذي الأيام فمانيب أدخل على سوالف دايم ..
    لكن الحمدلله لحقنا على موضوعك ..

    هذا تعديل بسيط ... ولو أني أشوف أن الدعوى واضحة الله يصلحك المفروض أنك جربت حظك في التعديل

    التعديل اللي سويته على كود الجاف اللي في الـ HTML .. واللي في الإستعلام من قاعدة البيانات ..
    ولكن ملف الجافا سكريبت .. ماسويت عليه ولا تعديل ... عشان كذا أنت على طول في صفحة البي اتش بي جرب هذا الكود لحاله :
    كود PHP:

     
    include ("admin/config.php"); 
    $n=mysql_query("select * from news"); 
    while (
    $s=mysql_fetch_array($n)) { 
    $id=$s['id']; 
    $sub=$s['sub']; /// لنفترض أن قيمة هذا المتغير هي عنوان الخبر ..
    $wr=$s['wr']; 
    $txt=$s['txt']; 
    $txt1=$s['txt1']; 

    echo 
    "
    أخر الأخبار&nbsp;
    <SPAN id=theTicker></SPAN>
    <SCRIPT language=javascript type=text/javascript>
    var theSummaries = new Array("".
    $sub.""); // تم إضافة عنوان الخبر هنا ..
    var theSiteLinks = new Array("
    http://www.site.com/news.php?id=".$id."");</SCRIPT> // وهنا تم إضافة رابط الخبر ..

    <SCRIPT src="java.js" type=text/javascript></SCRIPT>
    ";

    echo $sub; 


    ?> 

    واعذرني أخوي إذا كان فيه خطأ .... لأني والله ماقد جربت هذا الكود حق الـ BBC

    أتمنى أن الكود صحيح ... وأي خطأ يطلع لك انسخ السطر واكتبه هنا ...

    دعواتك يالغالي ..






  4. #4
    عضو نشيط
    تاريخ التسجيل
    Nov 2005
    المشاركات
    92


    الف شكر لك أخوي

    جربت طريقتك أخوي elamaken بس فيها أخطا ماأشتغل .. وسويته أنا كمان نفس طريقتك

    هل من طريقة أخرى لعمل مثل الـ BBC


    منتظر الحل :eek3:





    __________________
    كود PHP:
    <?php
    $name 
    "w w w . A l m S l o o B . c o m";
    $name .= "من طلب العلا سهر الليالي";
    echo 
    $name;
    ?>
    منتديات المسلوب العربي .. نلتقي لنرتقي

    www.almsloob.com/vb

  5. #5
    عضو فعال
    تاريخ التسجيل
    Nov 2005
    المشاركات
    1,307


    هذه تجربة سريعه منى


    كود:
    <body>
    <DIV class=ticki><A class=tickl id=tickerAnchor 
    href="http://news.bbc.co.uk/nol/ifs_news/hi/front_page/ticker.stm#" 
    target=_top></A></DIV>
    <SCRIPT language=JavaScript type=text/javascript>
    <!--
    // Ticker startup
    function startTicker()
    {
    	// Define run time values
    	theCurrentStory     = -1;
    	theCurrentLength    = 0;
    	// Locate base objects
    	if (document.getElementById) {	
    		    theAnchorObject     = document.getElementById("tickerAnchor");
    			runTheTicker();   	
    		 }
    	else {
                document.write("<style>.ticki{display:none;}.ticko{border:0px; padding:0px;}</style>");
                return true;
    	}
    }
    // Ticker main run loop
    function runTheTicker()
    {
    	var myTimeout;  
    	// Go for the next story data block
    	if(theCurrentLength == 0)
    	{
    		theCurrentStory++;
    		theCurrentStory      = theCurrentStory % theItemCount;
    		theStorySummary      = theSummaries[theCurrentStory].replace(/&quot;/g,'"');		
    		theTargetLink        = theSiteLinks[theCurrentStory];
    		theAnchorObject.href = theTargetLink;
    		thePrefix 	     = "<span class=\"tickls\">" + theLeadString + "</span>";
    	}
    	// Stuff the current ticker text into the anchor
    	theAnchorObject.innerHTML = thePrefix + 
    	theStorySummary.substring(0,theCurrentLength) + whatWidget();
    	// Modify the length for the substring and define the timer
    	if(theCurrentLength != theStorySummary.length)
    	{
    		theCurrentLength++;
    		myTimeout = theCharacterTimeout;
    	}
    	else
    	{
    		theCurrentLength = 0;
    		myTimeout = theStoryTimeout;
    	}
    	// Call up the next cycle of the ticker
    	setTimeout("runTheTicker()", myTimeout);
    }
    // Widget generator
    function whatWidget()
    {
    	if(theCurrentLength == theStorySummary.length)
    	{
    		return theWidgetNone;
    	}
    
    	if((theCurrentLength % 2) == 1)
    	{
    		return theWidgetOne;
    	}
    	else
    	{
    		return theWidgetTwo;
    	}
    }
    // -->
    </SCRIPT>
    
    <SCRIPT language=JavaScript type=text/javascript>
    	<!--
    
    	var theCharacterTimeout = 50;
    	var theStoryTimeout     = 5000;
    	var theWidgetOne        = "_";
    	var theWidgetTwo        = "-";
    	var theWidgetNone       = "";
    	var theLeadString       = "LATEST:&nbsp;";
    
    	var theSummaries = new Array();
    	var theSiteLinks = new Array();
    
    	var theItemCount = 3;
    
    <?
    for($i=0;$i<5;$i++)
    {
    ?>
    theSummaries[<?=$i;?>] ="ahmed[<?=$i;?>]";
    theSiteLinks[<?=$i;?>] ="http://www.ahmedwali.com";
    <?
    }
    ?>
    	startTicker();
    	
    	//-->
    	</SCRIPT>
    </BODY></HTML>






    __________________
    سبحان الله وبحمده
    سبحان الله العظيم

    "جديد" أكبر مركز تحميل عربي
    WwW.U111U.CoM
    دليل المواقع المرئية الأول عربيا
    9mbc.com
    هل صليت على النبي !!
    اقرب للحقيقه ستهرب من العراق مثل الجرذان

  6. #6
    عضو نشيط
    تاريخ التسجيل
    Nov 2005
    المشاركات
    73


    :con2: ... معليش يالغالي ..

    كنت ناسي علامة التنصيص .. وطلعت فيها مشكلة ..

    لكن جرب هذا الكود وان شاء الله يضبط معك ..

    كود PHP:
    <?
    include ("admin/config.php");  
    $n=mysql_query("select * from news");  
    while (
    $s=mysql_fetch_array($n)) {  
    $id=$s['id'];  
    $sub=$s['sub']; /// لنفترض أن قيمة هذا المتغير هي عنوان الخبر .. 
    $wr=$s['wr'];  
    $txt=$s['txt'];  
    $txt1=$s['txt1'];  

    echo 

    أخر الأخبار&nbsp; 
    <SPAN id=theTicker></SPAN> 
    <SCRIPT language=javascript type=text/javascript> 
    var theSummaries = new Array("
    .$sub."); // تم إضافة عنوان الخبر هنا .. 
    var theSiteLinks = new Array('http://www.site.com/news.php?id="
    .$id."');</SCRIPT>"// وهنا تم إضافة رابط الخبر .. 
    echo "<SCRIPT src="java.js" type=text/javascript></SCRIPT>"

    echo 
    $sub;  

    }  
    ?>

    أتمنى لك التوفيق ..

    واعذرني على التأخر في الرد ... لأني انشغلت اليومين هذي ... الله يوفقك ..










ضوابط المشاركة

  • لا تستطيع إضافة مواضيع جديدة
  • لا تستطيع الرد على المواضيع
  • لا تستطيع إرفاق ملفات
  • لا تستطيع تعديل مشاركاتك
  •  

أضف موقعك هنا| اخبار السيارات | حراج | شقق للايجار في الكويت | بيوت للبيع في الكويت | دليل الكويت العقاري | مقروء | شركة كشف تسربات المياه | شركة عزل اسطح بالرياض | عزل فوم بالرياض| عزل اسطح بالرياض | كشف تسربات المياة بالرياض | شركة عزل اسطح بالرياض