php db_coonect mysql_connect localhost root or die mysql_error mysql_s

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
$db_coonect = mysql_connect('localhost', 'root', '') or die(mysql_error());
mysql_select_db('ilt', $db_coonect) or die(mysql_error());
mysql_query("SET NAMES 'utf8'");
$res = mysql_query(" SELECT * FROM `item_lessons_table` ",$db_coonect);
$num_rows = mysql_num_rows($res);
$c = 0;
while($c < 8){
$row = mysql_fetch_assoc($res);
$less_id[$c] = $row['id'];
$less_item[$c] = $row['item'];
$less_cab[$c] = $row['cab'];
$c++;
}
function less_full_info($less_id, $less_item, $less_cab){
return "$less_id $less_item $less_cab";
}
$global_array = array_map("less_full_info", $less_id, $less_item, $less_cab);
$rmin = rand(1, 14);
$rmax = $rmin + 6;
$rand_array = array_slice($global_array, $rmin, $rmax);
$rand_array = implode(" ", $rand_array);
?>
<?php for($v = 0; $v < 2; $v++){
echo '<div class="one_class">';
for($i = 0; $i < 1; $i++){
echo '<div class="id-item">'.$rand_array.'</div>';
}
echo '</div>';
}
?>