Search
 
SCRIPT & CODE EXAMPLE
 

PHP

return multiple rows from mysqli php and encode JSON

<?php
    $dashboard_content_token = $_REQUEST["dashboard_content_token"];
    $token = "g4";

    require(cc_scripts/connect.php);

    $sql = "SELECT * FROM `dashboard_content`";
    $check = strcmp("$token", "$dashboard_content_token");
    $statement = mysqli_query($con, $sql);
    if (check) {
        $rows = mysqli_fetch_assoc($statement);
        if (!$rows) {
            echo "No results!";
        } else {

          do {
             $news_id = $rows['news_id'];
             $image_url = $rows['image_url'];
             $news_title = $rows['news_title'];
             $news_description = $rows['news_description'];
             $news_article = $rows['news_article'];

               $result['dashboard content: '][] = array('news_id' => $news_id, 'image_url' => $image_url, 'news_title' => $news_title, 'news_description' => $news_description, 'news_article' => $news_article); 


          } while ($rows = mysqli_fetch_assoc($statement));

        mysqli_free_result($statement);
        echo json_encode($result);
    }
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: iterate over assets container statamic 
Php :: laravel orm tutorial 
Php :: php pdo connect to database 
Php :: laravel gigapay resend payout notification 
Php :: condition for both of one should be true laravel eloquent 
Php :: smarty shorthand if 
Php :: php get last 4 digits of string 
Php :: how to make text bigger in php file 
Php :: Fehler beim Uploadtest der ausgewählten Datei. 
Php :: laravel excel check for duplicates 
Php :: add document by api php 
Php :: php display result from html 
Php :: undefined array key php 
Php :: Generating Random String In PHP Using Brute Force 
Php :: php division without round 
Php :: drop down list display only seleted item only 
Php :: phpunit-watcher 
Php :: sort array by date php 
Php :: laravel download file from storage with progress bar 
Php :: replace key name in associative array 
Php :: array_key_first not works 
Php :: verify that a valid login cookie was sent in order to do special things for that logged-in 
Php :: Required parameter follows optional parameter (500 Internal Server Error) php 
Php :: laravel change value to intger 
Php :: @parent laravel 
Php :: how to show image in easyadmin 3 index page 
Php :: vriadic function in php 
Php :: how to restrict user to some pages using php 
Php :: Drupal 9 check if UUD is valid 
Php :: Call to a member function delete() on null laravel 8 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =