Jump to content

quyen

Member
  • Posts

    44
  • Joined

  • Last visited

Posts posted by quyen

  1. Hi Andrea,

     

    As I mentioned to you before about my new project - Rosa bakery. I am still doing it, it's almost done. I want to say thank to you all for your comments and feedback.

     

    This is my trial running version - h tt p://rosabakery.c om.vn/htdocs/?page=home&lang=en#?page=home

     

    I am still working on this product - So it will be very helpful if you guys can share some of your comments for my trial version.

     

    Quyen,

  2. Hi again,

     

    Ok, I understand the reasons why you guys have to deactive all the links.

     

    As I said before that I am upgrading my website, that's why I put a sign on my website says "Temporary under construction".

     

    I am designing some new projects, and I've just finished designing these projects in the .psd files,right? I just want to receive some comments and feedback for the layouts. That's all.

     

    If you don't trust me then here are some of my designs:

     

    w ww. mondogelato.co m.vn

    w ww. classico.co m.vn

     

    I don't really want to spend too much time to post something like this. If you don't allow us to do this, then we have to leave.

     

    Quyen,

  3. Hi,

     

    I am not sure about your foreach "(get_xml_face() as $product) " ,so I just try this simple example with include or require, I don't know if this can help you a bit!

    File test.php:

    <?php
    function render_data($arr) {
       $output = '';
       return $output;
    }
    
    $arr = array("Homepage","About Us","Portfolio","Help");
    print render_data($arr);
    ?>
    

     

    Here is the file that I use to include or require include.php:

    <?php 
    for($i= 0; $i<=3; $i++){
       $output .= ''.$arr[$i];
       $output .= '';
    }
    ?>
    

     

    Quyen,

  4. Hello,

     

    you can use "require", "include" to include files. Its pretty hard to look at your code right now, next time could you please put it in

    Your php code will show here

    and also share us a full php file.

     

    Did you mean that is there anyone can help you to find the common code from your example and put it in a new file? so later you can reuse this file? Or did you mean something else?

     

    Quyen,

  5. Hi again,

     

    Could you please send me the php file, and I will try to edit it for you. Or you can try this:

     

    $bno = mysql_real_escape_string(htmlspecialchars($_POST['branch_id']));

    $street = mysql_real_escape_string($_POST['street']);

    $area = mysql_real_escape_string(htmlspecialchars($_POST['area']));

    $city = mysql_real_escape_string(htmlspecialchars($_POST['city']));

    $postcode = mysql_real_escape_string(htmlspecialchars($_POST['postcode']));

    $telno = mysql_real_escape_string(htmlspecialchars($_POST['tel']));

    $faxno = mysql_real_escape_string(htmlspecialchars($_POST['fax']));

     

    Note:

    branch_id, street, area, city, postcode, tel, fax have to be exacly the same with form_component_name (I am not sure what do they look like now after you edit).

    In the code above, for example your input text is :

    ....do the same to other components.

    Or you can try to read this page, very basic and simple, also easy to understand : http://w3schools.com/php/php_post.asp

     

    Goodluck!

     

    Quyen,

  6. Hello Taksi10,

     

    I think the problem comes from the form. Check your function renderForm() again, and also give the input fields different names.

     

    I hope that will help!

    Quyen,

  7. Hello everyone,

     

    Thanks a lot for your all replies, I do want to post all the coding which are require or include for you, but I'm wondering that my php pages are quite long, I hope you guys can understand all.

    Please let me know if there is anything wrong. Sorry I didn't comment much in my php code, I should do that but sorry i am too busy. If you need any futher information, let me know pls.

    Thanks a lot again

     

    "The main problem occurs in menu_manager.php file, I think"

    Quyen,

     

    file content.php:

    
    <?php 
    if(!isset($_SESSION['user_id'])){
       header("location: alert_box.php?opt=no_permission");
    }
    else{
       if(isset($_GET["content"])){
           $content = $_GET["content"];
           switch($content){
               case "home":
               break;
               case "menus":
                   require_once("menu_manager.php");
               break;
               case "users":
                   require_once("user_manager.php");
               break;
               case "portfolio":
               break;
               case "cart":
               break;
           }
       }
    }
    ?>
    
    

    file menu_manager.php:

    <?php                
       $query = "SELECT * FROM menu 
                 ORDER BY last_edit DESC";
       $result = mysql_query($query);
       $cnt_records = mysql_num_rows($result);
       if($cnt_records){
       $per_page = 10;
       $start = 0;
       $num_of_page = ceil($cnt_records/$per_page);
       if(isset($_GET['page'])){
           $get_request = $_GET['page'];
           if($get_request!="")
           {
               $start = ($get_request-1) * $per_page;
           }
           else
           {
               $start = 0;
           }
       }
       else{
       }
       ?>
    
    
    
    
               <?php 
               if($num_of_page >=2){
               ?>
    
                   Page:
    
    Select one
                       <?php 
                       for($index=1;$index <= $num_of_page;$index++)
                       {
                           if($get_request == $index)
                           {
    
                               echo "$index ";
                           }
                           else
                           {
                               echo "$index ";
                           }    
                       }
                       ?>
    
                   <?php 
                   if(isset($_POST['page'])){
                       $selected = $_POST['page'];
                       for($index=1;$index <= $num_of_page;$index++)
                       {
                           if($get_request == $selected)
                           {
                               header("location: index.php?content=menus&page=$selected");
                           }
                           else
                           {
                               header("location: index.php?content=menus&page=$selected");
                           }    
                       }
                   }
                   ?>
    
               <?php 
               }
               ?>
    
    
       
                   Item: 
    
    Select one
                   <?php 
                   if($cnt_records){
                       while($row = mysql_fetch_array($result)){
                           ?>
    
                               <?php 
                               print $row['name']."--"; 
                               if($row['type']==0){print "B";}else{print "F";}
                               ?>
    
                           <?php
                       }
                   }
                   ?>
    
    
    
    
    
                   Quick launch: 
    
    Select one
    All
    Back-End
    Front-End
    Published
    Un-Published
    
       
    
    
    
    
    Delete
    
    
    Published
    
    
    None
    
    
    Select All
    
    
    
    Add
    
    
           <?php 
           if(!isset($_GET['act'])){
               require_once("menu_content.php");
           }
           else{
               $action = $_GET['act'];
               switch($action){
                   case"item":
                       if(isset($_POST['menu_id'])){
                           $menu_id = $_POST['menu_id'];
                           $query = "SELECT * FROM menu
                                     WHERE menu_id = '$menu_id'
                                     ";
                           $result_items = mysql_query($query);
                           $cnt_records = mysql_num_rows($result_items);
                           if($cnt_records){
                           ?>
    
    IDGroupNameLink name OrderingPublishedDetailsEditDelete#
    
                           <?php    
                           }
                       }
                   break;
    
                   case "pos":
                       if(isset($_POST['pos'])){
                           $ordering= $_POST['pos'];
                           $menu_id = $_POST['menu_id'];
                           $last_edit = date("F j, Y, g:i a");
                           $query = "UPDATE menu
                                   SET ordering = '$ordering',last_edit = '$last_edit'
                                   WHERE menu_id = '$menu_id' 
                                   ";
                           $result = mysql_query($query);
                           $cnt_records = mysql_num_rows($result);
                           if($result){
                               header("location: index.php?content=menus");
                           }
                       }
                   break;
                   case 'formAdd':
                       require_once("menu_adding_form.php");
                   break;
                   case 'add':
                       $type = $_POST['type'];
                       $name = $_POST['name'];
                       $link_to = $_POST['link_to'];
                       $ordering = $_POST['ordering'];
                       $created_date = date("F j, Y, g:i a");
                       $last_edit = date("F j, Y, g:i a");
                       if(isset($_POST['published'])){
                           $status = 1;
                       }
                       else{
                           $status = 0;
                       }
                       if($name == ""){
                           header("location: alert_box.php?opt=empty");
                       }
                       else{
    
                           $table = "menu";
                           $cols = "menu_id,type,name,link_to,ordering,
                                    status,created_date,last_edit
                                    ";
                           $values = "'','$type','$name','$link_to','$ordering',
                                     '$status','$created_date','$last_edit'
                                     ";
                           $query = "INSERT INTO menu ($cols) 
                                     VALUES ($values)
                                    ";
                           $result = mysql_query($query);
                           if($result){
                               header("location: index.php?content=menus");
                           }
                           else{
                               header("location: alert_box.php?opt=not_insert");
                           }
                       }
                   break;
                   case "more":
                       if(isset($_GET['id'])){
                           $menu_id = $_GET['id'];
                           $query = "SELECT * FROM menu 
                                     WHERE menu_id = '$menu_id'
                                     ";
                           $result = mysql_query($query);
                           $cnt_records = mysql_num_rows($result);
                           if($cnt_records > 0){
                               require("menu_editing_form.php");
                           }
                       }
                   break;
                   case "edit":
                       $menu_id = $_POST['menu_id'];
                       $type = $_POST['type'];
                       $name = $_POST['name'];
                       $link_to = $_POST['link_to'];
                       $ordering = $_POST['ordering'];
                       $last_edit = date("F j, Y, g:i a");
                       if(isset($_POST['published'])){
                           $status = 1;
                       }
                       else{
                           $status = 0;
                       }
                       if($name == ""){
                           header("location: alert_box.php?opt=empty");
                       }
                       else{
                           $set = "type = '$type', 
                                   name = '$name',
                                   link_to = '$link_to',
                                   ordering = '$ordering', 
                                   status = '$status', 
                                   last_edit = '$last_edit' ";
                           $query = "
                                    UPDATE menu
                                    SET $set 
                                    WHERE menu_id = '$menu_id'
                                    ";
                           $result = mysql_query($query);
                           if($result){
                               header("location: index.php?content=menus");
                           }
                           else{
                               header("location: alert_box.php?opt=not_updated");
                           }
                       }
                   break;
                   case "delete":
                       if(!isset($_GET['id'])){}
                       else{
                           $menu_id = $_GET['id'];
                           $query = "DELETE FROM menu
                                     WHERE menu_id = '$menu_id';
                                    ";
                           $result = mysql_query($query);
                           if($result){
                               header("index.php?content=menus");
                           }
                           else{
                               print mysql_error();
    
                               header("alert_box.php?opt=delete_error");
                           }
                       }
                   break;
    
                   case "status":
                       if(isset($_GET['id']) && isset($_GET['cur'])){
                           $menu_id = $_GET['id'];
                           $last_edit = date("F j, Y, g:i a");
                           $current_status = $_GET['cur'];
                           if($current_status == 0){
                               $status = 1;
                           }
                           elseif($current_status == 1){
                               $status = 0;
                           }
                           else{
                               header("location: alert_box.php?opt=no_permission");
                           }
                           $query = "UPDATE menu
                                     SET status = '$status', last_edit = '$last_edit' 
                                     WHERE menu_id = $menu_id
                                    ";
                           $result = mysql_query($query);
                           if($result){
                               header("location: index.php?content=menus&page=1");
                           }
                           else{
                               header("location: alert_box.php?opt=not_updated");
                           }
                       }
                   break;
               }
           }
       } 
    ?>
    

     

    Required files:

    menu_list.php

    
    
           <?php print $row['menu_id']?>
    
    
           <?php 
           if($row['type'] == 1){
               print "Front-end";
           }
           else{
               print "Back-end";
           }
           ?>
    
    
           <?php print $row['name'];?>
    
    
           <?php print $row['link_to'];?>
    
    
    
           <?php 
               print $row['ordering'];
               $current_id = $row['menu_id'];
           ?>
    
           <?php 
           if(!isset($_GET['act'])){
           }
           else{
               ?>
    
    Select
                   <?php 
                   $query = "SELECT * FROM menu";
                   $result = mysql_query($query);
                   $cnt_records = mysql_num_rows($result);
                   for($i= 1; $i<= $cnt_records; $i++){
                       ?>
    <?php print $i;?>
                       <?php
                   }
                   ?>
    
            <?php 
                }
            ?>
    
    
    
           <?php 
           if($row['status'] == 1){
               print "Yes ";
           }
           else{
               print " No  ";
    
           }
           ?>
    
    
    Detail
    
    
    Edit
    
    
    Delete
    
    
    
    
    
    
    
    
    

     

    menu_adding_form.php

     

    
    
    Add a new menuitemGroup of menu 
    
    Front-End
    Back-End
    
    Menuitem nameLink to
    
    Home page
    About Us
    Web Designs
    Web Templates
    Contact Us
    Shopping Cart
    
    Menus
    Users
    
    Ordering
    
                       <?php 
                       $query = "SELECT * FROM menu";
                       $result = mysql_query($query);
                       $cnt_records = mysql_num_rows($result);
                       for($i= 1; $i<= $cnt_records; $i++){
                           print ''.$i.'';
                       }
                       ?>
    <?php print $cnt_records + 1?>
    
    Published
    
     Enter or click
    
    
    
    
    
    
    

     

    menu_editing_form.php

    
    Detail of menuitems  " <?php print $menu_id; ?> "Group of menu 
    
                       <?php 
                       while($row = mysql_fetch_array($result)){
                       ?>
    
                           <?php 
                           $menu_id = $row['menu_id'];
                           $type = $row['type'];
                           $name = $row['name'];
                           $link_to = $row['link_to'];
                           $status = $row['status'];
                           $ordering = $row['ordering'];
                           $created_date = $row['created_date'];
                           $last_edit = $row['last_edit'];
                           if($type ==  0){
                               print "Back-End";
                           }
                           else{
                               print "Front-End";
                           }
                           ?>
    
                       <?php 
                       }
                       if($type == 0){
                           ?>
    Front-End
                           <?php
                       }
                       else{
                           ?>
    Back-End
                           <?php
                       }
                       ?>
    
    
    Menuitem nameLink to
    
    
    <?php print $link_to;?>
                       <?php 
                       $query = "SELECT * FROM menu
                                 WHERE link_to <> '$link_to'
                                 ORDER BY ordering ASC
                                ";
                       $result = mysql_query($query);
                       $cnt_records = mysql_num_rows($result);
                       if($cnt_records){
                           while($row = mysql_fetch_array($result)){
                               $type = $row['type'];
                           ?>
    
                               <?php 
                               print $row['link_to']."--";
                               if($type == 0){
                                   print "Back";
                               }
                               else{
                                   print "Front";
                               }
                               ?>
    
                           <?php
                           }
                       }
                       ?>
    
    Ordering
    
                       <?php 
                       $query = "SELECT * FROM menu";
                       $result = mysql_query($query);
                       $cnt_records = mysql_num_rows($result);
                       for($i= 1; $i<= $cnt_records; $i++){
                       $start = $i + 1;
                       ?>
    selected="selected" <?php }?>>
                           <?php  print $i;?>
    
                       <?php
                       }
                       ?>
    
    Published
    checked<?php } ?> />
    Created on 
    <?php print $created_date; ?>
    Last edited
    <?php print $last_edit ; ?>
     Enter or click
    
    
    
    
    
    
    

  8. are you selecting form the same table or from two different tables? You can build your select query better with sub-query. and make your code more simple and easy to handle.

     

    I think you are selecting from 1 table (or even 2 tables), the thing is you want to delete the records where the conditions are true, you can also use:

     

    if(condition1 && condition2){

     

    }

    else{

     

    }

     

    Quyen,

  9. Yeah this is my php code: it may show you something easy to understand.

     

                   case 'formAdd':
                       require_once("menu_adding_form.php");
                   break;
                   case 'add':
                       $type = $_POST['type'];
                       $name = $_POST['name'];
                       $link_to = $_POST['link_to'];
                       $ordering = $_POST['ordering'];
                       $created_date = date("F j, Y, g:i a");
                       $last_edit = date("F j, Y, g:i a");
                       if(isset($_POST['published'])){
                           $status = 1;
                       }
                       else{
                           $status = 0;
                       }
                       if($name == ""){
                           header("location: alert_box.php?opt=empty");
                       }
                       else{
    
                           $table = "menu";
                           $cols = "menu_id,type,name,link_to,ordering,
                                    status,created_date,last_edit
                                    ";
                           $values = "'','$type','$name','$link_to','$ordering',
                                     '$status','$created_date','$last_edit'
                                     ";
                           $query = "INSERT INTO menu ($cols) 
                                     VALUES ($values)
                                    ";
                           $result = mysql_query($query);
                           if($result){
                               header("location: index.php?content=menus");
                           }
                           else{
                               header("location: alert_box.php?opt=not_insert");
                           }
                       }
                   break;
                   case "more":
                       if(isset($_GET['id'])){
                           $menu_id = $_GET['id'];
                           $query = "SELECT * FROM menu 
                                     WHERE menu_id = '$menu_id'
                                     ";
                           $result = mysql_query($query);
                           $cnt_records = mysql_num_rows($result);
                           if($cnt_records > 0){
                               require("menu_editing_form.php");
                           }
                       }
                   break;
                   case "edit":
                       $menu_id = $_POST['menu_id'];
                       $type = $_POST['type'];
                       $name = $_POST['name'];
                       $link_to = $_POST['link_to'];
                       $ordering = $_POST['ordering'];
                       $last_edit = date("F j, Y, g:i a");
                       if(isset($_POST['published'])){
                           $status = 1;
                       }
                       else{
                           $status = 0;
                       }
                       if($name == ""){
                           header("location: alert_box.php?opt=empty");
                       }
                       else{
                           $set = "type = '$type', 
                                   name = '$name',
                                   link_to = '$link_to',
                                   ordering = '$ordering', 
                                   status = '$status', 
                                   last_edit = '$last_edit' ";
                           $query = "
                                    UPDATE menu
                                    SET $set 
                                    WHERE menu_id = '$menu_id'
                                    ";
                           $result = mysql_query($query);
                           if($result){
                               header("location: index.php?content=menus");
                           }
                           else{
                               header("location: alert_box.php?opt=not_updated");
                           }
                       }
                   break;
    

     

    Thanks a lot

    Quyen,

  10. Thanks for your reply,

     

    Yeah you're right, I've used Header(); quite a lot in my php pages, ofcourse I used it for different purposes, I've been trying to comment all the //Headers, and use print "somthing"; to replaces Header commands, it works fine, but Whenever I remove one of the comment lines, the warning will appear straight away.

     

    I am sure I did something wrong, but I haven't found it yet. Maybe I already used Header in the file which is required in the php page. But I think you can use multiple Headers command on the same page or include or require, right?

     

    Thanks a lot for your help but really I don't want to use javascript in this case, because users can turn it off anytime, that means my website won't work ok without JS

     

    Quyen,

×
×
  • Create New...