Jump to content

including marquee


killay
 Share

Recommended Posts

Hi,Recently a friend made a script to update little marquee messages trhough login.Now he is on stage for 2 to 3 months and hasn't a lot of time. So I couldn't ask him to help me out :)Now for me it's kinda difficult to customize php. I tried but didn't work out.So here is the login page:

<?php include_once("header.php"); $conn=new connection();$conn->qselectDb("SELECT * FROM message");if($conn->fetchRs())	$marquee=$conn->rs['text_message'];	$msg="Please input your username and/or password."; $username=""; $password="";//echo md5('123456');if(isset($_POST['submit'])){		$username=trim($_POST['username']);	$password=trim($_POST['password']);		if(strlen($username)>0 && strlen($password)>0){					$msg="Invalid username and/or password."; 				$sql="SELECT * FROM users WHERE username='$username' AND password='".md5($password)."'";		$conn=new connection();		$conn->qselectDb($sql);		if($conn->fetchRs()){			$username=""; $password="";			@session_start();			$_SESSION['SESSION_ID']=md5(date('YMDHis'));			$_SESSION['SESSION_USER_ID']=$conn->rs['id'];			$_SESSION['SESSION_USER_NAME']=ucwords(stripslashes($conn->rs['name']));			ob_start();			header("Location: requestlist.php");		}			}	}?><h3>Member's Login</h3><h5><font color="red"><? echo $msg;?></font></h5><? if(isset($marquee)){ ?>	<marquee><?=$marquee;?></marquee><? } ?><p><form method="post"><table>	<tr>		<th>Username</th>		<th><input type="text" name="username" value="<?=$username;?>" /></th>	</tr>	<tr class="row_to_clone">		  <td>Password</td>		  <td><input type="password" name="password" value="<?=$password;?>" /></td>	</tr></table><div><input type="submit" name="submit" value="Login" /></div><br><br><div>Non-Member? <a href="request.php">Request A Song</a></div></form></p><?php include_once("footer.php"); ?>

and here is the message update:

<?php include_once("header.php"); $message=""; $msg="";include_once("djheader.php"); $conn=new connection();if(isset($_POST['submit'])){		$message=trim($_POST['message']);		$conn->qexecuteDb("UPDATE message SET text_message='$message'");				$msg="Your message has been successfully updated!";}$conn->qselectDb("SELECT * FROM message");if($conn->fetchRs())	$message=$conn->rs['text_message'];	?><h3>Update Message</h3><h5><font color="red"><?=$msg;?></font></h5><p><form method="post"><table>	<tr>		<th>Message</th>	</tr>	<tr class="row_to_clone">		  <td><textarea name="message" style="width:250px;height:100px;" /><?=$message;?></textarea></td>	</tr></table><div><input type="submit" name="submit" value="Save" /></div></form></p><?php include_once("footer.php"); ?>

Now I tried to take out the :<? if(isset($marquee)){ ?> <marquee><?=$marquee;?></marquee><? } ?>from the login page to include onto another page.But apparently it didn't work.Could someone help me on this?

Link to comment
Share on other sites

I dont really understand what you mean...But the marquee itself works in IE and FF, just what i needed. But i need to set the marquee somewhere else (on another page).And thats what I want to know how you do that.
Copy the code that sets $marquee ($conn=new connection();$conn->qselectDb("SELECT * FROM message");if($conn->fetchRs()) $marquee=$conn->rs['text_message'];) and put it into the page where you are putting the $marquee.
Link to comment
Share on other sites

Ok I tried to implement it... but no use.this is what I've set.

<div id=\"marquee\">			<?php			$marquee (				$conn=new connection();				$conn->qselectDb(\"SELECT * FROM message\");				if($conn->fetchRs())				  $marquee=$conn->rs['text_message'];			  )			  <? if(isset($marquee)){ ?>				<marquee><?=$marquee;?></marquee>			<? } ?>			  ?>	</div>

I also added "<?" (without quotes) in the beginning of the page and "?>" at the end.I saved it as .php .But it ain't comming up. I've set the page in the same directory thought.

Link to comment
Share on other sites

