Dear professionals.

How to change (add) the code to get the output from the database on the html page:

  1. Rated
  2. Random output

-

F3::route('GET /', function () { F3::set('html_title','Название'); include $_SERVER['DOCUMENT_ROOT'].'/perecc/rating/rating.php'; //$article=mysql_query('SELECT * FROM article ORDER by id DESC limit 5'); $rep_page=100; $num_pages=ceil(paginator()/$rep_page); for($i=1;$i<=$num_pages;$i++){ $pages[$i][0]=$i; } F3::set('paginator',$pages); $query="SELECT * FROM article ORDER by id DESC limit $rep_page"; $article=mysql_query($query) or die ("Error"); $query2="SELECT content FROM article"; $randmas=mysql_query($query2); for ($randmasdata=array();$row=mysql_fetch_assoc($randmas);$randmasdata[]=$row); for ($data=array();$row=mysql_fetch_assoc($article);$data[]=$row); $rnd=rand(1, count($randmasdata)-1); $random[0]=$randmasdata[$rnd]; F3::set('content','blog_home.html'); for ($i=0;$i<count($data);$i++) { $data[$i]['rat']=callrating($data[$i]['id'], "thumb", '&nbsp;'); } F3::set('random',$random); F3::set('list',$data); echo Template::serve('layout.html'); } ); 

Moved from comment.

Maybe something like that?

 <?php @mysql_connect("localhost", "root", ""); mysql_select_db("kakaeto_bd"); @mysql_query("SET NAMES 'utf8'"); $col = 1; // Сколько всего выводить записей $sql = "SELECT * FROM anekdots ORDER BY RAND() LIMIT " . $col; $res = mysql_query($sql); for ($i = 0; $i < $col; $i++) { $row = mysql_fetch_array($res); $text = $row['text']; $author = $row['author']; echo $text . " [ Автор:<b>" . $author . "</b> ]"; } ?> 
  • I have only one sentence: throw out this code and write normally. ZY F3 I do not know, so I will not answer in more detail .. But the code is disgusting - Photon
  • Help make on php. I will be grateful who will help you to do it right ... My contacts: vesbiznes@mail.ru - Greg888
  • Moved to the question. - Greg888


0