Re: Beginner javascript newbie - wants to learn some basics - display results from php query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Swap the print_r for an echo. Using print_r will not give you a valid JSON
object.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

On Sat, 2 May 2015 at 21:48 dealTek <dealtek@xxxxxxxxx> wrote:

> [OFF TOPIC]
>
> Hi all,
>
> I know this is not a javascript forum - but could use some basic
> javascript beginner help or URL's to get started...
>
>
> Beginner javascript newbie - wants to learn some basics - display results
> from php query
>
>
> example...
> Q: If I request just a single record result - like query ends with -
> print_r (json_encode($output));
>  how can I display various fields at different areas of the page using
> javascript query result?
> With php I can display a field output like:
>
> html ...
> html ...
> <?php echo $record->getField('FirstName'); ?>
> html ....
> html ...
>
> Q: So how do I convert the PHP query result - print_r
> (json_encode($output)); -  to place php field results randomly where I want
> mixed in with html?
>
>
> First Name is: <?php echo $record->getField('FirstName'); ?> <br />
>
> - ?CAN I JUST PUT FirstName here using javascript not php like ...
> <???JAVASCRIPT field ???> FirstName <???/JAVASCRIPT ???>
>
> Last Name is: <?php echo $record->getField('FirstName'); ?><br />
>
> Phone is: <?php echo $record->getField('Phone'); ?><br />
>
> Street is: <?php echo $record->getField('Street'); ?><br />
>
> etc.
>
>
>
> =================
>
>
>
> WHAT I HAVE in javascript - works but it forces me to put the html inside
> the script so whole thing inside ...........
>
>
> <script>
> $(document).ready(function(){
>     $("button").click(function(){
>         $.get("getstuff.php", function(data, status){
>             // alert("Data: " + data + "\nStatus: " + status);
>             console.log ('data', data);
>             output = "";
>
>             $.each(data, function(key, value) {
>                 console. log ('item', key, value);
>                         output += " Name is: " + value.FirstName + " " +
> value.LastName + "<br>";
>                         });
>             $('#list').html( output );
>             $('#list').listview( "refresh" );
>         });
>     });
> });
> </script>
>
>
>
>
>
>
>
>
> --
> Thanks,
> Dave - DealTek
> dealtek@xxxxxxxxx
> [db-15]
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux