php - Inserting specific values into a DB, and displaying it on a table? -


i'm trying insert specific values(knife, , blanket) database, but's not inserting db/table @ all. also, want display inserted values in table below, , not working well. dependant on insert show on table. sure, because inserted value through phpmyadmin, , displayed on table. please, need fix insert aspect.

the insert code/error handler

<?php if (isset($_post['collect'])) { if(($_post['object'])!= "knife" && ($_post['object'])!= "blanket") {   echo "this isn't among room objects."; }else { // makes sure uses sign have own names $sql = "select id objects object='".mysql_real_escape_string($_post['object'])."'"; $query = mysql_query($sql) or die(mysql_error()); $m_count = mysql_num_rows($query);   if($m_count >= "1"){     echo 'this object has been taken.!';     } else{    $sql="insert objects (object) values ('$_post[object]')";  echo "".$_post['object']." added"; } }  }   ?> 

table plus php code

<p> <form method="post"> </form> pick object: <input name="object" type="text" />   <input class="auto-style1" name="collect" type="submit" value="collect" /> </p>  <table width="50%" border="2" cellspacing="1" cellpadding="0">       <tr align="center">         <td colspan="3">player&#39;s object</td>       </tr>       <tr align="center">         <td>id</td>         <td>object</td>       </tr>       <? $result = mysql_query("select * objects") or die(mysql_error()); // keeps getting next row until there no more     while($row = mysql_fetch_array( $result )) { // print out contents of each row table?>       <tr>        <td><label for="<?php echo $row['id']; ?>"><?php     $name2=$row['id'];     echo "$name2"; ?>     </label></td>         <td><? echo $row['object'] ?></td>       </tr>         <?php }// while loop ?>     </table>  </body> 

if(($_post['object'])!= knife || ($_post['object'])!= blanket) 

these value knife , blanket string. may need use quotes around them define them string, or php won't understand ;)


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -