php json从数据库mysql获取json vlaue [英] php json getting json vlaue from database mysql

查看:71
本文介绍了php json从数据库mysql获取json vlaue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我的代码来自此链接



问题是我无法在json中设置while循环,因为我没有我的dea如何在这里是我的整个代码





hi ihave a code that came from this link

the problem is i cannot set the while loop inside the json because i don't have an i dea on how to here's my whole code


<!doctype html>
<html lang="en" >
<head>
    <meta charset="UTF-8">
    <title>Agile Carousel Multiple Slides Visible example</title>
    <meta name="description" content="Agile Carousel javascript jquery image gallery">
    <meta name="keywords"    content="Agile Carousel javascript jquery image gallery">



<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.js"></script>
<link rel="stylesheet" href="agile_carousel.css">
<script src="agile_carousel.alpha.js"></script>

<script>

    $.getJSON("agile_carousel_data.php", function (data) {

        $("#multiple_slides_visible").agile_carousel({
            carousel_data: data,
            carousel_outer_height: 230,
            carousel_height      : 200,
            slide_height         : 200,
            carousel_outer_width : 480,
            slide_width          : 260,
            number_slides_visible: 3,
            transition_time      : 330,
            control_set_1: "previous_button,next_button",
            control_set_2: "group_numbered_buttons",
            persistent_content: "<p class='persistent_content'>Agile Carousel Example: Multiple Slides Visible</p>"
        });

    })

 </script>

</head>
<body>

    <a href="http://krablekod.ru" > home</a>
    <br />
    <a href="../index.html" > back </a>
    <br />
    <a href="http://demo1.krablekod.ru/files/archives/agile_carousel_examples.tar" > Agile Carousel examples example </a>

    <div class="slideshow_wrapper">
        <div class="slideshow_title">Multiple Slides Visible</div>
        <div class="slideshow_wrapper slideshow_wrapper_right">
            <div class="slideshow" id="multiple_slides_visible"></div>
            <div class="slideshow_description">
                <ul class="slideshow_features">
                    <li>3 Slides Visible</li>
                    <li>Circle Buttons</li>
                </ul>
            </div>
        </div>
    </div>

</body>







这里是我的agile_carousel_data.php数据代码








and here's my code for the data for agile_carousel_data.php


[
            {
                  "content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='banner_bike.jpg' alt='Bike'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>",
                  "content_button": "<div class='thumb'><img src='f2_thumb.jpg' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"
            },
            {
                  "content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='banner_paint.jpg' alt='Paint'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>",
                  "content_button": "<div class='thumb'><img src='f2_thumb.jpg' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"
            },
            {
                  "content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='banner_bike.jpg' alt='Bike'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>",
                  "content_button": "<div class='thumb'><img src='f2_thumb.jpg' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"
            },
            {
                  "content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='banner_paint.jpg' alt='Paint'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>",
                  "content_button": "<div class='thumb'><img src='f2_thumb.jpg' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"
            },
            {
                  "content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='banner_bike.jpg' alt='Bike'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>",
                  "content_button": "<div class='thumb'><img src='f2_thumb.jpg' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"
            },
            {
                  "content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='banner_paint.jpg' alt='Paint'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>",
                  "content_button": "<div class='thumb'><img src='f2_thumb.jpg' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"
            },
            {
                  "content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='banner_tunnel.jpg' alt='Tunnel'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>",
                  "content_button": "<div class='thumb'><img src='f2_thumb.jpg' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"
            }
            ]







and here’s my while loop the original adatabase






and here's my while loop the original adatabase

<?php
include_once('includes/dbConnect.php');
?>

<?php
$query=mysql_query("select * from persons order by rand()");





$data = array();

