Jump to content

romio

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Everything posted by romio

  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]
  14. In my database I do have a 'status' field which have the value 1 for enable product and 0 for disable product, when the user click on edit product I do have a form that loads a form with the specified Id, my only problem is the radio option which I don’t know how to set one of them to be true if it has a value of 1. Some part of my edit_product() function which is used to edit a product: [code]     $category = $_GET['nodeid'];     $product_id = $_GET['product_id'];     $name = $_POST['product_name'];     $description = $_POST['description'];     $price = $_POST['price'];     $in_stock = $_POST['in_stock'];     $brief_desc = $_POST['brief_description'];     $product_code = $_POST['product_code'];     $upload_folder = "images/product_thumbnail";          $image = $fileName = $_FILES['uploaded']['name'];     switch($_POST['status'])               {                                   case 'enable':                                     $status = 1;               break;                      case 'disable':                                         $status = 0;               break;       }        $edit_product = "UPDATE product SET name='$name', description='$description', price='$price', in_stock='$in_stock', enabled='$status', brief_description='$brief_desc', product_code= '$product_code', thumbnail='$image' WHERE product_id=$product_id";     $edit_product_query = mysql_query($edit_product); [/code] and this is my form_edit() function which loads data row from my db: [code]     $catID = $_GET['nodeid'];     $product_id = $_GET['product_id'];     $edit_product = "SELECT * FROM product WHERE product_id = $product_id";     $edit_product_query = mysql_query($edit_product);     $edit_product_display_rows = mysql_num_rows($edit_product_query);     while($row = mysql_fetch_array($edit_product_query))     {         $name = $row['name'];         $description = $row['description'];         $price = $row['price'];         $in_stock = $row['in_stock'];         $item_sold = $rows['items_sold'];         $enabled = $row['enable'];         $brief_description = $row['brief_description'];         $product_code = $row['product_code'];     }     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>                         <tr>                              <td width='178'  class='style13' height='33'> Product Name : *</td>                              <td width='413' class='style12' colspan='2' height='33'>                             <input type='text' name='product_name' value='$name' size='22' maxlength='160' /></td>                         </tr>                              ............                              ............                         <tr>                              <td width='178'  class='style13' height='33'> Display:</td>                              <td width='413' class='style12' colspan='2'>                              Enable<input type='radio' name='status' value='enable' class='style5'>                              Disable<input type='radio' name='status' value='disable' class='style5'></td>                         </tr> [/code]
  15. This is my menu code on my index.php: [code] function menu_case($selected) {     switch($selected)     {         case 0:             echo add_product_form();             break;         case 1:             echo find_products();             break;         default:             echo find_products();             break;     } } [/code] When the page loads I have find_products() as a default value, on the same page I have a "Add Product" which will link to a function, how can I do that? I have tried doing this but I get an error: [code] <a href='<? menu_case(0) ?>' class='style10'>Add Product</a> | Add  Category<br><HR></td> [/code] Note that my add_product_form() contains a form which be displayed on the same page.
  16. Am currently working on php Product Catalogue system, DB is created and is running fine, small problem with the menu though, each category might have many sub_categories, and here were the problem starts, if i have cat_1 with sub cat_1_1 and cat_1_2 and cat_2 with sub cat_2_1 then codes works fine, i need to have a general function that would work on all depth, i cant just keep creating a new sql or a function code for every sub_categories! so i though of a recursive function or an array.. Any help would be appreciated. [code] function find_root_categories() {     $catID = $_GET['cat'];                  $find_parent_categories = "SELECT node.category_id ,node.name, (COUNT(parent.name) - 1) AS depth         FROM categories AS node, categories AS parent         WHERE node.lft             BETWEEN parent.lft AND parent.rgt         GROUP BY node.name         HAVING depth=1 ORDER BY node.lft";              $result_parent_categories = mysql_query($find_parent_categories);     $num_rows_parent_categories = mysql_num_rows($result_parent_categories);     if(!($num_rows_parent_categories))         {             echo"<tr>                     <td valign=top align=center>No Records To Display</td>                 </tr>";         }             else             {                 while($row = mysql_fetch_array($result_parent_categories))                 {                       $name= $row['name'];                       $catid = $row['category_id'];                     echo"                             <a href='?cat=$catid'>$name</a><br />                         ";                     if($catID == $catid){                                                  get_sub_cat($catID);                     }                 }             }      } [/code] [code] function get_sub_cat($catID){            $sql = "select * from categories where parent = $catID";    $result = mysql_query($sql);    $row = mysql_fetch_array($result);           // now, retrieve all descendants of the $root node    $result = mysql_query($sql);     while($row = mysql_fetch_array($result))     {           $name= $row['name'];           $catid = $row['category_id'];         echo"                 &nbsp;&nbsp;&nbsp;<a href='?cat=$catid'>$name</a><br />             ";             if($catID == $catid){                         get_sub_cat($catid);             }     } } [/code]
  17. I have developed a simple newsletter subscriber where the admin can login and send to all active subscribers an email. What I need to do is create my own random procedure in order to send the new subscribers a link to active him/her self, I have an overall idea but not sure how to implement it, would it be better to have a separate table or just use the same table by adding a new filed? Here are my thoughts up to now: This is my code, which adds a new subscriber: [code] if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "subscribe")) {             $first_name = $_POST['first_name'];             $last_name = $_POST['last_name'];             $email = $_POST['email'];             $phone = $_POST['phone'];             $street_address = $_POST['street_address'];             $postal_code = $_POST['postal_code'];             $province = $_POST['province'];             $town = $_POST['town'];             $country = $_POST['country'];             $query = "INSERT INTO subscribers (first_name, last_name, email, phone, street_address, postal_code, province, town, country) VALUES ('$first_name', '$last_name', '$email', '$phone', '$street_address', '$postal_code', '$province', '$town', '$country')";             mysql_select_db($database, $dbcnx);             mysql_query($query) or die('Error, insert query failed');                          $headers .= "Miramare Beach Hotel";             $headers .= "Content-Type: text/plain; charset=iso-8859-1\n";             $recipient = $email;             $subject = "News letter Subscribtion";             $message = "You have been added Successfuly";             $msg = wordwrap( $msg, 1024 );             mail($recipient, $subject, $message, stripslashes($msg), $headers);                          echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url='../../../?page=thanks.php'\">";             exit();         } ?> [/code] Can I add simply this link before the insert statement (I have also edited the insert query: [code] CREATE PROCEDURE Random_Num AS DECLARE Random_Num int; DECLARE Upper_Num int; DECLARE Lower_Num int SET Lower_Num = 1 SET Upper_Num = 999999 SELECT  Random_Num = Round(((Upper_Num - Lower_Num - 1) * Rand() + Lower_Num), 0) SET NOCOUNT ON $query = "INSERT INTO subscribers (first_name, last_name, email, phone, street_address, postal_code, province, town, country, random_num) VALUES ('$first_name', '$last_name', '$email', '$phone', '$street_address', '$postal_code', '$province', '$town', '$country', 'Random_Num')"; SET NOCOUNT OFF GO [/code]
  18. This is my mail_sender.php which i use to get some values from a form and send to all subscribers... [code] <?php require_once('config.inc.php'); $query = "select * from subscribers order by id"; mysql_select_db($database, $dbcnx); $result = mysql_query($query) or die('Error, insert query failed'); $num_rows = mysql_num_rows($result); if ((isset($_POST["MM_Mailer"])) && ($_POST["MM_Mailer"] == "subscribe")) {                                       $subject_Form = $_POST['subject'];             $message_Form = $_POST['message'];             $email = $_POST['email'];         while($row = mysql_fetch_array($result))         {                 $email = $row['email'];             $headers .= "Miramare Beach Hotel";             $headers .= "Content-Type: text/plain; charset=iso-8859-1\n";             $recipient = $email;             $subject = $message_Form;             $message = $message_form;             $msg = wordwrap( $msg, 1024 );             mail($recipient, $subject, $message, stripslashes($msg), $headers);         } }                 if(mail($recipient, $subject, $message, stripslashes($msg), $headers))         {             echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url='MailIsSend.php'\">";         }             else             {                 echo "The message can not been sent !<br />\n";             } ?> [/code] But i need to add an attachment to my mail how can i do that? Thanks.
  19. I have created my admin panel as follow: 1. (Add_Subscribers.php) which will add a new Subscriber based on html form (Subscriber will be added to my Database). 2. (View_Subscribers.php) which will list all Subscribers on my Database 3. (admin.php) just a simple menu page. 4. (Send_Mail.php) Help here, it’s a simple form with the following fields: Subject, message (body), attachment and a send command button, am not sure. How can I send this message to all Subscribers? Anyone could help or point to some tutorials I will appreciate it. Thanks in advance.
  20. I found the mistake.... I had it this way: [code] $directory = 'content/en'; [/code] which it should have been this way [code] $directory = 'content/en/'; [/code] Thanks alot for your help
  21. thats what i have for the moment but its aint working yet: menu.php [code] echo"     <!-- menu start --> <table border='0' cellpadding='0' cellspacing='0'  valign='top'>          <tr>         <td><img src='template/images/left_img.jpg'></td>     </tr>     <tr>                                 <td align='center' valign='middle' bgcolor='#B5E3F5'>                                                  <a class='menu' href='index.php?language=en'><img src='content/images/en.gif' border=0 alt='English'></a>                                                  <a class='menu' href='index.php?language=ru'><img src='content/images/ru.gif' border=0 alt='Russian'></a>                                              <a class='menu' href='index.php?language=ge'><img src='content/images/ge.gif' border=0 alt='German'></a>             </td>     </tr>         <tr><td class='menuDivLine'></td></tr>";                   if ($page=="home"){echo"<tr bgcolor='#C5B881'>";}         else{echo"<tr onMouseover=this.bgColor='#C5B881'; onMouseout=this.bgColor='#ACE6FD';  bgcolor='#ACE6FD'>";}echo"             <td><a class='menu' href='?page=home.htm'>Home</a></td>     </tr>          <tr><td class='menuDivLine'></td></tr>";         if ($page=="fact_sheet"){echo"<tr bgcolor='#C5B881'>";}         else{echo"<tr onMouseover=this.bgColor='#C5B881'; onMouseout=this.bgColor='#9CDAF3';  bgcolor='#9CDAF3'>";}echo"         <td><a class='menu' href='?page=fact_sheet.htm'>FACT SHEET</a></td>     </tr> . . .etc [/code] index.php [code] <?php if (!@$page) $page = 'home.htm'; switch($_GET['language']) {       case('en'):            $directory = 'content/en';       break;       case('ru'):             $directory = 'content/ru';       break;              case('ge'):             $directory = 'content/ge';       break;       default: $directory = 'content/ge'; } $PATH = $directory.$page; include("template/head.php"); [/code]
  22. [!--quoteo(post=353557:date=Mar 10 2006, 04:36 AM:name=lessthanthree)--][div class=\'quotetop\']QUOTE(lessthanthree @ Mar 10 2006, 04:36 AM) [snapback]353557[/snapback][/div][div class=\'quotemain\'][!--quotec--] I think you've got a bit confused as to whether to use GET or POST to determine this. You won't have posted anything because despite your form having a method of post, there is no submit form button. Consequently nothing will get posted. If you want to use GET with <a> tags and hyperlinks, you don't need to use the form at all. I think you sould decide which method you would rather use, we can then go from there. [/quote] I think using the <a> tags would be much better, I don’t think the form is needed, but am not sure how to implement it. Thanks
  23. This is my menu.php(part of it) file, what am trying to do is to check what language would the user choose, [code]                 <form method='post' action='index.php'>                         <a class='menu' href='index.php?ID'>                         <input type='hidden' name='ID' id='ID_Eng' value='ID_Eng'><img src='content/images/en.gif' border=0 alt='English'></a>                         <a class='menu' href='index.php?ID'>                         <input type='hidden' name='ID' id='ID_Rus' value='ID_Rus'><img src='content/images/ru.gif' border=0 alt='Russian'></a>                         <a class='menu' href='index.php?ID'>                         <input type='hidden' name='ID' id='ID_Ger' value='ID_Ger'><img src='content/images/ge.gif' border=0 alt='German'></a>                         <input type='hidden' name='Check_ID' value='Check'>                 </form> [/code] and this is my index.php(part of it) [code] <?php if (!@$page) $page = "home.htm"; if ($_POST['Check_ID']) {             $id=$_GET['ID'];     if ($id = 'ID_Eng')     {     $directory = "content/en/";     }     else if ($id = 'ID_Rus')     {     $directory = "content/ru/";     }     else if ($id = 'ID_Ger')     {     $directory = "content/ge/";     } } [/code] and for the rest of the menu thats what i got: [code]     <tr><td class='menuDivLine'></td></tr>";                   if ($page=="home"){echo"<tr bgcolor='#C5B881'>";}         else{echo"<tr onMouseover=this.bgColor='#C5B881'; onMouseout=this.bgColor='#ACE6FD';  bgcolor='#ACE6FD'>";}echo"             <td><a class='menu' href='?page=home.htm'>Home</a></td>     </tr>          <tr><td class='menuDivLine'></td></tr>";         if ($page=="fact_sheet"){echo"<tr bgcolor='#C5B881'>";}         else{echo"<tr onMouseover=this.bgColor='#C5B881'; onMouseout=this.bgColor='#9CDAF3';  bgcolor='#9CDAF3'>";}echo"         <td><a class='menu' href='?page=fact_sheet.htm'>FACT SHEET</a></td>     </tr> [/code] What am I doing wrong, Thanks
×
×
  • 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.