Jump to content

Recommended Posts

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 :P

 

ok well it didnt seem to work. i think i did everything you said to.

 

here's a screen of my terminal:

term.jpg

 

and here's my pastebin:

http://pastebin.com/m5744715a

 

see something wrong?

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){

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

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

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 :P 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)?

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

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 :P ill most likely be back to bother you guys again

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.