Jump to content

simona6

Members
  • Posts

    146
  • Joined

  • Last visited

Everything posted by simona6

  1. We are building this tool where admins can group the range of followers by what has been added in a 'creation' screen. So they might put Facebook: followers 5000-10000. Twitter: followers 2500-5000. The users enter their followers into a field, and their social media platform. So I need the database to query both the platform name and their followers, dynamically. SELECT u.id, u.selfdescription, u.usertype AS usertype, u.username AS username, u.firstname AS firstname, u.surname AS surname, u.instagram AS instagram, u.facebook AS facebook, u.twitter AS twitter, u.pinterest AS pinterest, u.youtube AS youtube, u.instagramurl AS instagramurl, u.facebookurl AS facebookurl, u.twitterurl AS twitterurl, u.pinteresturl AS pinteresturl, u.youtubeurl AS youtubeurl, u.profilephoto AS profilephoto, g.userid AS userid, g.gigid AS gigid, u.status, u.datecreated AS datecreated, u.town AS town, g.answer FROM gigsassigned AS g INNER JOIN users AS u ON u.id = g.userid WHERE u.usertype = 'influencer' AND status IS NULL AND gigid =:gid AND dateadded IS NOT NULL AND $rowrange->platform >=:rangelow AND $rowrange->platform <=:rangehigh So it has to query the "platform" field in 'users' and check if that field is within the 'range'. How do I put a variable in there, like you can see here toward the end of the script?
  2. Totally agree. But at the time I wasn't aware of the reasoning behind this dropdown option. If I did it again, yes I would split it anyway.
  3. Bingo: $followersrange = (explode("-",$rowrange->followersrange)); // with positive NoOfElements $rangelow = $followersrange[0]; $rangehigh = $followersrange[1]; echo "$rangelow > $rangehigh<br/>"; 2000 > 5000 5000 > 10000
  4. $input_array = array_chunk($rowrange->followersrange); $array1=$input_array[0]; $array2=$input_array[1]; echo "$array1 > $array2"; Warning: array_chunk() expects at least 2 parameters, 1 given in C:\xampp\phpMyAdmin\site\includes\admin-gig.inc on line 208 > Warning: array_chunk() expects at least 2 parameters, 1 given in C:\xampp\phpMyAdmin\site\includes\admin-gig.inc on line 208 > For reference here.................. $rowrange->followersrange = "5000-10000";
  5. $input_array = array($rowrange->followersrange); $array1=$input_array[0]; $array2=$input_array[1]; echo "$array1 > $array2";; Notice: Undefined offset: 1 in C:\xampp\phpMyAdmin\site\includes\admin-gig.inc on line 210 2000-5000 > Notice: Undefined offset: 1 in C:\xampp\phpMyAdmin\site\includes\admin-gig.inc on line 210 5000-10000
  6. $input_array = array($rowrange->followersrange); $array1=chunk[0]; $array2=chunk[1]; echo "$array1 > $array2";; Warning: Use of undefined constant chunk - assumed 'chunk' (this will throw an Error in a future version of PHP) in C:\xampp\phpMyAdmin\site\includes\admin-gig.inc on line 209 Warning: Use of undefined constant chunk - assumed 'chunk' (this will throw an Error in a future version of PHP) in C:\xampp\phpMyAdmin\site\includes\admin-gig.inc on line 210 c > h Warning: Use of undefined constant chunk - assumed 'chunk' (this will throw an Error in a future version of PHP) in C:\xampp\phpMyAdmin\site\includes\admin-gig.inc on line 209 Warning: Use of undefined constant chunk - assumed 'chunk' (this will throw an Error in a future version of PHP) in C:\xampp\phpMyAdmin\site\includes\admin-gig.inc on line 210 c > h
  7. Ooooo, how do I assign the two chunks I need, into their own variables?
  8. We have a database that shows for example: 2500-5000 5000-10000 10000-15000 15000-20000 I need to show in a screen what people are have 3000 followers, and as such as grouped into that 2500-5000. The best way I can see how to do this, is to run through the database table for these values. Then for each value, put the first and second set of numbers into two respective variables, say $low, $high. Then find those people who are on a particular platform with followers between those two values. So how do I turn $row->followsrange (which might be for example: "2500-5000"), into: $low = 2500 $high = 5000. Many thanks. ps I have a feeling the hyphen might play a bit part, as it cannot be done by the amount of characters..........
  9. $lowestrange = 50000; $highestrange = 500; if ($rowcats->followersrange == "2000-5000") { $lowrange2000 = "2000"; $lowestrange = $lowrange2000; $numberpeople = $rowcats->numberpeople; } if ($rowcats->followersrange == "5000-10000") { $lowrange5000 = "5000"; if ($lowrange5000 < $lowestrange) { $lowestrange = $lowrange5000; $numberpeople = $rowcats->numberpeople;} } if ($rowcats->followersrange == "10000-15000") { $lowrange10000 = "10000"; if ($lowrange10000 < $lowestrange) { $lowestrange = "$lowrange10000"; $numberpeople = $rowcats->numberpeople;} } if ($rowcats->followersrange == "15000-20000") { $lowrange15000 = "15000"; if ($lowrange15000 < $lowestrange) { $lowestrange = $lowrange15000;$numberpeople = $rowcats->numberpeople;} } if ($rowcats->followersrange == "15000-20000") { $lowrange15000 = "15000"; if ($lowrange15000 < $lowestrange) { $lowestrange = $lowrange15000; $numberpeople = $rowcats->numberpeople;} } Though it was set to $lowestrange = NULL; before, at the top.
  10. I have just set this at the top: $lowestrange = 50000; $highestrange = 500; It works, but is it the right thing to do. As 10000 is NOT lower than NULL...?!
  11. if ($rowcats->followersrange == "2000-5000") { $lowrange2000 = "2000"; $lowestrange = $lowrange2000; $numberpeople = $rowcats->numberpeople; } if ($rowcats->followersrange == "5000-10000") { $lowrange5000 = "5000"; if ($lowrange5000 < $lowestrange) { $lowestrange = $lowrange5000; $numberpeople = $rowcats->numberpeople;} } if ($rowcats->followersrange == "10000-15000") { $lowrange10000 = "10000"; if ($lowrange10000 < $lowestrange) { $lowestrange = "$lowrange10000"; $numberpeople = $rowcats->numberpeople;} if ($lowestrange == NULL) { echo "yes";} echo "$lowestrange"; } if ($rowcats->followersrange == "15000-20000") { $lowrange15000 = "15000"; if ($lowrange15000 < $lowestrange) { $lowestrange = $lowrange15000;$numberpeople = $rowcats->numberpeople;} } We are trying to find the lowest range from the entries added to a database, so at the end, we can say the range is FROM... TO... They might opt for 2-5k, or 5-10k etc. If they opt for 10-15k, then the lowest range is 10,000. We have a result of 10000 - 15000. So the $lowrange10000 = "10000". Therefore, this should be echoing the $lowestrange from 7th line up in this code, but it remains at NULL, based on: $lowestrange = NULL;, set at the top of the code. Why is that?
  12. Ooo thanks. BTW the reason why it wasn't working or generating errors was a RAM issue. It appears that the RAM was set wrong... it showed nothing. As soon as I made it 128mb, it all loaded.
  13. $params = array(); $sqlFilters = ""; if(isset($filtertown)) { $sqlFilters .= " AND town =:town"; $params["town"] = $filtertown; } if(isset($filterinstagram) && !empty($filterinstagram)) { $sqlFilters .= " AND instagram >=:instagram"; $params["instagram"] = $filterinstagram; } if(isset($filtertwitter) && !empty($filtertwitter)) { $sqlFilters .= " AND twitter >=:twitter"; $params["twitter"] = $filtertwitter; } if(isset($filterfacebook) && !empty($filterfacebook)) { $sqlFilters .= " AND facebook >=:facebook"; $params["facebook"] = $filterfacebook; } if(isset($filterpinterest) && !empty($filterpinterest)) { $sqlFilters .= " AND pinterest >=:pinterest"; $params["pinterest"] = $filterpinterest; } if(isset($filteryoutube) && !empty($filteryoutube)) { $sqlFilters .= " AND youtube >=:youtube"; $params["youtube"] = $filteryoutube; } if (isset($userstatus)) { if ($userstatus == "active") { $sqlFilters .=" AND profilecomplete = 'yes'";} if ($userstatus == "incomplete") { $sqlFilters .=" AND profilecomplete IS NULL";} if ($userstatus == "block") { $sqlFilters .=" AND status = 'block'";} if ($userstatus == "cancel") { $sqlFilters .=" AND status = 'cancel'";} if ($userstatus == "showall") { $sqlFilters .=" AND status IS NULL";} } if (isset($search)) { if (isset($searchfirstname)) { $sqlFilters .= " AND firstname LIKE :searchfirstname"; $params["searchfirstname"] = $searchfirstname; } if (isset($searchsurname)) { $sqlFilters .= " AND surname LIKE :searchsurname"; $params["searchsurname"] = $searchsurname; } } $sqlStart = "SELECT * FROM users WHERE usertype = 'influencer'"; // only use $sqlSort to sort columns if it is selected, else add a blank to the query if (isset($sort)) { $sqlSort = " ORDER BY `$col` $order ";} else { $sqlSort = "";} $sqlEnd = " LIMIT $offset, $rowsPerPage;"; $sql = $sqlStart.$sqlFilters.$sqlSort.$sqlEnd; // sqlfiltercount removes the LIMIT to show ALL users on this userstatus filter $sqlfiltercount = $sqlStart.$sqlFilters; $result = $pdo->prepare($sql); $result->execute($params); $num_users = $result->rowCount(); echo "$sqlfiltercount"; $resultfiltercount = $pdo->prepare($sqlfiltercount); $resultfiltercount->execute($params); $num_usersfiltered = $resultfiltercount->rowCount(); This is still showing a blank on our live server. I've added the Sort only if it is submitted, but within the same query, and it works on Localhost. Still unclear why it's not showing anything, simply because of $resultfiltercount. Any ideas?
  14. I'm keen to learn how you might all code this differently, so I can understand an improved way to do it. I am genuinely stuck. I thought I had done a good job, as appending submitted variables to a query is new to me - only learnt it in the last few months. We need to only show the first rowsPerPage at the start, but within that query, we also need to show ALL those found where their userstatus is as submitted. ie. to see all Blocked, or all Active.
  15. This is PDO. Thanks for the note though.
  16. I did try it with Prepare and using the Array in the Execute, but the same problem occurs. I also don't understand why it works on my laptop but not on the live server - when both are the same PHP versions.
  17. BTW... I can see what you mean about the $sort. I can perhaps append that into just one query, but the second bit must be in two queries as part of it is down to the LIMIT per page, and the other count is TOTAL. Are you able to assist? btw nice to get help from a fellow UK person.
  18. I thought query() was used when it is not prepared. That's when you prepare(). How would you write that final bit of code then to make it work?
  19. Yes. Nothing showing in there. I've raised it with our hosts to see if they can spot anything that the Apache Errors are not showing. It's not showing errors on screen my end either. Both versions are PHP7.2.27.
  20. $params = array(); $sqlFilters = ""; if(isset($filtertown)) { $sqlFilters .= " AND town =:town"; $params["town"] = $filtertown; } if(isset($filterinstagram) && !empty($filterinstagram)) { $sqlFilters .= " AND instagram >=:instagram"; $params["instagram"] = $filterinstagram; } if(isset($filtertwitter) && !empty($filtertwitter)) { $sqlFilters .= " AND twitter >=:twitter"; $params["twitter"] = $filtertwitter; } if(isset($filterfacebook) && !empty($filterfacebook)) { $sqlFilters .= " AND facebook >=:facebook"; $params["facebook"] = $filterfacebook; } if(isset($filterpinterest) && !empty($filterpinterest)) { $sqlFilters .= " AND pinterest >=:pinterest"; $params["pinterest"] = $filterpinterest; } if(isset($filteryoutube) && !empty($filteryoutube)) { $sqlFilters .= " AND youtube >=:youtube"; $params["youtube"] = $filteryoutube; } if (isset($userstatus)) { if ($userstatus == "active") { $sqlFilters .=" AND profilecomplete = 'yes'";} if ($userstatus == "incomplete") { $sqlFilters .=" AND profilecomplete IS NULL";} if ($userstatus == "block") { $sqlFilters .=" AND status = 'block'";} if ($userstatus == "cancel") { $sqlFilters .=" AND status = 'cancel'";} if ($userstatus == "showall") { $sqlFilters .=" AND status IS NULL";} } if (isset($search)) { if (isset($searchfirstname)) { $sqlFilters .= " AND firstname LIKE :searchfirstname"; $params["searchfirstname"] = $searchfirstname; } if (isset($searchsurname)) { $sqlFilters .= " AND surname LIKE :searchsurname"; $params["searchsurname"] = $searchsurname; } } if (isset($sort)) { $sqlStart = "SELECT * FROM users WHERE usertype = 'influencer'"; $sqlEnd = " ORDER BY `$col` $order LIMIT $offset, $rowsPerPage;"; $sql = $sqlStart.$sqlFilters.$sqlEnd; $sqlfiltercount = $sqlStart.$sqlFilters; $result = $pdo->prepare($sql); $result->execute($params); $resultfiltercount = $pdo->prepare($sqlfiltercount); $resultfiltercount->execute($params); $num_users = $result->rowCount(); $num_usersfiltered = $resultfiltercount->rowCount(); } else { $sqlStart = "SELECT * FROM users WHERE usertype = 'influencer'"; $sqlEnd = " LIMIT $offset, $rowsPerPage;"; $sql = $sqlStart.$sqlFilters.$sqlEnd; // sqlfiltercount removes the LIMIT to show ALL users on this userstatus filter $sqlfiltercount = $sqlStart.$sqlFilters; $result = $pdo->prepare($sql); $result->execute($params); $num_users = $result->rowCount(); echo "$sqlfiltercount"; $resultfiltercount = $pdo->query($sqlfiltercount); $num_usersfiltered = $resultfiltercount->rowCount(); } Hi there. I am writing a tool that displays a list of users. The page has pagination, set at 99 per page. This script combines the various filters added by the administrator, but if they select Active, Blocked or a few others, it bypasses that and runs the bottom {} brackets of query. You have the $num_users which is the total on screen at the time, plus the secondary count of TOTAL users in the system. This count is then show by 'users' on the page. This runs fine on my local machine running php7.2, but on the live 7.2 server, it's showing nothing. No errors. If I comment out the $resultfiltercount lines, the page loads, but of course no count. Why might it be getting upset at that, and why would it not throw errors on screen at me?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.