Hi friends, I have a excel file with about 200 rows. I need to display data from each row one by one (one row's data at a time). Suppose, one row's data will display and stay 3 seconds and then next row's data will display in the same place (previous data will disappear). The full process will loop continuously. excel file: here is the display example of one row: You can use PHP/jQuery/AJAX/JavaScript etc to do this. You can use fading style or any other style for data transaction. Note: If it is hard form excel sheet, then I can convert it to mySQL. So you can pull data from excel or mysql, what ever better for you. (excel is preferable) Please help me doing this. I searched but did not find the solution anywhere. Thank you
Hi. one untested idea is to save all of those 200 rows to a CSV file. On 1st page load javascript will load this CSV into an array of object: data = { country: 'united states', infected: 1292879, death: 76942, recovered: 217251 } Code (JavaScript): and when loaded: start showing 1st row. start 3-seconds timer to show next row.
Try this Save your excel as CSV file. (data.csv) It will look something like this USA,111,11,100 India,333,33,300 <?php $c= file_get_contents( 'data.csv' ); $arr=array(); $d= explode("\n",$c); foreach($d as $v){ if(strlen($v)>2){ $v=str_replace('"', '', $v); $arr[]=explode(',',$v); } }//foreach ends $count=sizeof($arr); $arr= json_encode($arr); echo '<script type="text/javascript"> var obj= '.$arr.'; var max='.$count.'; </script>'; ?> <script type="text/javascript"> var r=0; function getNextRow(){ s=obj[r]; str=" "+s[0]+" | "+s[1]+" | "+s[2]+" | "+s[3]+" "; document.getElementById("cData").innerHTML = str; ++r; if(r>=max){ r=0; } } </script> <p id="cData"></p> <script type="text/javascript"> getNextRow(); setInterval( getNextRow, 3000 ); </script> Code (markup):
Hi @JEET Thank you very much. It works perfectly. You did great work. Is it possible to do from mysql table or excel sheet?
@KingCobra You can make the PHP array from MySQL instead of from CSV file. Only that part of code will change. About reading directly from excel, I'm not sure, never did that. There must be some class, some package which does, but its much easier to just convert the excel into csv and use php to parse it into an array.