Jump to content

marque with multiple database in 1 line


pclp19

Recommended Posts

help me please, my code is :

 

$table = tov;
$hal = $_GET[hal];
if(!isset($_GET['hal'])){
$page = 1;
} else {
$page = $_GET['hal'];
}
$max_results = 2;

$from = (($page * $max_results) - $max_results);
$sql = mysql_query("SELECT * FROM $table ORDER BY id_berita DESC LIMIT $from, $max_results");
while($hs_show = mysql_fetch_array($sql)){
$urut++;
?>
<marquee scrollamount="4" align="left" behavior="scroll" direction="left" class="text" onmouseover="this.stop()" onmouseout="this.start()">
<?php echo "$hs_show[judul]"; ?>
</marquee>
<?php
}
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM $table"),0);
$total_pages = ceil($total_results / $max_results);

 

 

i want the results to be in 1 line and one after the other ,thanks   ;D   ;D

Link to comment
https://forums.phpfreaks.com/topic/289809-marque-with-multiple-database-in-1-line/
Share on other sites

Take the marquee out of the loop

while($hs_show = mysql_fetch_array($sql)) {
    $urut++;
    $marqueeText .= $hs_show['judul'];  // build single text string
}

then

<marquee scrollamount="4" align="left" behavior="scroll" direction="left" class="text" onmouseover="this.stop()" onmouseout="this.start()">
<?php echo $marqueeText; ?>
</marquee>

When I use code from Barand suggestion, I try like this :

 

$table = tov;
$hal = $_GET[hal];
if(!isset($_GET['hal'])){ 
    $page = 1; 
} else { 
    $page = $_GET['hal']; 
}
$max_results = 2;
 
$from = (($page * $max_results) - $max_results); 
$sql = mysql_query("SELECT * FROM $table ORDER BY id_berita DESC LIMIT $from, $max_results"); 
while($hs_show = mysql_fetch_array($sql)) {
    $urut++;
    $marqueeText = $hs_show['judul'];  // build single text string
?>
<marquee scrollamount="4" align="left" behavior="scroll" direction="left" class="text" onmouseover="this.stop()"    onmouseout="this.start()">
<?php echo $marqueeText; ?>
</marquee>
<?php
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM $table"),0);
$total_pages = ceil($total_results / $max_results);
 
 
And this code still showing/appear 2 lines simultaneously, does not appear by turns. 

Maybe you need to do some learning and then try some coding?

 

This code:

while ($hs_show = mysql_fetch_array($sql))
{
    $urut++;
    $marqueeText = $hs_show['judul'];  // build single text string
?>
    <marquee scrollamount="4" align="left" behavior="scroll" direction="left" class="text" onmouseover="this.stop()"    onmouseout="this.start()">
    <?php echo $marqueeText; ?>
    </marquee>
<?php
} 

is very silly.  You are looping thru your result records and creating a 'marquee' tag for every record.  Is that what you want?  As was said before - REMOVE THE MARQUEE TAG from the loop.  Create just your text and then use that combined text in a var in your single marguee tag later.

 

Also - stop using the MySQL_* functions.  IF you bothered to read the manual you would see why.

 

Here is a better method:

 

$marqueeText = '';
while($hs_show = mysql_fetch_array($sql))
{
    $urut++;
    $marqueeText .= $hs_show['judul'];  // build single text string
} 

echo '<marquee scrollamount="4" align="left" behavior="scroll" direction="left" class="text" onmouseover="this.stop()"    onmouseout="this.start()">', $marqueeText, '</marquee>';

Many thank you for Barand and ginerjm, troubles are finished. if I want to ask something else please help again.

 

Final code :

 

$sql = mysql_query("SELECT * FROM tov"); 
while($hs_show = mysql_fetch_array($sql))
{
    $urut++;
    $marqueeText .= $hs_show['judul'];  // build single text string
 
echo '<marquee scrollamount="4" align="left" behavior="scroll" direction="left" class="text" onmouseover="this.stop()" onmouseout="this.start()">', $marqueeText, '</marquee>';
?>
 
case close  :happy-04:

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.