Ok I tried to implement it... but no use.this is what I've set.
<div id=\"marquee\">			<?php			$marquee (				$conn=new connection();				$conn->qselectDb(\"SELECT * FROM message\");				if($conn->fetchRs())				  $marquee=$conn->rs['text_message'];			  )			  <? if(isset($marquee)){ ?>				<marquee><?=$marquee;?></marquee>			<? } ?>			  ?>	</div>

I also added "<?" (without quotes) in the beginning of the page and "?>" at the end.I saved it as .php .But it ain't comming up. I've set the page in the same directory thought.

OK, I didn't mean that literally...I was putting the code within parenthesis.I'll rephrase that:Copy the code which sets the $marquee variable:
$conn=new connection();$conn->qselectDb("SELECT * FROM message");if($conn->fetchRs())$marquee=$conn->rs['text_message'];

And paste it onto the page where you're going to place the marquee.Don't forget to add

<? if(isset($marquee)){ ?><marquee><?=$marquee;?></marquee><? } ?>

Link to comment
Share on other sites

Well isn't that what I just did?

head blablabla.....</head><body bgcolor=\"#ffffff\"><div id=\"radior1c1\"><img name=\"radio_r1_c1\" src=\"images/radio_r1_c1.jpg\" width=\"800\" height=\"125\" border=\"0\">	<div id=\"marquee\">			<?php			$marquee (				$conn=new connection();				$conn->qselectDb(\"SELECT * FROM message\");				if($conn->fetchRs())				  $marquee=$conn->rs['text_message'];			  )			  <? if(isset($marquee)){ ?>				<marquee><?=$marquee;?></marquee>			<? } ?>			  ?>	</div></div><div id=\"radior2c1\"><img name=\"radio_r2_c1\" src=\"images/radio_r2_c1.jpg\" width=\"630\" height=\"65\" border=\"0\"></div><div id=\"radior2c4\"><img name=\"radio_r2_c4\" src=\"images/radio_r2_c4.jpg\" width=\"170\" height=\"65\" border=\"0\"></div><div id=\"radior3c1\"><img name=\"radio_r3_c1\" src=\"images/radio_r3_c1.jpg\" width=\"56\" height=\"280\" border=\"0\"></div><div id=\"radior3c2\"><img name=\"radio_r3_c2\" src=\"images/radio_r3_c2.jpg\" width=\"525\" height=\"280\" border=\"0\"></div><div id=\"radior3c3\"><img name=\"radio_r3_c3\" src=\"images/radio_r3_c3.jpg\" width=\"49\" height=\"280\" border=\"0\"></div><div id=\"radior3c4\"><img name=\"radio_r3_c4\" src=\"images/radio_r3_c4.jpg\" width=\"170\" height=\"88\" border=\"0\"></div><div id=\"radior4c4\"><img name=\"radio_r4_c4\" src=\"images/radio_r4_c4.jpg\" width=\"170\" height=\"80\" border=\"0\"></div><div id=\"radior5c4\"><img name=\"radio_r5_c4\" src=\"images/radio_r5_c4.jpg\" width=\"170\" height=\"63\" border=\"0\"></div><div id=\"radior6c4\"><img name=\"radio_r6_c4\" src=\"images/radio_r6_c4.jpg\" width=\"170\" height=\"49\" border=\"0\"></div><div id=\"radior7c1\"><img name=\"radio_r7_c1\" src=\"images/radio_r7_c1.jpg\" width=\"800\" height=\"70\" border=\"0\"></div></body></html>?>

So I pasted

$conn=new connection();$conn->qselectDb("SELECT * FROM message");if($conn->fetchRs())$marquee=$conn->rs['text_message'];

