开发者

Where inside a web page should I display data in order to be retrieved by HttpConnection?

开发者 https://www.devze.com 2023-04-01 12:00 出处:网络
I want to get a text from a PHP file through java j2me , the tex开发者_开发技巧t is the maximum value of the primary key of a MySQL table. So I use HttpConnection to make a connection to the web page.

I want to get a text from a PHP file through java j2me , the tex开发者_开发技巧t is the maximum value of the primary key of a MySQL table. So I use HttpConnection to make a connection to the web page. But I do not know where should I put ( echo in PHP ) the text : is it inside the <header> or inside the <body> or somewhere else inside the PHP file ?


If I understand you usage correctly (which means you call the script from the Cleint just to get the value) you do not output ANY tags/text other than your value:

yourFile.php

<?php
    /*
        Code/Logic to read out the $pkMax-value
    */
    echo $pkMax;
?>


You don't need HTML to retrieve the data. HttpConnection will just retrieve the whole page, so you can make PHP output your data in simple text format or JSON or whatever you want.


You just have to put it on top, without any parents. Your browser might not display

<html>
<head>
<body>

tags, but if you just display the raw output you got from your Http request, then you will see those tags.


If all the webpage needs to do is to give that number to your j2me program, you don't need a <header> or <body>, just echo the data as plain text.

Otherwise, <header> is just info for the webbrowser, and <body> is what users see when they view the page, and your application doesn't care where the data is, as long as you tell it where to find it.

0

精彩评论

暂无评论...
验证码 换一张
取 消