English 中文(简体)
找出错误的结果,造成我的错误吗?
原标题:Getting the wrong result in mysql?
  • 时间:2011-10-22 19:45:21
  •  标签:
  • php
  • mysql
  • sql

Hello i在S.A.R.R.R.A.R.R.R.I.A.A.R.A.R.R.I.A.A.R.A.R.M.A.R.M.A.R.M.M.A.M.A.M.A.M.A.M.M.A.M.A.M.M.在S.R.R.I.A.A.A.R.R.A.R.M.M.C.M.M.M.M.T.A.M.M.A.R.M.M.M.R.M.M.M.M.R.M.M.M.T.M.T.,在S.R.R.R.R.R.R.C.R.R.R.R.M.R.R.M.M.M.M.M.T.R.R.R.M.M.R.M.M.M.M.M.M.M.M.M.M.R.M.M.M.R

我对每一种结果都有一个提子,让用户了解他们想要的东西。 当他们报到提交文件时,Itoni想要提交信息并添加到数据库中。 但是,出于某种原因,当用户点击项目1时,它会把最后一个项目输入数据库,例如项目6? 因此,每6个县就有6个结果和1个提交国。 当用户报界提交第1号项目时,它提交第6号供某些回馈。

<form method="post" action="buydo.php">
                <label><br />
                <br />
                </label>
                <p>


                <?php   
    $sql = "SELECT * FROM sell
             ORDER BY Pokemon_level ASC";
    $res = mysql_query($sql) or die(mysql_error());

        while ($v = mysql_fetch_array($res)) {
            echo  
                <div class="auction_box">
                <img src="http://myrpg.net/new_rpg/ .$v[ Pokemon_pic ]. " width="100" height="100"><br/>
                &pound; .$v[ price ]. <br/>
                <label id="pokemonName .$v[ id ]. "> .$v[ pokemon_name ]. </label><br/>


                <label>Level  .$v[ Pokemon_level ]. </level><br/>
                <label>Exp  .$v[ exp ]. </level><br/>
                <label>Time Left: ;

                echo  </label>
                <br/>
                <input type="hidden" name="Name" value=" .$v[ pokemon_name ]. ">
                <input type="hidden" name="level" value=" .$v[ Pokemon_level ]. ">
                <input type="hidden" name="vid" value=" .$v[ id ]. ">
                <input type="hidden" name="price" value=" .$v[ price ]. ">
                <input type="hidden" name="exp" value=" .$v[ exp ]. ">


                <input type="submit" id=" .$v[ id ]. " class="buy_submit" value="Buy Now" /> </div> ;
        }

?>



                &nbsp;</p>
                <p>&nbsp;</p>
              </form>

That is the select with the submit buttons for each result. Then i insert the info they have chosen.

include  config.php ;
session_start() ;

$name = mysql_real_escape_string($_POST[ Name ]);
$Pokemon_level = mysql_real_escape_string($_POST[ level ]);
$idofpokemonsell = mysql_real_escape_string($_POST[ vid ]);
$price = mysql_real_escape_string($_POST[ price ]);
$exp = mysql_real_escape_string($_POST[ exp ]);


    $sql = "SELECT * FROM `users` WHERE `username` =  " . $_SESSION[ username ] . " ";
    $result = mysql_query($sql) or die(mysql_error());
    $values = mysql_fetch_array($result);


echo $values[ money ] ;




if ( $values[ money ] == $price ) {
    echo "Give them the pokemon yay";
}



if ( $values[ money ] > $price ) {

mysql_query("INSERT INTO `user_pokemon` (`pokemon`, `belongsto`, `exp`, `slot`, `level`) VALUES ( $name , " . $_SESSION[ username ] . " , $exp , 0 , $Pokemon_level )") or die(mysql_error());  

    echo "Your money is over";
}

如同一说,在新闻项目1-5中,插入项目6,即项目6的所有内容。

最佳回答

由于你以某种形式表现出来,最新的价值观是过时的。 通过将<代码><form>和</form> 标签在座标

问题回答

或试图用被点击的id子追踪,并填充被点击的暗地

这是因为你的html是错误的。 价值观已超出文字

基本上,你们必须选择:

  • render a form for each item
  • do it with a dropdown or radio buttons

有了第二种选择,如果你问我,你就更需要改写你的法典。 因此,你需要做些什么。

  1. Move the submit button out of the loop
  2. Only generate code with the id and labels like this: <option value=" .$v[ id ]. "/>YOUR LABEL</option>
  3. When the form is submitted, you have to retrieve the values corresponding to your the submitted id




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签