FaT3oYCG Posted March 22, 2009 Share Posted March 22, 2009 is stock the actual feild inside the stock table, because if anything i would change that to quantity and try again and see what happens Quote Link to comment https://forums.phpfreaks.com/topic/150577-solved-need-some-help-with-phpmysql-bookstore/page/2/#findComment-791089 Share on other sites More sharing options...
sstoveld Posted March 22, 2009 Author Share Posted March 22, 2009 is stock the actual feild inside the stock table, because if anything i would change that to quantity and try again and see what happens yes it is. ill change it and see what happens Quote Link to comment https://forums.phpfreaks.com/topic/150577-solved-need-some-help-with-phpmysql-bookstore/page/2/#findComment-791090 Share on other sites More sharing options...
FaT3oYCG Posted March 22, 2009 Share Posted March 22, 2009 ok well i hope that works otherwise i will have to find something else if its wrong and there cant possibly be thet much more to do before this all works perfectly Quote Link to comment https://forums.phpfreaks.com/topic/150577-solved-need-some-help-with-phpmysql-bookstore/page/2/#findComment-791094 Share on other sites More sharing options...
sstoveld Posted March 22, 2009 Author Share Posted March 22, 2009 ok well i hope that works otherwise i will have to find something else if its wrong and there cant possibly be thet much more to do before this all works perfectly  haha lets hope so  ok well it didnt seem to work. i think i did everything you said to.  here's a screen of my terminal:  and here's my pastebin: http://pastebin.com/m5744715a  see something wrong? Quote Link to comment https://forums.phpfreaks.com/topic/150577-solved-need-some-help-with-phpmysql-bookstore/page/2/#findComment-791106 Share on other sites More sharing options...
FaT3oYCG Posted March 22, 2009 Share Posted March 22, 2009 change $sql = "UPDATE stock SET quantity = quantity - 1 WHERE stock_id = '$id'"; if (!mysql_query($sql)){ Â to echo('submit working'); $sql = "UPDATE stock SET quantity = quantity - 1 WHERE stock_id = '$id'"; $result = mysql_query($sql) if (!$result){ Quote Link to comment https://forums.phpfreaks.com/topic/150577-solved-need-some-help-with-phpmysql-bookstore/page/2/#findComment-791110 Share on other sites More sharing options...
sstoveld Posted March 22, 2009 Author Share Posted March 22, 2009 change $sql = "UPDATE stock SET quantity = quantity - 1 WHERE stock_id = '$id'"; if (!mysql_query($sql)){ Â to echo('submit working'); $sql = "UPDATE stock SET quantity = quantity - 1 WHERE stock_id = '$id'"; $result = mysql_query($sql) if (!$result){ Â getting a parse error line 38 Â http://pastebin.com/m2b56cc81 Â Parse error: parse error, unexpected T_IF in /Users/dbase18/Sites/bookstore/index.php on line 38 Quote Link to comment https://forums.phpfreaks.com/topic/150577-solved-need-some-help-with-phpmysql-bookstore/page/2/#findComment-791115 Share on other sites More sharing options...
Philip Posted March 22, 2009 Share Posted March 22, 2009 Missing semicolon, line above ($result = mysql_query($sql)) Quote Link to comment https://forums.phpfreaks.com/topic/150577-solved-need-some-help-with-phpmysql-bookstore/page/2/#findComment-791117 Share on other sites More sharing options...
FaT3oYCG Posted March 22, 2009 Share Posted March 22, 2009 finally your form is wrong aswell lol didnt spot that  replace <table> <tr> <td><strong>Title</strong></td> <td><strong>Stock</strong></td> <td><strong>Price</strong></td> </tr> <?php /////////// RESULTS OF QUERY AND PUBLISH TO TABLE /////////// while ($row = mysql_fetch_array($queryresult)){ echo '<tr><td>'.$row['title'].'</td><td>'.$row['quantity'].'</td><td>'.$row['price'].'</td><td><input type="radio" name="'.$row['title'].'" value="'.$row['stock_id'].'"></td></tr>'; } ?> </table> <p> <form name="submit" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> <input type="submit" value="Submit" name="submit" /> </form> </p>  with <p>  <form name="submit" action="<?php echo($_SERVER["PHP_SELF"]); ?>" method="post">    <table>     <tr>       <td><strong>Title</strong></td>       <td><strong>Stock</strong></td>       <td><strong>Price</strong></td>     </tr>     <?php       while ($row = mysql_fetch_array($queryresult))       {        echo('<tr><td>' . $row['title'] . '</td><td>' . $row['quantity'] . '</td><td>' . $row['price'] . '</td><td><input type="radio" name="stock_id" value="' . $row['stock_id'] . '"></td></tr>');       }     ?>     <input type="submit" value="Submit" name="submit" />    </form>  </table> </p>  p.s. soz bout missin off the semi-colon XD Quote Link to comment https://forums.phpfreaks.com/topic/150577-solved-need-some-help-with-phpmysql-bookstore/page/2/#findComment-791122 Share on other sites More sharing options...
sstoveld Posted March 22, 2009 Author Share Posted March 22, 2009 Missing semicolon, line above ($result = mysql_query($sql)) thanks, found and fixed Quote Link to comment https://forums.phpfreaks.com/topic/150577-solved-need-some-help-with-phpmysql-bookstore/page/2/#findComment-791123 Share on other sites More sharing options...
sstoveld Posted March 22, 2009 Author Share Posted March 22, 2009 finally your form is wrong aswell lol didnt spot that  replace <table> <tr> <td><strong>Title</strong></td> <td><strong>Stock</strong></td> <td><strong>Price</strong></td> </tr> <?php /////////// RESULTS OF QUERY AND PUBLISH TO TABLE /////////// while ($row = mysql_fetch_array($queryresult)){ echo '<tr><td>'.$row['title'].'</td><td>'.$row['quantity'].'</td><td>'.$row['price'].'</td><td><input type="radio" name="'.$row['title'].'" value="'.$row['stock_id'].'"></td></tr>'; } ?> </table> <p> <form name="submit" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> <input type="submit" value="Submit" name="submit" /> </form> </p>  with <p>  <form name="submit" action="<?php echo($_SERVER["PHP_SELF"]); ?>" method="post">    <table>     <tr>       <td><strong>Title</strong></td>       <td><strong>Stock</strong></td>       <td><strong>Price</strong></td>     </tr>     <?php       while ($row = mysql_fetch_array($queryresult))       {        echo('<tr><td>' . $row['title'] . '</td><td>' . $row['quantity'] . '</td><td>' . $row['price'] . '</td><td><input type="radio" name="stock_id" value="' . $row['stock_id'] . '"></td></tr>');       }     ?>     <input type="submit" value="Submit" name="submit" />    </form>  </table> </p>  p.s. soz bout missin off the semi-colon XD  OMG YES! it works! hahah thanks so much  it works now, but my submit button is floating above the table lol. i had that problem earlier so i moved the form action stuff below where it was. i guess that was a bad idea how do i get the submit button below the table?  also have another question..., how do i make the radio button not show up there if the quantity is at 0 (so the user cant make it go to -1)? Quote Link to comment https://forums.phpfreaks.com/topic/150577-solved-need-some-help-with-phpmysql-bookstore/page/2/#findComment-791125 Share on other sites More sharing options...
FaT3oYCG Posted March 22, 2009 Share Posted March 22, 2009 lol almost done hehe  <p>  <form name="submit" action="<?php echo($_SERVER["PHP_SELF"]); ?>" method="post">    <table>     <tr>       <td><strong>Title</strong></td>       <td><strong>Stock</strong></td>       <td><strong>Price</strong></td>       </tr>       <?php        while ($row = mysql_fetch_array($queryresult))        {          if($row['quantity'] > 0)          {           echo('<tr><td>' . $row['title'] . '</td><td>' . $row['quantity'] . '</td><td>' . $row['price'] . '</td><td><input type="radio" name="stock_id" value="' . $row['stock_id'] . '"></td></tr>');          }else{           echo('<tr><td>' . $row['title'] . '</td><td>' . $row['quantity'] . '</td><td>' . $row['price'] . '</td><td>Out of Stock, Sorry.</td></tr>');          }        }       ?>     <tr><td><input type="submit" value="Submit" name="submit" /></td></tr>    </form>  </table> </p>  try that  p.s. could you link me to the page by any chance coz i would just like to see how it is looking and operating if not its ok im just curious lol Quote Link to comment https://forums.phpfreaks.com/topic/150577-solved-need-some-help-with-phpmysql-bookstore/page/2/#findComment-791126 Share on other sites More sharing options...
sstoveld Posted March 22, 2009 Author Share Posted March 22, 2009 lol almost done hehe  <p>  <form name="submit" action="<?php echo($_SERVER["PHP_SELF"]); ?>" method="post">    <table>     <tr>       <td><strong>Title</strong></td>       <td><strong>Stock</strong></td>       <td><strong>Price</strong></td>       </tr>       <?php        while ($row = mysql_fetch_array($queryresult))        {          if($row['quantity'] > 0)          {           echo('<tr><td>' . $row['title'] . '</td><td>' . $row['quantity'] . '</td><td>' . $row['price'] . '</td><td><input type="radio" name="stock_id" value="' . $row['stock_id'] . '"></td></tr>');          }else{           echo('<tr><td>' . $row['title'] . '</td><td>' . $row['quantity'] . '</td><td>' . $row['price'] . '</td><td>Out of Stock, Sorry.</td></tr>');          }        }       ?>     <tr><td><input type="submit" value="Submit" name="submit" /></td></tr>    </form>  </table> </p>  try that  p.s. could you link me to the page by any chance coz i would just like to see how it is looking and operating if not its ok im just curious lol  absolutely perfect! thanks so much. now i just gotta get the administration back end done ill most likely be back to bother you guys again Quote Link to comment https://forums.phpfreaks.com/topic/150577-solved-need-some-help-with-phpmysql-bookstore/page/2/#findComment-791133 Share on other sites More sharing options...
FaT3oYCG Posted March 22, 2009 Share Posted March 22, 2009 lol no probs glad i could help, this was actually a quite interesting problem to solve and it has helped me to learn what not to do some more aswell. Quote Link to comment https://forums.phpfreaks.com/topic/150577-solved-need-some-help-with-phpmysql-bookstore/page/2/#findComment-791135 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.