Jump to content

Recommended Posts

Hi.

I'm very new to php. Got script for scrolling text (not java) but using txt file to store data. I want to use mysql to store the data. Anybody can help?

Original code files:

1. colors.txt

[code]background-color="#887788"
font-color="#ffffff"
font-size="13px"
scrollamount="1"
scrolldelay="40"
width="150"
height="150"[/code]

2. news.txt

[code]HNEWS="This is a news ticker"
HLINK="http://www.a.com"

HNEWS="free scripts and tutorial"
HLINK="http://www.b.com"

HNEWS="free web hosting "
HLINK="http://www.c.com"

HNEWS="online calculator and binary / hex / ascii convertors"
HLINK="http://www.d.com"[/code]

3. hnt.php

[code]<?php
$file1 = "./HNT/colors.txt";
$lines1 = file($file1);
//$count = count($lines1)

foreach ($lines1 as $line_num1 => $line1)
{
$spos = strpos($line1,'ackground-color="');

if($spos != null && $spos > 0)
{
$spos2 = strpos($line1,'"',($spos+18));
//echo(".....".$spos."------".$spos2);

$str = substr($line1,18,($spos2-($spos+17)));
$bgcol = $str;
//echo($bgcol);
}

$spos1 = strpos($line1,"ont-color=");
if($spos1 != null && $spos1 > 0)
{
$spos2 = strpos($line1,'"',($spos1+12));
//echo(".....".$spos."------".$spos2);

$str = substr($line1,12,($spos2-($spos1+11)));
$fontcol = $str;
$linkcol = $fontcol;
//echo("||".$fontcol);
}

$spos1 = strpos($line1,"ink-color=");
if($spos1 != null && $spos1 > 0)
{
$str = substr($line1,12,(strlen($line1)-15));
$linkcol = $str;
echo("||".$linkcol);
}


$spos = strpos($line1,"crollamount=");
if($spos != null && $spos > 0)
{
$spos2 = strpos($line1,'"',($spos+14));
//echo(".....".$spos."------".$spos2);

$str = substr($line1,14,($spos2-($spos+13)));
$scamount = $str;
//echo("||".$scamount);
}

$spos = strpos($line1,"crolldelay=");
if($spos != null && $spos > 0)
{
$spos2 = strpos($line1,'"',($spos+13));
//echo(".....".$spos."------".$spos2);

$str = substr($line1,13,($spos2 - ($spos+12)));
$scdelay = $str;
//echo("||".$scdelay);
}

$spos = strpos($line1,"idth=");
if($spos != null && $spos > 0)
{
$spos2 = strpos($line1,'"',($spos+7));
//echo(".....".$spos."------".$spos2);

$str = substr($line1,7,($spos2-($spos+6)));
$width = $str;
//echo("||".$width);
}

$spos = strpos($line1,"eight=");
if($spos != null && $spos > 0)
{
$spos2 = strpos($line1,'"',($spos+8));
//echo(".....".$spos."------".$spos2);

$str = substr($line1,8,($spos2-($spos+7)));
$height = $str;
//echo("||".$height);
}

$spos = strpos($line1,"ont-size=");
if($spos != null && $spos > 0)
{
$spos2 = strpos($line1,'"',($spos+11));
//echo(".....".$spos."------".$spos2);

$str = substr($line1,11,($spos2-($spos+10)));
$fsize = $str;
//echo("||".$fsize);
}

}

?>

<table width=<?php echo($width); ?> height=<?php echo($height); ?> >
<tr><td>
<marquee height=<?php echo($height); ?> width=<?php echo($width); ?> bgcolor=<?php echo($bgcol); ?>
scrollamount=<?php echo($scamount); ?> scrolldelay=<?php echo($scdelay); ?> direction=up
onmouseover="this.stop()" onmouseout="this.start()">
<br>
<?php

$file1 = "./HNT/news.txt";

$lines = file($file1);
$count = count($lines);

$newsf = false;
$linkf = true;

foreach ($lines as $line_num => $line)
{
if($newsf == false && $linkf == true)
{
$spos = strpos($line,"NEWS=");
if($spos != null && $spos > 0)
{
            $spos2 = strpos($line,'"',($spos+7));

            $newsstr = substr($line,7,($spos2-($spos+6)));
//echo("<div align=left style=\"color: ".$fontcol.";\" >".$newsstr."</div>");
$newsf = true;
}
}
else if( $linkf == true &&  $newsf == true)
{
$spos = strpos($line,"LINK=");
if($spos != null && $spos > 0)
{
$spos2 = strpos($line,'"',($spos+7));

            $linkstr = substr($line,7,($spos2-($spos+6)));

//echo("<div align=left><a href=".$linkstr." style=\"color: ".$linkcol."; \">".$linkstr."</a></div><br><br>");
echo("<div align=left style=\"margin: 10px;\"><a href=".$linkstr." style=\"color: ".$linkcol."; font-size: ".$fsize."; text-decoration: none;
font-weight: bold;\">".$newsstr."</a></div><br>");
      $newsf = false;
            $linkf = true;
}
else
{
  $linkf = false;
echo("<div style=\"color: red; font-weight: bold;\"> Improper Usage of NEWS TICKER </div>");
}
}
}
?>
<br>
</marquee>
<div align=center style="background-color: <?php echo($bgcol); ?>; color: white; font-size: 10px;">
tool by <a href=http://www.script.com style="color: white; font-decoration: none;">script.com</a>
</td></tr>
</table[/code]
Link to comment
https://forums.phpfreaks.com/topic/25781-scrolling-text-in-phpmysql/
Share on other sites

  • 2 weeks later...
[quote author=Twysted link=topic=113436.msg468788#msg468788 date=1163653223]
i will do it for ya, for $15
[/quote]

Deal.

Please convert both TXT files to table. My idea:

1. I want to place it on my website frontpage: http://www.replica2u.com for latest news
2. I also want to place this news at http://www.replica2u.com/store/news.php for new and old news
3. In admin CP, I can select (using checkbox) which news I want to display in frontpage, edit and delete news

Thanks.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.