Jump to content

HelpMe1985

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

HelpMe1985's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hi i want to format the out put from my database in a table to 2 decimal places e.g. 6.70 ive found that this code dose what i want to do printf ("%01.2f", $variable); but im having trouble fitting it into my code within the table echo "<td><center>£" . $row['WeeklyCharge'] . "</td>"; how do i fit that in so WeeklyCharge will display in the table to two decimal places. Every time i try i get an error. Any help would be great or if anyone knows of a better way i could look at doing it?
  2. you can post stuff over from other pages if thats what your getting at ?
  3. LINE 159 is the query this line: mysql_query("UPDATE accounts SET WeeklyCharge = '$deTotal' WHERE CustomerID='2'", $con) or die('Error: '.mysql_error());
  4. hi, i tried changing it to mysql_query("UPDATE accounts SET WeeklyCharge = '".$deTotal."' WHERE CustomerID='2'", $con) or die('Error: '.mysql_error()); and i still get the same erorr Are you saying i need to change this $deTotal=$weeklyTotal+0.70;
  5. hi, i am trying to UPDATE a table accounts with a php variable i have created but i keep getting an error "Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\wamp1\www\test5\balance.php on line 159 Error:" this is the out put i get : Weekly Total=6.00 Weekly Total + Delivery Charge=6.70 Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\wamp1\www\test5\balance.php on line 159 Error: This is my code : echo "<br>"; echo "Weekly Total="; $weeklyTotal=$dailyTotal+$satTotal+$sunTotal; printf ("%01.2f", $weeklyTotal); echo "<br>"; echo "Weekly Total + Delivery Charge="; $deTotal=$weeklyTotal+0.70; printf ("%01.2f", $deTotal); mysql_query("UPDATE accounts SET WeeklyCharge = '$deTotal' WHERE CustomerID='2'", $con) or die('Error: '.mysql_error());
  6. <html> <h2>Search</h2> <form name="search" method="post" action="<?php=$PHP_SELF?>"> Seach for: <input type="text" name="find" /> <Select NAME="field"> <Option VALUE="fname">surname</option> <Option VALUE="lname">forname</option> <Option VALUE="info">postcode</option> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form> <?php //if they have submitted the form if ($_POST['searching'] == "yes") { echo "<h2>Results</h2><p>"; //did not enter a search term we give an error if ($find == "") { echo "<p>You forgot to enter a search term"; exit; } // connect to our Database mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("randv") or die(mysql_error()); // preform filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //Now we search the table and filed $data = mysql_query("SELECT * FROM customers WHERE upper($field) LIKE'%$find%'"); //display the results echo "<table width=90% align=center border=1><tr>"; while($result = mysql_fetch_array( $data )) { $surname = $row["surname"]; $forename = $row["forename"]; $addressLine1 = $row["addressLine1"]; $addressLine2 = $row["addressLine2"]; $postcode = $row["postcode"]; echo "<tr> <td>$surname</td> <td>$forname</td> <td>$addressLine1</td> <td>$addressLine2</td> <td>$postcode</td></tr> <tr></td> </tr></table>"; } //This counts the number or results $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match the search<br><br>"; } //what was searched for echo "<b>Searched For:</b> " .$find; } ?> </html>
×
×
  • 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.