cabbie Posted October 5, 2013 Share Posted October 5, 2013 I want to get a number from a data base use it in another script increment by 1 and insert back into that column. In this script how can I get the numeric value of que? $query = $db->query("SELECT `que` FROM `tracker` "); while($rows = $query->fetch(PDO::FETCH_ASSOC)){ echo $rows['que']; (prints que) echo que; (does not work) Quote Link to comment https://forums.phpfreaks.com/topic/282746-que-count/ Share on other sites More sharing options...
Barand Posted October 6, 2013 Share Posted October 6, 2013 Go with the one that works Quote Link to comment https://forums.phpfreaks.com/topic/282746-que-count/#findComment-1452826 Share on other sites More sharing options...
cabbie Posted October 6, 2013 Author Share Posted October 6, 2013 I need que to be an integer value.. A number I can use math on. Ill provide a link to survey page Whatever the que is a query SELECTS the data in that row. What I want to do is on the next operation got to the next ID.. http://libertarianpartylc.org/survey.php Quote Link to comment https://forums.phpfreaks.com/topic/282746-que-count/#findComment-1452851 Share on other sites More sharing options...
Barand Posted October 7, 2013 Share Posted October 7, 2013 Are you trying to find out what the next ID should be for a new record by finding the last one used then adding 1 to it? Quote Link to comment https://forums.phpfreaks.com/topic/282746-que-count/#findComment-1452902 Share on other sites More sharing options...
cabbie Posted October 7, 2013 Author Share Posted October 7, 2013 This is a phone survey script... survey php prints the current reg voters data on the survey page. The surveyor attempts a call and gets a no answer or contact and Selects this result from a dropdown which calls operation.php. Operation.php increments the row id and stores it into table tracker. survey.php then prints the new data for the next call .. this code is almost working.. this is a link to the survey page. and link to the code below that. survey page http://libertarianpartylc.org/survey.php code http://pastebin.com/9dx04UDP Quote Link to comment https://forums.phpfreaks.com/topic/282746-que-count/#findComment-1452939 Share on other sites More sharing options...
Barand Posted October 7, 2013 Share Posted October 7, 2013 Survey.php Line 9: The query uses a parameter "?" (mysqli type, not PDO!) but no bindParam() statement. Does each operator have their own que_id? It looks like you need to pass the$row['id'] of the last call made in the form (hidden field) to operation.php (or use the $_SESSIONto store). operator.php When you update tracker table I think you need a "WHERE que_id = :queid" Quote Link to comment https://forums.phpfreaks.com/topic/282746-que-count/#findComment-1452950 Share on other sites More sharing options...
cabbie Posted October 7, 2013 Author Share Posted October 7, 2013 Originally que_id was the increment variable and i was passing between pages. the table tracker has 2 columns id (not auto incremented) and que_id. each operator after login will start at the current que_id or id.. Yes I had where Que_id= que_id but changed it As you can see I have put a lot of time in this project and way over my head trying to develop this code and pulling my hair. Syntax in this particular operation is the problem.. Quote Link to comment https://forums.phpfreaks.com/topic/282746-que-count/#findComment-1452954 Share on other sites More sharing options...
cabbie Posted October 7, 2013 Author Share Posted October 7, 2013 This is close.... http://pastebin.com/rqSVNBFV Quote Link to comment https://forums.phpfreaks.com/topic/282746-que-count/#findComment-1452956 Share on other sites More sharing options...
cabbie Posted October 7, 2013 Author Share Posted October 7, 2013 Everything works but the SELECT COUNT $q = $db->prepare("SELECT COUNT(id) as records FROM tracker WHERE que_id = 3"); $q->execute(); $records = (int) $q->fetch(PDO::FETCH_OBJ)->records; echo '$records =', $records; Quote Link to comment https://forums.phpfreaks.com/topic/282746-que-count/#findComment-1452966 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.