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
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>
Link to comment
Share on other sites

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. 
Link to comment
Share on other sites

sorry I am very confused with this code, when I try $max_results = 2; put after $marqueeText = $hs_show['judul'];, first data appear and showing in 1 line but the problem is next data is unreadable. Can you give a direct code. Thank's

Link to comment
Share on other sites

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>';
Edited by ginerjm
Link to comment
Share on other sites

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:
Link to comment
Share on other sites

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.