Jump to content

romio

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

romio's Achievements

Member

Member (2/5)

0

Reputation

  1. I know, but i thought if its possible having the result by using the number_format() only, thank you guys. i appreciate all your suggestions.
  2. My bad the records are saved in the table as follow: 100000.00 50000.00 1500.00 30.00 1.50 when i fetch the row from the table i echo it as follow: $p1 = number_format($row->p1,2); so the correct output is as follow: 300,000.00 50,000.00 1,500.00 30.00 1.50 Thanks
  3. i am developing a small application that a winner might won the following amount: if 5 numbers found then the prize is 100,000 Euro if 4 ..... prize is 50,000 Euro if 3 ..... prize is 1500 Euro if 2 ..... prize is 30 Euro if 1 ..... prize is 1,50 Euro 30 gets the trailing zeros bcoz its defined as float(10,2) even if i simply add 30 the trailing zeros will be added by MYSQL, and yes if you use only number_format() then 1,50 will be rounded up to 2.
  4. Hi, i need to store the following in my database: 500,000 50,000 1500 30 1,5 after some research i understood that i need a float type, so i defined the following float (10,2) the problem is that when i output the numbers: echo number_format($number,2); i get the following results: 200,000.00 50,000.00 1,500.00 30.00 1.50 i am not really happy with the output, is it possible to have sth like this: 200,000 50,000 1,500 30.00 1.50 Thanks in advance.
  5. I am trying to save in a cookies some products "id's" separated by "&", but for some reasons in my cookie it does display “%26” instead, why this happening? if(!isset($_COOKIE['mybasket'])){ $store_id = $store_id.'&'; setcookie("mybasket",$store_id); }else{ $all_store_id = explode("&", $_COOKIE['mybasket']); array_push($all_store_id, "$store_id&"); $all_store_id = implode($all_store_id); setcookie("mybasket","$all_store_id"); }
  6. This is my code which I use for my Login page, I would appreciate if anyone could tell me if its good enough, if not, then how can I improve it. [code] if ((isset($_POST['username'])) && (isset($_POST['username']))) {   $loginUsername = mysql_escape_string($_POST['username']);   $password = mysql_escape_string(md5($_POST['password']));   $checkaccess = "SELECT username,password FROM login WHERE username = '$loginUsername' AND password = '$password'";   $Login = mysql_query($checkaccess) or die(mysql_error());   $loginFoundUser = mysql_num_rows($Login); if ($loginFoundUser){ setcookie('Logged', 'True', time()+60*60); header('Location: index.php'); exit; }else{   $errorMessage = true; } } [/code]
  7. [!--quoteo(post=379588:date=Jun 3 2006, 05:12 AM:name=Zanjo)--][div class=\'quotetop\']QUOTE(Zanjo @ Jun 3 2006, 05:12 AM) [snapback]379588[/snapback][/div][div class=\'quotemain\'][!--quotec--] What exactly does the check box do? If it confirms it then just make one link goto delete.php?confirm=yes and go isset($_GET['confirm']). [/quote] Basically i am listing some rows from my database, next to each record the checkbox appear, if that check box is selected and the user clicks on the delete link then all checkboxes must be deleted.... [code]             while($row = mysql_fetch_array($query_posts))             {                 $name = $row['name'];                 $email = $row['email'];                 $message = $row['message'];                 $id = $row['user_id'];                 $length = 27;                                      if (strlen($message) <= $length)                     {                         $message = $message;                     }                     else                     {                     $message = substr($message, 0, $length) . "..";                     }                                  echo "<tr>                         <td width='25'  class='lign_3'><input type=checkbox name=cb[] value=$id></td>                         <td width='120' class='lign_3'>&nbsp;$current_date</td>                         <td width='150' class='lign_4'>&nbsp;<a href=\"javascript:popUp('popup.php?&id=$id')\" class='links'>$message</a></td>                         <td width='80'  class='lign_3'>$name</a></td>                         <td width='100' class='lign_3'>&nbsp;201.201.201.201</td>                         <td width='45'  class='lign_3'>P</td>                         <td width='45'  class='lign_3'>&nbsp;<a href='admin.php?select=7&id=$id' class='links'><img src='template/images/edit.gif' border='0' title='Edit Post'></a></td>                     </tr>";             } [/code]
  8. In the past i used to delete though the use of a form and a submit button, [code] $find = "SELECT * FROM countries order by ID"; $row= mysql_query($find); $num_rows = mysql_num_rows($row); if(isset($_POST["delete"])) {     for($i=0;$i<$num_rows;$i++)     {         $cb = $_POST['cb'];         $delete_records = $cb[$i];         $sql = "DELETE FROM countries WHERE ID=$delete_records";         $result = mysql_query($sql);     } } mysql_close(); [/code] [code] <td width='25'  class='lign_3'><input type=checkbox name=cb[] value=$id></td> [/code] But now i need to use a link instead of a submit button, How can I do that?
  9. [code] <td valign='top'>     <select name="copy1" multiple size='10'>          <?php         echo $list_countries = "SELECT * FROM languages_main ORDER BY id";         $query_list_countries = mysql_query($list_countries);         $num_rows = mysql_num_rows($query_list_countries);         while($row = mysql_fetch_array($query_list_countries))             {                 $id = $row['id'];                 $country_name = $row['lang_name'];                 echo "<option value='$id'>$country_name</option>";             }     ?>             </select> </td> <td valign='middle' align='center'>     <input type="button" name="right" value="&gt;&gt;" onClick="copySelectedOptions(document.forms[0]['copy1'],document.forms[0]['copy2'],false);return false;"><BR><BR>     <input type="button" name="right" value="&lt;&lt;" onClick="removeSelectedOptions(document.forms[0]['copy2']); return false;"><BR><BR> </td> <td>     <select name="copy2" multiple size=10></select><br /> </td> <tr>     <td><input type='submit' name='submit' value='Submit'></td> </tr> [/code] copy1 has 20 countries listed in it(static), copy2 will the be the second list box which will be filled when a user select a country from copy1, my question is how can I get all the selected item from copy2 in order to insert it into my table?
  10. I am building a little admin panel and I want to have the option of uploading sql file to restore the current database. I am not really sure how to do that, I did search for online tutorial but Ii couldn’t find any thing that might help, anyone knows a good link so I can get started and learn how to create my own restore database function
  11. [!--quoteo(post=363578:date=Apr 11 2006, 03:48 AM:name=shortj75)--][div class=\'quotetop\']QUOTE(shortj75 @ Apr 11 2006, 03:48 AM) [snapback]363578[/snapback][/div][div class=\'quotemain\'][!--quotec--] instead of this header("Location: $_SERVER[PHP_SELF]"); try something like this [code]    echo "<br /><br /><div align=center><span class='style2'>Error, Pleaes Enter The Correct Current Password</span></div><br />"; echo "<input type=button value=back onclick=window.location='yourformpage.php'>"; [/code] see how that works for you [/quote] in this way the refresh button will cause a problem ... user can still click on refresh.
  12. I use this code to allow the a user to change his/her User_Name and Password, the code works fine, i did have some problem with the refresh button so i added [code] header("Location: $_SERVER[PHP_SELF]"); [/code] to clear my cache to avoid the refresh button problem, but i do have a problem that i cant show my error msg incase the user input wrong Current_password, i have tried using $error variable and increase it by one and then check if the $error is <> 0 then output the error msg, but it didnt work, anyone got an idea to solve this? Thanks. [code] <?php require_once('include/config.inc.php'); session_start(); $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_POST['username'])) {          $loginUsername= $_POST['username'];       $password = md5($_POST['password']);       $new_password = md5($_POST['new_password']);       $get_records = "SELECT * FROM access where username = '$loginUsername'";       $query_change_password =  mysql_query($get_records);       $query_change_password_rows = mysql_num_rows($query_change_password);          if(!($query_change_password_rows))       {                     header("Location: $_SERVER[PHP_SELF]");       }           else           {               $update_password = "UPDATE access SET username = '$loginUsername', password = '$new_password' WHERE username = '$loginUsername'";               $update_password_query = mysql_query($update_password);               echo "<br /><br /><div align=center><span class='style2'>Your Password Has Been Changed Successfully, You will be Redirected Soon</span></div>";               echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"2; url=admin.php\">";           } } //    else //    { //        echo "<br /><br /><div align=center><span class='style2'>Error, Pleaes Enter The Correct Current Password</span></div>"; //    } ?>   [/code]
  13. the disable radion is always checked no matter what the value of $enabled would be: [code]    echo $enabled;    echo"       <table border='0' align=center cellspacing='0' cellpadding='0' width='100% height='100%'>       <tr>          <td>             <form name='' method='post' action='?sec=9&treeviewid=treeid&nodeid=$catID&product_id=$product_id' enctype='multipart/form-data'>                <table border='0' cellspacing='2' cellpadding='2' border='0' height='100%' align='center' width='95%'>                   <tr>                       <td height='20' colspan=3></td>                   </tr>                                          ......................................                                          ...................................... <td width='178'  class='style13' height='33'>&nbsp;Display:</td> <td width='413' class='style12' colspan='2'> Enable <input type='radio' name='status' value='enable'  class='style5' if($enabled == 1){ checked='checked'}> Disable<input type='radio' name='status' value='disable' class='style5' if($enabled == 0){ checked='checked'}> </td> [/code]
×
×
  • 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.