jimfog Posted July 8, 2015 Share Posted July 8, 2015 I am using a prepared statement to bring results from more that 2 tables. One of the tables lists servicenames with prices and duration....each table row corresponds to one service....so: while ($stmt->fetch()) { $serviceslist[]=array('service'=>$servicename,'price'=>$price,'serviceID'=>$serviceID,'duration'=>$duration); } The problem is that I need to fetch some data that reside to another table....regarding if the prices of the services should be visible or not....so I do something like this: while ($stmt->fetch()) { $serviceslist[]=array('service'=>$servicename,'price'=>$price,'serviceID'=>$serviceID,'duration'=>$duration); $serviceslist['prices']=$prices_visibility; } and then to print to the browser: for($i = 0, $size = count($serviceslist); $i < $size; ++$i) {?><input class='services' data-service="<?php {echo $serviceslist[$i]['serviceID'];} ?>" size ='40' value="<?php {echo $serviceslist[$i]['service'];} ?>" type="text" name="<?php echo 'service'.$i ?>"> //line 258 <input class='price' size ='3' value="<?php {echo $serviceslist[$i]['price'];} ?>" type="text" name="<?php echo 'price'.$i ?>"> <input class='duration' size ='3' value="<?php {echo $serviceslist[$i]['duration'];} ?>" type="text" name="<?php echo 'duration'.$i ?>">λεπτά <?php }?> the problem is that I get a warning: <br /><b>Notice</b>: Undefined offset: 2 in <b>C:Apache24htdocsAppointmentsAdministratorprofile.php</b> on line <b>258</b><br /> Obvioulsy adding to the array the prices index creates a problem with the loop...but what that might be? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 8, 2015 Share Posted July 8, 2015 Use print_r on $serviceslist to see the problem. Link to comment Share on other sites More sharing options...
jimfog Posted July 8, 2015 Author Share Posted July 8, 2015 Use print_r on $serviceslist to see the problem. within the loop or outside it... Link to comment Share on other sites More sharing options...
justsomeguy Posted July 8, 2015 Share Posted July 8, 2015 At any point after you've finished building it. You can put it in a loop if you want to see the same thing over and over. Link to comment Share on other sites More sharing options...
jimfog Posted July 9, 2015 Author Share Posted July 9, 2015 here is what get printed(print_r is used outside of the loop): Array ( [0] => Array ( [service] => haircut [price] => 65.00 [serviceID] => 19 [duration] => 20 ) [price] => 1 [1] => Array ( [service] => μανικιουρ [price] => 70.00 [serviceID] => 20 [duration] => 20 ) ) I think [price] is creating the issue here... So the question becomes how to integrate prices to the array without triggering such a notice. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 9, 2015 Share Posted July 9, 2015 The question that I have is what are you trying to do with this line: $serviceslist['prices']=$prices_visibility;And why that says "prices" but the print_r output says "price". Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now