AndrisP 193 Posting Pro in Training

Each "else if" is unclosed brackets. "for" is closed. "if" inside "for" is closed. But "else if" mis-matched

AndrisP 193 Posting Pro in Training

File "insert_pdo":

  1. Use filter_input http://php.net/manual/en/function.filter-input.php instead of $email = $_POST['email']; and $checkbox = $_POST['checkbox'];
  2. bindParam() and execute() is missing after the prepare statement http://php.net/manual/en/pdostatement.bindparam.php
AndrisP 193 Posting Pro in Training

"Map network drive" if you are windows user, or open network folder and then save bookmark if you are linux user.

AndrisP 193 Posting Pro in Training

You can create stored procedure eg

delimiter $$
drop procedure if exists `check_before_insert`$$
create procedure `check_before_insert`(
    in p_param_1 varchar(30)
    ,in p_param_2 varchar(30)
    ,in p_param_3 varchar(30)
) begin
declare v_exists boolean default false;
select t.`p_field_1` = p_param_1 into v_exists from `some_table` t where t.`p_field_2` =  p_param_2;
if v_exists = false then
    insert into `some_table`(
        `p_field_1`
        ,`p_field_2`
        ,`p_field_3`
    ) values (
        p_param_1
        ,p_param_2
        ,p_param_3
    );
    commit;
end if;
end; $$
delimiter ;

and then call procedure for insert if not exist

call `check_before_insert`('some_value_1','some_value_2','some_value_3');
AndrisP 193 Posting Pro in Training

Yes. FireFox is the best of android web browsers for DaniWeb IMHO.

AndrisP 193 Posting Pro in Training

It was not the only problem with Ubuntu phone OS. Yesterday I reinstall OS to Flyme Android.

AndrisP 193 Posting Pro in Training

You can define function

delimiter $$
create function not_max_of_division(
     p_product varchar(30)
    ,p_division varchar(30)
) returns boolean
begin
    declare v_max int;
    declare v_not_max boolean;
    select
        max(t.`sales`) into v_max
    from
        `sample` t
    where
        t.`Division` = p_division;
    select
        t.`sales` <> v_max into v_not_max
    from
        `sample` t
    where
        t.`product` = p_product;
    return v_not_max;
end $$
delimiter ;

and then

select t.* from `sample` t
where not_max_of_division(t.`product`, t.`Division`)
order by
     t.`Division` asc
    ,t.`sales` desc;

(do not need set sql_mode)

AndrisP 193 Posting Pro in Training

In to the subquery you can select max(sales) group by Division then select * from SAMPLE where product not in (subquery) eg

select
    t.*
from
    `sample` t
where
    t.`product` not in (
        select
            s.`product` from (
            select
                 m.`product`
                ,max(m.`sales`)
            from
                `sample` m
            group by m.`Division`
        ) s
    )
order by
     t.`Division` asc
    ,t.`sales` desc;

if your MySQL version is 5.7 then before this query set sql_mode

set sql_mode=(select replace(lower(@@sql_mode),'only_full_group_by',''));
k_manimuthu commented: Thanks for your solution +5
AndrisP 193 Posting Pro in Training

I try it many times but it does not change anything

AndrisP 193 Posting Pro in Training

Maybe can I disable mobile view on the DaniWeb?

AndrisP 193 Posting Pro in Training

Another web browser not available on the ubuntu
phone. I have Meizu pro 5 Ubuntu edition. All software is updated.

AndrisP 193 Posting Pro in Training

What has gone wrong with DaniWeb? It is no longer normal usable on the Ubuntu Phone.

AndrisP 193 Posting Pro in Training

You don't need use subqueries

select
     a.`p_ID`
    ,a.`p_fName`
    ,a.`p_mName`
    ,a.`p_lName`
    ,b.`a_ID`
    ,b.`a_street`
    ,b.`a_box`
    ,b.`a_city`
    ,c.`c_ID`
    ,c.`c_name`
    ,c.`c_city`
from `personTb` a
inner join `personAddress` b on b.`p_ID` = a.`p_ID`
inner join `personChurch` c on c.`p_ID` = a.`p_ID`
;

or

