1

i want that against each numbers, its call_count and duration are saved in single array.. this is my table:

Number   Call_count duration
03455919448    4             14
03215350700    2             35

i want somethng like this:

foreach($number as $number1)
{
$data=array($row['call_count']<3,$row['duration']<20,1)
}

basically i want against each number its count and duration are checked for some values and if they meet the condition, display output 1... actually i can do it with simple if-else but as i have to train my dataset for neural network implementaion so all rows must be in one array? can anyone please help me out?

4
  • What is in $number and/or $number1 Commented May 27, 2013 at 19:14
  • use PDO and set the FETCH_TYPE to FETCH_ASSOC which will give you an associative array of columns per row.link Commented May 27, 2013 at 19:14
  • $number is the database column fetched through sql query and $number1 is the temporary variable as its the syntax for foreach loop.. its like: $l=0;$number=$row['number']; $num[$l]=$number; $l++; @Farkie Commented May 27, 2013 at 19:20
  • can someone please code it correctly... would be appreciatable Commented May 27, 2013 at 19:22

2 Answers 2

1

Maybe I don't understand quite well your code, but:

foreach($number as $number1)

$number1 is never used in your foreach :

$data=array($row['call_count']<3,$row['duration']<20,1)

So I guess $number1 is $row.

Second, it would help me if you provide the SQL Statement you are using now.

Sign up to request clarification or add additional context in comments.

1 Comment

$number is the database column fetched through sql query and $number1 is the temporary variable as its the syntax for foreach loop.. its like: $l=0;$number=$row['number']; $num[$l]=$number; $l++;
0

You could do a query like:

select Number, if(Call_count<3, if(duration<20, 1, 0), 0) as checked from tablename;

This gives you only the number, and 1 if both conditions are met, and 0 otherwise.

After that, in php do a loop (presented in plain mysql* funcions)

$data = array();
while ($row = mysql_fetch_assoc($result)) { // row will be an array with Number and checked as items
    $data[] = $row;
}
// at this point you will have all rows in one array, with number and corresponding 1/0 in each item

1 Comment

yeah i can do it like that but as i narratd earlier i need this data to train my neural net.. and for that the steps are:1. Initially, for each attribute, a threshold value is assigned. 2. The attribute values of the training dataset are compared with the attribute‟s threshold to declare that a customer will churn or not. Simple if…then …else rules are applied in this process. 3. A model is then constructed for the training dataset. 4. The model is then applied on the test dataset and the results are listed.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.