Solved

Creating vertical scrolling text from data in MySQL database

Posted on 2009-07-05
3
4,271 Views
Last Modified: 2013-12-13
I have managed to get some code to create some vertical scrolling data from my mysql database. I want the ticker to scroll vertically and show jobs that have been posted by users. The code needs changing as I cant seem to return more than one field from the database table i.e. job text and user ID and Category for example.

I'm pretty sure its the php section grabbing the query results that needs altering but I am quite new to php.

Please help.
<style type="text/css">
#divNewsCont{position:relative; width:300; height:302; overflow:visible; top:15; visibility:hidden}
#divNewsText{position:absolute; top:0; left:0}
    h1
	{margin-bottom:.0001pt;
	page-break-after:avoid;
	font-size:14.0pt;
	font-family:"Times New Roman";
	font-weight:normal; margin-left:0in; margin-right:0in; margin-top:0in}
</style>
 
 
<script type="text/javascript" language="JavaScript">
 
function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}
bw=new checkBrowser()
 
//The pixel value of where you want the layer to start (from the top)
lstart=0
 
//Set this to false if you just want it to go one time
loop=true 
 
//Set the speed, lower value gives more speed
speed=150
 
//Set this to how many pixels you want it to go for each step, this also changes the speed.    
pr_step=1
 
//Object constructor
function makeObj(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
	this.newsScroll=newsScroll;
	this.moveIt=b_moveIt; this.x; this.y;
    this.obj = obj + "Object"
    eval(this.obj + "=this")
    return this
}
function b_moveIt(x,y){
	this.x=x;this.y=y
	this.css.left=this.x
	this.css.top=this.y
}
//Makes the object scroll up
function newsScroll(speed){
	if(this.y>-this.scrollHeight){
		this.moveIt(0,this.y-pr_step)
		setTimeout(this.obj+".newsScroll("+speed+")",speed)
	}else if(loop) {
		this.moveIt(0,lstart)
		eval(this.obj+".newsScroll("+speed+")")
	  }
}
//Makes the object
function newsScrollInit(){
	oNewsCont=new makeObj('divNewsCont')
	oNewsScroll=new makeObj('divNewsText','divNewsCont')
	oNewsScroll.moveIt(0,lstart)
	oNewsCont.css.visibility='visible'
	oNewsScroll.newsScroll(speed)
}
//Call the init on page load
onload=newsScrollInit;
    </script>   
    <base target="_top">
 
 
 
<BODY style="word-spacing: 0; margin: 0">
 
 
 
 
<body text="#FFFFFF" link="#FFFF00" vlink="#FFFF00" alink="#FFFF00" style="word-spacing: 0; margin: 0">
<table cellpadding=0  cellspacing=0 id="table1" style="position:relative;top:0px;width:300px;table-layout:fixed" name="table1">
  <tr>
    <td valign="top" align="left" style="color: #000000; text-decoration: none" >
                  
                  
<div id="divNewsCont" style="float: left">
<div id="divNewsText" style="width: 300; height: 302">
	<table border="0" cellpadding="2" cellspacing="0" id="table2">
		<tr>
			<td>
			
  <font face="Arial" style="font-size: 7pt" color="#000000">
  
 
 
	<p style="margin-top: 0; margin-bottom: 0">
  
 
 
<?php
$db_server = "localhost";
$db_user   = "jez";
$db_pass   = "frank5";
 
 
$con       = mysql_connect("$db_server", "$db_user", "$db_pass") or die("Cannot connect to database.<br>");
mysql_select_db("local_traders");
 
 
$query = "
(
	SELECT * FROM job
)
 
ORDER BY id DESC
LIMIT 25";
 
 
  $result = mysql_query($query) or die("Could not perform the requested query!<BR>".mysql_error());
  while ($row = mysql_fetch_array($result))
  {
  		$array[] = $row['jobtext'];
  }mysql_free_result($result);
 
	$result = array_unique ($array);
 
 
echo "<table>";
	foreach ($result as $i => $value) {
		
		echo "<font color=#57616D>$value</font><br><br>";
	}
echo "</table>";
 
 
 
?>
 
 
			
			
			
			
			</td>
		</tr>
	</table>
	
	</div></div>
</table> 
 
 
</body>

Open in new window

0
Comment
Question by:jezskill
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Author Comment

by:jezskill
ID: 24779671
I have changed the PHP code to include another table field which is showing in the output, but what I would like is to display category in bold with the jobs detailed underneath.

revised code as follows

<?php
$db_server = "localhost";
$db_user   = "jez";
$db_pass   = "frank5";


$con       = mysql_connect("$db_server", "$db_user", "$db_pass") or die("Cannot connect to database.<br>");
mysql_select_db("local_traders");


$query = "
(
      SELECT * FROM job
)

ORDER BY category DESC
LIMIT 25";


  $result = mysql_query($query) or die("Could not perform the requested query!<BR>".mysql_error());
  while ($row = mysql_fetch_array($result))
  {
              $array[] = $row['category'];
            $array[] = $row['jobtext'];
            
  }mysql_free_result($result);

      $result = array_unique ($array);


echo "<table>";
      foreach ($result as $i => $value) {
            
            echo "<font color=#57616D>$value</font><br>";
      }
echo "</table>";



?>

manh thanks in advance of any help
0
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 500 total points
ID: 24779693
Try this:


            $array[] = '<b>'.$row['category'].'</b><br>'.$row['jobtext'];

Open in new window

0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question