
taquitosensei
Members-
Posts
676 -
Joined
-
Last visited
-
Days Won
2
Everything posted by taquitosensei
-
Limit 50 rows in search results per page
taquitosensei replied to mark107's topic in PHP Coding Help
You can use LIMIT in mysql select rows from table limit 1,21 would return the first 21 results. You'd have to build in some logic to determine which page you're on. Here's an example. https://www.myprogrammingtutorials.com/create-pagination-with-php-and-mysql.html -
a boolean is 1 or 0, true or false. Usually a column labelled as "unread" would be a boolean telling you whether it had been read or not. If it's supposed to hold the user's id, you should rename it. But after looking at your table here is what the query should look like. $stmt = $this->db->prepare("SELECT unread FROM pm WHERE unread=1 and receiver_id=:id") This would get all of the results that were sent to your user that have not been read. You don't need the bind_result line. I believe that's a mysqli function and not needed with pdo.
-
What does the unread table look like. You only need to bind when you're putting user submitted data in your query. You don't have to do that with unread=1. Also unread shouldn't ever equal an id, because it's probably a boolean. Your query should probably look more like this if($stmt = $this->db->prepare("SELECT unread FROM pm WHERE unread=1 and id_field=:id")) { $stmt->bindParam(':id', $id, PDO::PARAM_INT); }
-
Connectivity error or Security Certificate Issue ?
taquitosensei replied to DontheCat's topic in PHP Coding Help
The PR_END_OF_FILE_ERROR is either an issue with the format of your certificate or you might have an older version of nss. -
You would need to involve javascript. You could do this almost all in javascript then do an ajax call to send the data to php. Here's a guide that shows how to listen for sound and make a reactive page. It should give you an idea of how to start. https://hackernoon.com/creative-coding-using-the-microphone-to-make-sound-reactive-art-part1-164fd3d972f3
-
You don't need to decode. Store the users info in your database. Pre-fill the form. Let them change the info. Then generate a new QRCode and update your database.
-
Unexpected results when adding intervals to DateTime
taquitosensei replied to NotionCommotion's topic in PHP Coding Help
$dt4->add($dif); I think that gives the result expected. Not sure why. 2019-07-15 12:30:00 | 2019-07-17 14:15:30 | 0 0 2 1 45 30<br>2019-08-17 01:45:30 | 2019-08-19 03:31:00 | 0 0 2 1 45 30<br> -
Need more info. What is it supposed to do, what is it not doing. I 2nd foreach. $files = array("file1.php","file2.php","file3.php"); foreach($files as $file) { include($file); }
-
there is something wrong with $query->wheres, it's not countable. So it's not an array or not an object. Do var_dump($query->wheres); after the $query = to find out what it is and what it does contain.
-
I usually echo at the end of the script instead of in the loop and also send 200 http response. $result = $page->read($_GET['pageid']); //check for data if ($result) { //page array $page_arr['pages'] = array(); while ($row =$result->fetch(PDO::FETCH_ASSOC)) { extract($row); $page_item = array( 'id'=> $id, 'title' => $title, 'pageid' => $pageid, 'pagecontent' =>html_entity_decode($pagecontent), 'mdkeywords' => $mdkeywords, 'description' =>$description, 'date_added' =>$date_added, 'hasAudio' => $hasAudio, 'excludeSearch' =>$excludeSearch ); //push to data array_push($page_arr['pages'], $page_item); } http_response_code(200); } else { $page_arr['message']="Nothing Here!!!"; } echo json_encode($page_arr);
-
How to print largest even number in given string?
taquitosensei replied to aveeva's topic in PHP Coding Help
I didn't even think about using the max function. $numbers = array(1,3,7,8,10,12); foreach($numbers as $number) { if($number%2==0) { $evens[]=$number; } } $max_number = max($evens); echo $max_number; -
How to print largest even number in given string?
taquitosensei replied to aveeva's topic in PHP Coding Help
$numbers = array(1,3,7,8,10,12); foreach($numbers as $number) { if($number%2==0) { if($number > $old_number) { $max_number = $number; } $old_number = $number; } } echo $max_number; Not sure what nodejs has to do with anything. This is a php forum. Something like this would do it in php. -
PHP - Ajax Passing value to another php file
taquitosensei replied to aveeva's topic in PHP Coding Help
If you're not seeing the results you expect in console. I use postman for troubleshooting. You can put in the URL and the post data in json format, and run it to see what the result actually is. You could have an error in my_cart.php. You could be outputting something along with your json. Your json may not be formatted properly. I would add this ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); to the beginning of my_cart.php and either view the results in development tools or download postman and try it that way. -
PHP structure with Composer does not work in production
taquitosensei replied to montilla's topic in PHP Coding Help
A white screen could be a fatal error. I would turn on error reporting put ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); at the top of your index.php, if it is a fatal error, the error should display instead of the white screen. -
When you use the $row variable in your form action you're not in the $row loop yet and that wouldn't make sense anyways because you'd be creating your form repeatedly, as many times as there are results in your query. Also selecting an option with the value of the URL you want to be redirected to won't work. The value would just get passed with the other form data. For this to work you would need javascript to get the url from the selected option and redirect you.
-
Is this query correct? Something going wrong with getting MAX value.
taquitosensei replied to imgrooot's topic in MySQL Help
Yeah ok nm I wasn't thinking when I wrote that. -
Is this query correct? Something going wrong with getting MAX value.
taquitosensei replied to imgrooot's topic in MySQL Help
Just curious would this be any more efficient? SELECT entry_id, votes FROM entries group by entry_id order by votes ASC -
ajax redirect doesn't work after php insert mysql query
taquitosensei replied to michaelfurey's topic in PHP Coding Help
Along with everything else. You need to echo a properly formatted json string. echo "{'message':'correct'}"; then if(data.message === 'correct') -
Live location tracking using php and javascript
taquitosensei replied to urajesh's topic in PHP Coding Help
So you want tracking information but want it refreshed on a regular basis? Is it always shipped through the same shipping company? ie FedEx, UPS, etc? If not you'll have to come up with a solution for each tracking company. Just deal with pulling tracking information first, then worry about refreshing it. So you have to pull the shipping provider and tracking # out of your database, then based on the shipping provider use an api to get the tracking info, then parse that info and display it. -
Try this. <form id="main-search-form" method="POST" action="<?= $baseurl; ?>/_searchresults.php" role="search"> <select id="query-input" name="city_id" style="width:28.8%" style="height:69px" required> <option value="">Select Area</option> <option value="3,1">Ches & VB</option> <option value="3">Chesapeake , VA</option> <option value="9">Hampton , VA</option> <option value="10">Newport News , VA</option> <option value="2">Norfolk , VA</option> <option value="12">Poquoson , VA</option> <option value="4">Portsmouth , VA</option> <option value="5">Suffolk , VA</option> <option value="1">Virginia Beach , VA</option> <option value="11">Williamsburg , VA</option> <option value="0">All Active US Cities</option> </select> then if($_SERVER['REQUEST_METHOD'] == 'POST'){ if(isset($_POST['city_id']) && $_POST['city_id']!="") { $city_ids=explode(",", $_POST['city_id']); $query = "SELECT city_name, state FROM cities"; switch($_POST['city_id']) { case 0: Default: $query.=" WHERE city_id IN (:" . implode(',:',$city_ids) . ")"; } $stmt = $conn->prepare($query); foreach($city_ids as $city_id) { $stmt->bindValue(":query_city_id",$city_id); } $stmt->execute(); $cities = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach($cities as $city) { } } } Haven't tested it. But something like this.
-
I had a boss who had an 80/20 rule. Program for the 80%. He would have told me not to worry about people with their cookies disabled. Make sure it works for everyone else.
-
Important "if" statement relying on mySQL
taquitosensei replied to StevenOliver's topic in PHP Coding Help
I would personally go for #2 I don't know if it's safer. I just like the idea of setting a flag then using that flag. -
I just tried the syntax and it works. Have you tried it? Without knowing where $ARR and $NEEDLE come from and what they look like. It's hard to know what the problem is.