Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

preventing PHP page from outputting text (part of Ajax app)

$
0
0

Here is a segment of code that I'm using in a PHP script, which is called as part of an AJAX HTTP Request:

 

<?php

   
    $result = $user_conn->execQuery($sql_query);
    
    while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
        $resultText .= '<option value="'.$row['id'].'">'.$row['display_text'].'</option><br />'."\n";
    }

    echo $resultText;
?>

 

NOTE: I created a MySQL class with custom functions, so execQuery() is a custom function I created that actually runs the query() command for SQL.

 

Anyway, as you can see, to get the results back to the JavaSCript calling request function, I used ECHO.  Is there an alternative so that if someone where to run just this PHP script directly, it wouldn't output any text (because right now it will)?

 

(I asked this a few weeks ago but seem to have "lost" the post.)


Viewing all articles
Browse latest Browse all 13200

Trending Articles