select
     concat_ws(' ', a.`p_fName`, a.`p_mName`, a.`p_lName`) as p_Name
    ,concat_ws(' ', b.`a_street`, b.`a_box`, b.`a_city`) as p_Address
    ,concat_ws(' ', c.`c_name`, c.`c_city`) as p_Church
from `personTb` a
inner join `personAddress` b on b.`p_ID` = a.`p_ID`
inner join `personChurch` c on c.`p_ID` = a.`p_ID`;

... and using MySQL keywords like "name" for column names or aliases is not good practice

AndrisP 193 Posting Pro in Training

if you declare variable outside a function (before declare function) then you can access and change it inside eg

var someVariable;
function someFunction(){
    someVariable = 5;
}

alert(someVariable); // undefined
someFunction();
alert(someVariable); // 5

but if you redeclare variable with same name inside a function then it's a local variable and you lost access to global variable inside a function

var someVariable;
function someFunction(){
    var someVariable = 5;
}

alert(someVariable); // undefined
someFunction();
alert(someVariable); // undefined
AndrisP 193 Posting Pro in Training

Thanks to everyone who tried to help. I found solution:

string="string_4.3.2"
if [[ $string =~ ^string_([0-9])\.([0-9])\.([0-9])$ ]]; then
    do_something "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[3]}"
fi
AndrisP 193 Posting Pro in Training

How i can sed save pattern matches to variables and do something with it? eg

$ echo "string_4.3.2" | sed 's/^string_\([0-9]\)\.\([0-9]\)\.\([0-9]\)$/\1 \2 \3/'

output "4 3 2" but I want to pass variables to function eg

do_something() {
    echo $1
    echo $2
    echo $3
    # .....
    # .....
}

string="string_4.3.2"
if [[ $string =~ `sed ??????` ]]; then
    do_something "$1" "$2" "$3"
fi

Matched numbers need pasing to method "do_something"

AndrisP 193 Posting Pro in Training

You can drav small circle eg

<circle r=".5" cx="73.3" cy="73.1" fill="black" />
AndrisP 193 Posting Pro in Training
begin
    insert into your_table ....
exception
    when dup_val_on_index then
    update your_table...
end;
AndrisP 193 Posting Pro in Training

@ deceptikon - Thank you for comment. I will follow on your recommendation.

AndrisP 193 Posting Pro in Training

... or use bitwise operator if(i&1) if true even else odd. Its faster because compare one bit only without mathematics

AndrisP 193 Posting Pro in Training

Your pattern checked only first character. Change to:
(!preg_match("/^[0-9a-zA-Z ]+$/", $name3))

Aeonix commented: Yea! +4
AndrisP 193 Posting Pro in Training
strlen(trim($string))
AndrisP 193 Posting Pro in Training

"array" need passing as reference to function "selectionSort"

AndrisP 193 Posting Pro in Training
#include <stdio.h>

int main(){
    int i,s=8;
    while(s<=100){
        printf("\t%d\n", s);
        switch(i){
            case 4: i+=1; break;
            case 5: i+=2; break;
            default: i=4;
        }
        s+=i;
    }
    return 0;
}
AndrisP 193 Posting Pro in Training

You have a form inside another form - may not correctly treated by browser

AndrisP 193 Posting Pro in Training
AndrisP 193 Posting Pro in Training

Your code works properly on Ubuntu 16.04 compiled by CodeBlocks IDE 13.12

AndrisP 193 Posting Pro in Training

Use brackets when you combine multiple AND OR conditions eg

WHERE `aprove` = 1 
AND (`descripcion` LIKE '%$search%' 
        OR `nombre` LIKE '%$search%')
AndrisP 193 Posting Pro in Training

You cannot set combined primary key CONSTRAINT SCREEN_PK PRIMARY KEY(BRANCHID,SCREENID)
The unique index may combine two (or more) fields eg UNIQUE(BRANCHID,SCREENID)

AndrisP 193 Posting Pro in Training

What browser (version) do you use? And what DOCTYPE is declared in your HTML? Tag "details" is new in HTML5. It can be unsupported if your DOCTYPE declared older than HTML5.
W3C maintains that it is working on Firefox 48, but in reality I can see that it works only on the Chromium-based browsers. I tested on FireFox 48 (Linux and Windows) both not properly supported "details" tag. On the Opera, Chromium and Google Chrome clickable "details" working properly.

AndrisP 193 Posting Pro in Training

better looks this

<?php
function makeList(array $Array, &$Output) {
    foreach($Array as $Key => $Value) {
        if(is_array($Value)) {
            $Output .= '<details>';
            $Output .= '<summary>'.$Key.'</summary>';
            $Output .= makeList($Value, $Output);
            $Output .= '</details>';
        } else {
            $Output .= '<div><a name="'.$Value.'" href="#">'.$Value.'</a></div>';
        }
    }
    return;
}
?>

add to style sheet padding

<!DOCTYPE html>
<head>
    <title>Categories</title>
    <style>
    details details { padding-left:30px; }
    </style>
</head>
<body>
<?php

makeList($categories, $Output);
echo $Output;

?>
</body>

is not mistake "details details { ... }" - root details witout padding but any contained <details> with "padding-left"

AndrisP 193 Posting Pro in Training

You can use http://www.w3schools.com/tags/tag_details.asp

<?php
function makeList(array $Array) {
    $Output = '<details>';
    foreach($Array as $Key => $Value) {
        if(is_array($Value)) {
            $Output .= '<summary>'.$Key.'</summary>';
            $Output .= makeList($Value);
        } else {
            $Output .= '<div><a name="'.$Value.'" href="#">'.$Value.'</a></div>';
        }
    }
    $Output .= '</details>';
    return $Output;
}
?>

but is'n't supported on IE

AndrisP 193 Posting Pro in Training

PHP arrays unlimited levels but ini file seems 2 levels only

AndrisP 193 Posting Pro in Training

Make multidimensional array eg

$categories = array(
    'cars' => array(
        'BMW' => array(
            'X1',
            'X3',
            'X5',
            'X6'
        ),
        'AUDI' => array(
            'A3',
            'A6'
        ),
        'MERCEDES'
    ),
    'moto' => array(
        'SUZUKI',
        'HONDA',
        'YAMAHA'
    ),
    'phones' => array(
        'SAMSUNG',
        'LG',
        'MOTOROLA'
    )
);
// etc

You can write data to ini file if it's much readable for you and build array with parse_ini_file() http://php.net/manual/en/function.parse-ini-file.php

Stefce commented: How much sub-arrays i can have ? +2
AndrisP 193 Posting Pro in Training
diafol commented: This needs to be a sticky! Heh heh. +14
AndrisP 193 Posting Pro in Training

Make DB table for categories and another table for brends with foreigh keys constraints referenced to categories and another table for models with constraints referenced to brends

AndrisP 193 Posting Pro in Training

oh sorry its a copy-paste

AndrisP 193 Posting Pro in Training

maybe try

$query = "select * from manuscript where year = :year limit, :offset , :refs";
$sql = $con->prepare($query);
$offset = $page * $refs;
    $sql->bindParam(':year', $year, PDO::PARAM_INT);
    $sql->bindParam(':offset', $offset, PDO::PARAM_INT);
    $sql->bindParam(':refs', $refs, PDO::PARAM_INT);
    $sql->execute();
AndrisP 193 Posting Pro in Training

use one of

    $query = "select count(*) from manuscript where year = :year";
    $sql=$con->prepare($query);
    $sql->bindParam(':year', $year);
    $total = $sql->fetchColumn();
    echo $total;

or

    $query = "select count(*) from manuscript where year = ?";
    $sql=$con->prepare($query);
    $sql->execute([$year]);
    $total = $sql->fetchColumn();
    echo $total;

do not mixed two methods of binding variables

AndrisP 193 Posting Pro in Training

edit links:

for($x=0; $x<$pages; $x++){
       echo '<a href="index.php?page='.$x.'"
                 style="text-decoration:none">'.($x+1).'</a>';
    }

after line 10 insert line $sql->bind_param('i', $year);

AndrisP 193 Posting Pro in Training

Initialize request variables outside of function before you call it

    $year = filter_input(INPUT_GET, 'year', FILTER_VALIDATE_INT);
    $page = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT);
    $refs = filter_input(INPUT_GET, 'refs', FILTER_VALIDATE_INT);

    getYear($year, $page, $refs);

drop lines 13 and 16-30 put new line instead:
if($page>$pages){ $page = $pages; }
elseif($page<0){ $page = 0 }
change variable name in line 14 $refs_per_page to $refs

AndrisP 193 Posting Pro in Training

show me your new version of function

AndrisP 193 Posting Pro in Training

In fact you call basic function which contained in to the object declaration.
I wold recommend write database class which is extended mysqli. In connstructor make connection, in destructor call disconnect then add your "db_select" as public function eg

class DataBase extends mysqli {
    public function __construct(){
        parent::init();
        parent::options(MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT = 1');
        parent::real_connect(DBhost, DBuser, DBpass, DBname, DBport)
    }
    public function __destruct(){
        $this->close();
    }
    public function db_select($sql, $inParam, &$outParam){
        $stmt = $this->stmt_init();
        $stmt->prepare($sql);
        $stmt->bind_param('s', $inParam);
        $stmt->execute();
        $stmt->bind_result($col1, $col2, $col3);
        while($stmt->fetch()){
            $outParam[] = array($col1, $col2, $col3);
        }
        $stmt->free_result();
        $stmt->close();
    }
}

then you can make connection, repeatedly call up a variety of methods and call disconnection at the end eg

$db = new DataBase(); // make connection

$db->db_query(/* add method params */);
$db->db_query(/* other SQL query */);
$db->db_query(/* and other SQL query */);

$db = NULL; // call destructor for disconnect from DB
AndrisP 193 Posting Pro in Training

Two similar function for different year is irrationally. I would suggest to transform getYear() and put year as parameter eg getYear($year). You can set many parameters eg getYear($year, $page, $refs) you can set default values also eg getYear($year=date("Y"), $page=0, $refs=20) then replace your query

$year = filter_input(INPUT_GET, 'year', FILTER_VALIDATE_INT);
$page = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT);
$refs = filter_input(INPUT_GET, 'refs', FILTER_VALIDATE_INT);

$query = "select * from manuscript where year = :year limit :page*:refs,:refs";

never put request variables directly to the SQL query! - use bind variables and bind params after prepare query

$stmt = $conn->prepare($query);
$stmt->bindParam(':year', $year, PDO::PARAM_INT);
$stmt->bindParam(':page', $page, PDO::PARAM_INT);
$stmt->bindParam(':refs', $refs, PDO::PARAM_INT);
$stmt->execute();

Replace HTML links eg

<a href="index.php?year=2015&page=0">2015/1</a>
<a href="index.php?year=2015&page=1">2015/2</a>
<a href="index.php?year=2015&page=2">2015/3</a>
.....
.....
.....
<a href="index.php?year=2016&page=0">2016/1</a>
<a href="index.php?year=2016&page=1">2016/2</a>
<a href="index.php?year=2016&page=2">2016/3</a>
rproffitt commented: Well said. +11
diafol commented: Good advice +14
AndrisP 193 Posting Pro in Training

It is not good idea because your db_select() function make new connection on each query

AndrisP 193 Posting Pro in Training

And you can use attribute "required" for all required fields in a form such as:

<input type="email" name="email" width="20" required="required" />

HTML5 input type "email" is supported. if you use this type then client web browser check input email address before data form send to server. On the server side check email address with "filter_input()".

$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
AndrisP 193 Posting Pro in Training

For first:

  $id = $_GET['id'];
  $action = $_GET['action'];

is not good practice! It raise PHP error if not set. All request variables initialize like this:

$id = ( isset($_GET['id']) ? $_GET['id'] : '' );

"isset($action)" in to the line 9 is senseless, check it while initialize

$action = ( isset($_GET['action']) ? $_GET['action'] : 'edit' );
cereal commented: Hi, why not `filter_input()` then? https://php.net/filter-input +14
AndrisP 193 Posting Pro in Training

Try this:

 <?php
    $num=array(rand(), rand(), rand(), rand(), rand());
    for($i=0;$i<5;$i++)
    echo '<input type="number" value="'.$num[$i].'">';
    ?>

Your array is empty

AndrisP 193 Posting Pro in Training

Both order is valid but attribute "alt" is necessary for valid "img" tag

AndrisP 193 Posting Pro in Training

In your example "0" is terminator but "0" allways incrases "even".
Check if(entNum==0){ break; } after scanf.
More convenient is binary compare to 1 for test even and odd in my opinion e.g. lines 15-22 you can replace to one line: entNum & 1 ? odd++ : even++ ; variable "ans" is unnecessary.