php - Output from MySQL -


i have slight problem input , output mysql db. problem in 1 section of web page. when enter supplier's name in page through , recorded in mysql database. but, when use same name input form tracks information supplier, other table records first word of supplier's name, ex:

(data in suppliers table): name: abc co. ltd.
(data output after second form submission using supplier name):name: abc

i've attached schema 2 tables in question.

unfortunately whole name not being recorded in database. hope clear. please let me know can do. in advance!rtgs table:this second table, ie 1 takes input part of name.

supplier table: first table, 1 forms input rtgs table.

following code inputs data first table in post. form uses 'select' tag updates based on db entries second table.

<?php include ('navbar.php'); mysql_connect('localhost','username','password'); mysql_select_db(rtgs); ?> <html> <head>      <title>     </title>  </head> <body>     <center>     <div class="form">              <form action="ntxn.php" method="post">              <table>                     <tr>                             <td>supplier name:</td>                               <td>                                 <?php                                                                       echo "<select name='supplier'>";                                 $result = mysql_query("select supname supplier");                                 while ($row = mysql_fetch_assoc($result))                                                 {               echo "<option value=" . $row['supname'].">" . $row['supname'] ."</option>";                                                  }                                  echo "</select>";                                                                        ?>                             </td> <td><button><a style="text-decoration:none"href="newsup.php">add new?</a></button></td>                     </tr>                      <tr>                             <td>bill no. :</td>                             <td><input type ="text" name="billno"/></td>                     </tr>                      <tr>                             <td>bill date : </td>                             <td><input type="date" name="billdate"/></td>                     </tr>                      <tr>                             <td>bill amount : </td>                             <td><input type="text" name="billamt"/></td>                     </tr>                      <tr>                             <td>neft / rtgs no. :</td>                             <td><input type="text" name="rtgs"/></td>                     </tr>                      <tr>                             <td><input type="submit" name="submite" value="save"/></td>                     </tr>              </table>     </form>     </div>     </center> </body> </html> 


this code inputs data second table, ie, data in table used input 'select' tag shown above. problem that, though data in table 2 complete (abc co. ltd.), data in table 1 takes abc input. hope makes question clear. :)

<?php  include ('navbar.php');  mysql_connect('localhost', 'username', 'password'); mysql_select_db(rtgs);  $result = mysql_query("insert supplier values          (null,'$_post[supname]','$_post[add1]','$_post[add2]','$_post[tin]',         '$_post[ed]','$_post[ph]','$_post[email]')");   if(!$result){     echo "could not add entry database" . mysql_error(); }  else {        echo "<center>";     echo "supplier added successfully!";     echo "<center>"; }  echo "<center>";  echo "what next?"; echo "<br/>"; echo "<br/>";  echo "<button><a style='text-decoration:none' href=index.html>home</a></button>"; echo "<button><a style='text-decoration:none' href=newsup.php>add another</a>/button>"; echo "<button><a style='text-decoration:none' href=newtxn.php>new txn</a></button>";  echo "</center>";  ?> 

the option elements missing double quotes around value attribute:

echo "<option value=" . $row['supname'].">" . $row['supname'] ."</option>"; 

should be:

echo '<option value="' . $row['supname'] . '">' . $row['supname'] . '</option>'; 

since supname string not delimited quotes, browser posts first word (until first space, assuming next word other attribute).


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -