pclp19 Posted July 13, 2014 Share Posted July 13, 2014 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 Quote Link to comment Share on other sites More sharing options...
Barand Posted July 13, 2014 Share Posted July 13, 2014 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> Quote Link to comment Share on other sites More sharing options...
pclp19 Posted July 18, 2014 Author Share Posted July 18, 2014 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. Quote Link to comment Share on other sites More sharing options...
Barand Posted July 18, 2014 Share Posted July 18, 2014 Now try it as I suggested, concatenating the values then outputting the marquee after the while loop Quote Link to comment Share on other sites More sharing options...
pclp19 Posted July 23, 2014 Author Share Posted July 23, 2014 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 Quote Link to comment Share on other sites More sharing options...
ginerjm Posted July 23, 2014 Share Posted July 23, 2014 (edited) 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 July 23, 2014 by ginerjm Quote Link to comment Share on other sites More sharing options...
Barand Posted July 23, 2014 Share Posted July 23, 2014 If we tell him enough times it might sink in Quote Link to comment Share on other sites More sharing options...
pclp19 Posted July 25, 2014 Author Share Posted July 25, 2014 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.