onto this page. Oke I just need to delete $marquee ( in th ebeginning.and I also didn't forget to add

<? if(isset($marquee)){ ?><marquee><?=$marquee;?></marquee><? } ?>

So I dont really understand why you keep telling me to add it, and not to take it literally.Or can you just change the code I provided, to see what you mean

Link to comment
Share on other sites

Your problem is that you copied literally what I wrote.This is wrong:$marquee ($conn=new connection();$conn->qselectDb("SELECT * FROM message");if($conn->fetchRs())$marquee=$conn->rs['text_message'];)I only mentioned writing this:$conn=new connection();$conn->qselectDb("SELECT * FROM message");if($conn->fetchRs())$marquee=$conn->rs['text_message'];

Link to comment
Share on other sites

Take out the div. Replace this:

	<div id=\"marquee\">			<?php			$marquee (				$conn=new connection();				$conn->qselectDb(\"SELECT * FROM message\");				if($conn->fetchRs())				  $marquee=$conn->rs['text_message'];			  )			  <? if(isset($marquee)){ ?>				<marquee><?=$marquee;?></marquee>			<? } ?>			  ?>	</div>

With this:

	<div id="marquee">			<?php			  $conn=new connection();			  $conn->qselectDb("SELECT * FROM message");			  if($conn->fetchRs())				  echo $conn->rs['text_message'];			  ?>	</div>

Link to comment
Share on other sites

Strange,I I tried it, but then I get a white page. Nothing is showing up.But I do have to save my html page as a php then, no?and where do I need to input this:

<? if(isset($marquee)){ ?><marquee><?=$marquee;?></marquee><? } ?>

Lol haven't thought it was so difficult :)

Link to comment
Share on other sites

Yes, you need to save it as .php. You don't need the second part. If you want to display the same marquee on several places then you would do something else, but I assume the marquee only shows up once. But you do need to add the marquee tag, I forgot that. The div should have the marquee inside it:<div id="marquee"><marquee><?php...?></marquee></div>

Link to comment
Share on other sites

well I first thought that it could be cause the div was maybe underneath another one.But then I tweeked a bit to test out:

	<div id=\"marquee\">		<marquee>		echo ('HELLO');			<?php			  echo ('HELLOO');			  $conn=new connection();			  $conn->qselectDb(\"SELECT * FROM message\");			  if($conn->fetchRs())			  echo $conn->rs['text_message'];			?>		</marquee>	</div>

and offcourse it prints out "echo ('HELLO');" so the marquee works (I know it waas dumb of me to set echo in front if the page is also going to print it out :)but the other echo with two "OO" doesnt work.So there is something wrong with the php.

Link to comment
Share on other sites

But what I actually dont get is... how does this php code connects to the mysql? How does he know which mysql to connect to?I dont see anywhere the name of the sql file.Look check the page.I have done everything you told me. But most of the images vanishes.

http://www.cgedits.com/bwradio/radio_test.rar

Link to comment
Share on other sites

The connection class probably defines all of that. There isn't a built-in class in PHP called connection, so that's probably a user-defined class. Both the files include a file called header.php before they create a new connection, so you may need to check inside header.php and look for what you need. If you want to post the code here that's fine. If the header.php file contains a lot of HTML code you'll want to take out only what you need, but if it only defines variables and classes and things or includes other files it's probably safe if you just include the same file in your pages. I don't think the header.php file would include any output HTML because headers get sent after the file gets included and you can't send a header if you've already sent output. But you will need to include the definition for the connection class for that code to work, if you want to post the code for header.php here go ahead and do that.

Link to comment
Share on other sites

Ok so as you know that message works :)But... hehe... now there should be an autorefresh for the marquee itself.Is there a possibility to just refresh the message itself, instead of the whole page?Or what I was thinking was setting the header/banner into another phppage and refreshing that page, but just including it into my index...I dont know if its a good idea. But if it would be possible to just refresh the message , your reply is welcome :)

Link to comment
Share on other sites

If you want to change the message that the marquee shows you'll want to use either AJAX or straight Javascript. If you just use Javascript without AJAX then you will need to write out all the different messages into a Javascript array and set an interval of X seconds for Javascript to go to the next message. If you want to use AJAX it's similar, but instead of writing everything into an array every X seconds Javascript would get the next message from a PHP script and display it. Here's an example of the first way:

<marquee id="message"></marquee><script type="text/javascript">var messages = [  "This is message 1",  "This is message 2",  "This is message 3"];var current_message = 0;function change_message(){  document.getElementById("message").innerHTML = messages[current_message++];  if (current_message == messages.length)	current_message = 0;  setTimeout('change_message()', 10000);  //change in 10 seconds}change_message();</script>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...