while ($test = mysql_fetcharray($query)){





$data = array();
while ($test = mysql_fetcharray($query)){

<?php
include_once('includes/dbConnect.php');
?>


$query=mysql_query("select * from persons order by rand()");



<img height=200 width=200 src=’upload/\". $test[’Image’] .\"’/> //for the image

\".$test[’LastName’].\", \". $test[’FirstName’].\" \". $test[’MiddleName’].\" // for the contents



my code is working but how to convert it to json? so that the other script can get this? how can i make this json?


<img height=200 width=200 src='upload/". $test['Image'] ."'/> //for the image
".$test['LastName'].", ". $test['FirstName']." ". $test['MiddleName']." // for the contents

my code is working but how to convert it to json? so that the other script can get this? how can i make this json?

推荐答案

.getJSON(\"agile_carousel_data.php\", function (data) {
.getJSON("agile_carousel_data.php", function (data) {


(\"#multiple_slides_visible\").agile_carousel({
carousel_data: data,
carousel_outer_height: 230,
carousel_height : 200,
slide_height : 200,
carousel_outer_width : 480,
slide_width : 260,
number_slides_visible: 3,
transition_time : 330,
control_set_1: \"previous_button,next_button\",
control_set_2: \"group_numbered_buttons\",
persistent_content: \"<p class='persistent_content'> Agile Carousel Example: Multiple Slides Visible</p>\"
});

})

</script>

</head>
<body>

<a href=\"http://krablekod.ru\" > home</a>
<br < span class=\"code-keyword\">/>
<a href=\"../index.html\" > back </a>
<br />
<a href=\"http://demo1.krablekod.ru/files/archives/agile_car ousel_examples.tar\" > Agile Carousel examples example </a>

<div class=\"slideshow_wrapper\">
<div class=\"slideshow_title\">Multiple Slides Visible</div>
<div class=\"slideshow_wrapper slideshow_wrapper_right\">
<div class=\"slideshow\" id=\"multiple_slides_visible\"></div>
<div< span class=\"code-attribute\"> class=\"slideshow_description\">
<ul class=\"slideshow_features\">
<li>3 Slides Visible</li>
<li>Circle Buttons</li>
</ul>
</div>
</div>
</div>

</body>
("#multiple_slides_visible").agile_carousel({ carousel_data: data, carousel_outer_height: 230, carousel_height : 200, slide_height : 200, carousel_outer_width : 480, slide_width : 260, number_slides_visible: 3, transition_time : 330, control_set_1: "previous_button,next_button", control_set_2: "group_numbered_buttons", persistent_content: "<p class='persistent_content'>Agile Carousel Example: Multiple Slides Visible</p>" }); }) </script> </head> <body> <a href="http://krablekod.ru" > home</a> <br /> <a href="../index.html" > back </a> <br /> <a href="http://demo1.krablekod.ru/files/archives/agile_carousel_examples.tar" > Agile Carousel examples example </a> <div class="slideshow_wrapper"> <div class="slideshow_title">Multiple Slides Visible</div> <div class="slideshow_wrapper slideshow_wrapper_right"> <div class="slideshow" id="multiple_slides_visible"></div> <div class="slideshow_description"> <ul class="slideshow_features"> <li>3 Slides Visible</li> <li>Circle Buttons</li> </ul> </div> </div> </div> </body>







and here’s my code for the data for agile_carousel_data.php








and here's my code for the data for agile_carousel_data.php


[
            {
                  "content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='banner_bike.jpg' alt='Bike'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>",
                  "content_button": "<div class='thumb'><img src='f2_thumb.jpg' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"
            },
            {
                  "content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='banner_paint.jpg' alt='Paint'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>",
                  "content_button": "<div class='thumb'><img src='f2_thumb.jpg' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"
            },
            {
                  "content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='banner_bike.jpg' alt='Bike'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>",
                  "content_button": "<div class='thumb'><img src='f2_thumb.jpg' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"
            },
            {
                  "content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='banner_paint.jpg' alt='Paint'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>",
                  "content_button": "<div class='thumb'><img src='f2_thumb.jpg' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"
            },
            {
                  "content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='banner_bike.jpg' alt='Bike'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>",
                  "content_button": "<div class='thumb'><img src='f2_thumb.jpg' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"
            },
            {
                  "content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='banner_paint.jpg' alt='Paint'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>",
                  "content_button": "<div class='thumb'><img src='f2_thumb.jpg' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"
            },
            {
                  "content": "<div class='slide_inner'><a class='photo_link' href='#'><img class='photo' src='banner_tunnel.jpg' alt='Tunnel'></a><a class='caption' href='#'>Sample Carousel Pic Goes Here And The Best Part is that...</a></div>",
                  "content_button": "<div class='thumb'><img src='f2_thumb.jpg' alt='bike is nice'></div><p>Agile Carousel Place Holder</p>"
            }
            ]







and here’s my while loop the original adatabase






and here's my while loop the original adatabase

<?php
include_once('includes/dbConnect.php');
?>

<?php


query=mysql_query(\"select * from persons order by rand()\");
query=mysql_query("select * from persons order by rand()");







这篇关于php json从数据库mysql获取json vlaue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