Jump to content

Self_Taught_Still_Learning

Members
  • Posts

    10
  • Joined

  • Last visited

Self_Taught_Still_Learning's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've got 2 rows in a database table for 2 different accounts, each time an account changes page, the time changes in the database and is recorded. I want to display both accounts side by side and have it pull that time running through a function to convert it into time gone by but have it refresh every 2-5 seconds without needing to keep refreshing the page manually. So on first load, user 1 and user 2 will be on 00s for example if both have just moved, then on next refresh user 2 hasn't moved but user 1 has so it would display user 1 as 00s and user 2 as 02s
  2. So it's to compare 2 figures simultaneously. Value 1 = Time Value 2 = Time Both times are constantly changing yes. <table> <tr> <td>Name 1</td><td>Name 2</td> </tr> <tr> <td>Time 1</td><td>Time 2</td> </tr> </table> So the times above would be pulled from the database and updated every 2-5 seconds
  3. Hi, thanks for taking the time to read this. Probably pretty basic for most but i'm struggling even after watching videos and reading different forum posts. Here is what i am trying to do. I want to watch some data without the need to refreshing the page. The database stores the data using time() and then runs through a time function to convert it to a seconds and minute output(examples "00s"/"13m 44s"). I need to pull this and have it refresh automatically and been told due to how basic this is i should be able to do it in javascript using fetch() but i am struggling to get pages talking and just completely confused how to pull the data in php and then pull using javascript. Any advise would be greatly appreciated as well as and examples and explanations on why you are doing what you are.
  4. It works perfectly if i repeat the num code again and run the fetch from a seperate file instead of both from the same and also i had to change the way it was adding things to the database. I had to change the code to: $sql = "UPDATE feeds SET quantity=quantity-:quantity WHERE code=:code"; $q = $db->prepare($sql); $q->execute(array(':quantity'=>$quantity, ':code'=>$code)); What's the difference between binding and what i am currently using?
  5. $sqld = "SELECT * FROM orders WHERE `id`='$delete' AND `name`='$inf2[name]' AND `email`='$inf2[email]' LIMIT 1"; $csql = $db->query($sqld); $ccheck = $csql->fetch(PDO::FETCH_NUM); $cinf = $csql->fetch(PDO::FETCH_ASSOC); $quantity = $cinf[quantity]; $code = $cinf[code]; $stmt11 = $db->prepare('UPDATE feeds SET quantity=quantity-:quantity WHERE code=:code'); $stmt11->bindValue(':quantity', $quantity, PDO::PARAM_STR); $stmt11->bindValue(':code', $code, PDO::PARAM_STR); $stmt11->execute(); $id = $delete; $name = $inf2[name]; $stmt2 = $db->prepare("DELETE FROM orders WHERE id=:id AND name=:name"); $stmt2->bindValue(':id', $id, PDO::PARAM_STR); $stmt2->bindValue(':name', $name, PDO::PARAM_STR); $stmt2->execute(); OK, i have just been told i should start using PDO instead of mysql to update my tables. This code works to delete the order but doesn't update the feeds section. All this is new to me so far and i think i am getting the hang of it. Should i still be using the quantity=quantity-:quantity or is there another way to do it with PDO? Sorry, i posted this in the wrong forum. Hope someone here can help until it's moved
  6. This is what i'm using currently $select = mysql_query("SELECT * FROM `table` ORDER by `name`"); while ($i = mysql_fetch_object($select)){ //Orders via name but each time its in a new row. } I want to be able to group the name together and just show the items that person has order in on row.
  7. <table> <tr><td colspan=5>Table</td></tr> <tr><td>Name</td><td>Contact</td><td>Code</td><td>Type</td><td>Price</td><td>Quantity</td></tr> <tr><td>Name 1</td><td>xxxxxxxx</td><td>GTH1</td><td>Food</td><td>£10</td><td>2</td></tr> <tr><td>Name 1</td><td>xxxxxxxx</td><td>GTH2</td><td>Food</td><td>£10</td><td>2</td></tr> <tr><td>Name 1</td><td>xxxxxxxx</td><td>GTH3</td><td>Food</td><td>£10</td><td>2</td></tr> <tr><td>Name 2</td><td>xxxxxxxx</td><td>GTH1</td><td>Food</td><td>£10</td><td>2</td></tr> <tr><td>Name 2</td><td>xxxxxxxx</td><td>GTH3</td><td>Food</td><td>£10</td><td>2</td></tr> <tr><td>Name 3</td><td>xxxxxxxx</td><td>GTH2</td><td>Food</td><td>£10</td><td>2</td></tr> </table> What i want is to be able to pull all data needed for each name in on go like <table> <tr><td colspan=5>Table</td></tr> <tr><td>Name</td><td>Contact</td><td>Code</td><td>Type</td><td>Price</td><td>Quantity</td></tr> <tr><td colspan=1>Name 1</td><td colspan=1>xxxxxxxx</td><td colspan=3>GTH1 x 2<br>GHT2 x 2<br>GHT3 x 2<br>Total Price: £30.</td></tr> <tr><td colspan=1>Name 2</td><td colspan=1>xxxxxxxx</td><td colspan=3>GTH1 x 2<br>GHT2 x 2<br>Total Price: £20.</td></tr> <tr><td colspan=1>Name 3</td><td colspan=1>xxxxxxxx</td><td colspan=3>GTH1 x 2<br>Total Price: £10.</td></tr> </table>
  8. Ok, so in a database table i have: name contact code type price quantity Name 1 xxxxxxxxx GHT3 Food £10.50 2 Name 1 xxxxxxxxx GHTd Food £10.30 2 Name 1 xxxxxxxxx GHTs Food £10.90 2 Name 2 xxxxxxxxx GHT3 Food £10.50 2 Name 3 xxxxxxxxx GHTs Food £10.50 2 Name 3 xxxxxxxxx GHTd Food £10.50 2 I want them to read on another page like this: Name Contact Code Type Quantity Name 1 xxxxxxxxxx GHT3 Food 2 GHTd Food 2 GHTs Food 2 Total Price: £xx.xx Name 2 xxxxxxxxxx GHT3 Food 2 Total Price: £xx.xx Name 3 xxxxxxxxxx GHTs Food 2 GHTd Food 2 Total Price: £xx.xx So it only reads the name and number once but puts in the whole of what they are after. Hope someone understands this and can lend some help. Don't need the table doing just need to know the sql i would need to use. <table> <tr><td colspan=5>Table</td></tr> <tr><td>Name</td><td>Contact</td><td>Code</td><td>Type</td><td>Price</td><td>Quantity</td></tr> <tr><td>Name 1</td><td>xxxxxxxx</td><td>GTH1</td><td>Food</td><td>£10</td><td>2</td></tr> <tr><td>Name 1</td><td>xxxxxxxx</td><td>GTH2</td><td>Food</td><td>£10</td><td>2</td></tr> <tr><td>Name 1</td><td>xxxxxxxx</td><td>GTH3</td><td>Food</td><td>£10</td><td>2</td></tr> <tr><td>Name 2</td><td>xxxxxxxx</td><td>GTH1</td><td>Food</td><td>£10</td><td>2</td></tr> <tr><td>Name 2</td><td>xxxxxxxx</td><td>GTH3</td><td>Food</td><td>£10</td><td>2</td></tr> <tr><td>Name 3</td><td>xxxxxxxx</td><td>GTH2</td><td>Food</td><td>£10</td><td>2</td></tr> </table> What i want is to be able to pull all data needed for each name in on go like <table> <tr><td colspan=5>Table</td></tr> <tr><td>Name</td><td>Contact</td><td>Code</td><td>Type</td><td>Price</td><td>Quantity</td></tr> <tr><td colspan=1>Name 1</td><td colspan=1>xxxxxxxx</td><td colspan=3>GTH1 x 2<br>GHT2 x 2<br>GHT3 x 2<br>Total Price: £30.</td></tr> <tr><td colspan=1>Name 2</td><td colspan=1>xxxxxxxx</td><td colspan=3>GTH1 x 2<br>GHT2 x 2<br>Total Price: £20.</td></tr> <tr><td colspan=1>Name 3</td><td colspan=1>xxxxxxxx</td><td colspan=3>GTH1 x 2<br>Total Price: £10.</td></tr> </table>
  9. Ok, so in a database table i have: name contact code type price quantity Name 1 xxxxxxxxx GHT3 Food £10.50 2 Name 1 xxxxxxxxx GHTd Food £10.30 2 Name 1 xxxxxxxxx GHTs Food £10.90 2 Name 2 xxxxxxxxx GHT3 Food £10.50 2 Name 3 xxxxxxxxx GHTs Food £10.50 2 Name 3 xxxxxxxxx GHTd Food £10.50 2 I want them to read on another page like this: Name Contact Code Type Quantity Name 1 xxxxxxxxxx GHT3 Food 2 GHTd Food 2 GHTs Food 2 Total Price: £xx.xx Name 2 xxxxxxxxxx GHT3 Food 2 Total Price: £xx.xx Name 3 xxxxxxxxxx GHTs Food 2 GHTd Food 2 Total Price: £xx.xx So it only reads the name and number once but puts in the whole of what they are after. Hope someone understands this and can lend some help. Don't need the table doing just need to know the sql i would need to use.
×
×
  • 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.