webForumDet fria alternativet

Koppla till databas

1 svar · 295 visningar · startad av noll5

noll5Medlem sedan jan. 200611 inlägg
#1

Har just kommit över ett script som "maskinskriver" ut text. Det jag skulle vilja göra är att detta script skriver ut de senaste ingresserna ur matchrefferat på en hemsida, och läser från en databas som heter matchref.

Vore tacksam om jag kunde få hjälp med detta. Kanske finns det t.o.m. ett enklare sätt än det jag tänkt mig...

<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
<link type="text/css" rel="stylesheet" href="/nol/shared/css/news.css" />

</head>

<body>
<div class="ticki"><a id="tickerAnchor" href="#" target="_top" class="tickl"></a></div>

<script language="JavaScript">
<!--

function SymError()
{
  return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
  return (new Object());
}

window.open = SymWinOpen;

//-->
</script>

<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 = 4;

	
		theSummaries[0] = "Russian prosecutors open 'coup attempt' case against tycoon Berezovsky.";
		theSiteLinks[0] = "/2/hi/europe/4765598.stm";
	
		theSummaries[1] = "Attempt to form new Iraqi cabinet in disarray amid campaign against PM Jaafari. ";
		theSiteLinks[1] = "/2/hi/in_depth/4765456.stm";
	
		theSummaries[2] = "Suspected police raid on offices of Standard newspaper group in Kenya. ";
		theSiteLinks[2] = "/2/hi/africa/4765250.stm";
	
		theSummaries[3] = "President Bush confirms death of a US citizen in Karachi bombing.";
		theSiteLinks[3] = "/2/hi/south_asia/4765170.stm";
	

	startTicker();
	
	//-->
	</script>

</body>
</html>
<script language="JavaScript">
<!--
var SymRealOnLoad;
var SymRealOnUnload;

function SymOnUnload()
{
  window.open = SymWinOpen;
  if(SymRealOnUnload != null)
     SymRealOnUnload();
}

function SymOnLoad()
{
  if(SymRealOnLoad != null)
     SymRealOnLoad();
  window.open = SymRealWinOpen;
  SymRealOnUnload = window.onunload;
  window.onunload = SymOnUnload;
}

SymRealOnLoad = window.onload;
window.onload = SymOnLoad;

//-->
</script>
hopparnMedlem sedan nov. 20011 043 inlägg
#2

nu är jag ingen javascriptkung, men kan du inte ersätta detta:

theSummaries[0] = "Russian prosecutors open 'coup attempt' case against tycoon Berezovsky.";
theSiteLinks[0] = "/2/hi/europe/4765598.stm";

med

theSummaries[0] = <%=RS("ingressnummerett")%>;
theSiteLinks[0] = <%=RS("ingressLänkennummerett")%>;

RED: Sorry, såg inte att det var phpforumet, då vet jag inte riktigt hur du skriver ut rader från db, men stället och principen e nog densamma tror jag...

Genererad på 366 ms · cache AV · v20260730165559-full.f96bc7eb