Jump to content

badgerchap

Members
  • Posts

    7
  • Joined

  • Last visited

badgerchap's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. You're a star, would never have picked that up myself. Many thanks! Yeah, you were right about the !==, have change it to > and it's just fine now. Many thanks!
  2. This is a pretty simple bit of code, taken from a template on w3schools.com. For some reason though, it doesn't clear my table. I've tried exactly the same but with TRUNCATE TABLE. It's not the $ipaddress as the table name, as a) that works fine with other commands elsewhere in my site and b) I've tried the same commands with a simpler table name. I've messed around with this now and I'm out of ideas! No error is being returned, and to all intents and purposes it seems as if the command has gone through, but the table remains resolutely full of data :/ Any help please? Thanks in advance. <?php $con=mysqli_connect("*********","*****","*****","*********"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $ipaddress=$_SERVER["REMOTE_ADDR"]; mysql_query($con,"DELETE FROM `".$ipaddress"` WHERE Quantity!=='0'"); mysqli_close($con); ?>
  3. Think I've marked it as such. Thanks also ginerjm, will try that too after dinner
  4. Excellent! It works a treat, thank you so much! My only problem is that it puts it in a really weird position, but I should be able to solve that by myself. Thanks insidus, you've fixed a real head-bender!
  5. Excellent, I will have a fiddle Many thanks. I will report back!
  6. I haven't put the sum in, because so far I've drawn a complete blank! As for bad practice - c'mon, it's my first day!
  7. Sorry guys, I imagine this is as simple as simple can be. I've only delved into PHP since this morning, and whilst it's actually gone pretty well so far, I'm absolutely stumped with the simplest of tasks. Here is my snippet: <?php $con=mysqli_connect("blahblahblah....."); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result = mysqli_query($con,"SELECT * FROM Basket"); echo "<table border='1'> <tr> <th>Product</th> <th>Quantity</th> <th>Price (£)</th> </tr>"; while($column = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $column['Product'] . "</td>"; echo "<td>" . $column['Quantity'] . "</td>"; echo "<td>" . $column['Price'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?> This is displaying the contents of a user's basket, and it's doing so just fine, with Product, Quantity and Price column being displayed perfectly. What I can't do, no matter how many of other people's snippets I try and tinker with and fit into my code, I just cannot get a total price for the basket to display. I'm sure there is a simple solution, I just can't work it out myself right now! Any help greatly appreciated, many Thanks, Badgerchap
×
×
  • 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.