conection php with MySQL (case)

Discussion in 'PHP' started by guif, Aug 5, 2008.

  1. guif

    guif New Member

    Joined:
    Jul 25, 2008
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
    I have problems to make a a case option with my php files.
    I have a index.php with links:

    Code:
    <a href="lib/consultas.php?accion=A">link1</a><br>
    <a href="lib/consultas.php?accion=B">link2</a><br>
    <a href="lib/consultas.php?accion=C">link3</a><br>
    <a href="lib/consultas.php?accion=D">link4</a><br>
    And now, I have another php file: consultas.php
    In this php i have this code:

    Code:
    $conexion = mysql_connect("localhost", "user", "pass");
    mysql_select_db("jiradb", $conexion);
    
    if($accion!=''){
    switch($accion)
    {
    
    case 'A':
    $queEmp = "select * from membershipbase where user_name like 'gbosch'";
    $resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
    $totEmp = mysql_num_rows($resEmp);
    echo Usuario: "<strong>".$rowEmp['USER_NAME']."</strong><br>";
    echo Grupo: "<strong>".$rowEmp['GROUP_NAME']."</strong><br>";
    break;
    
    case 'B':
    $queEmp = "select * from membershipbase where user_name like 'jcodina'";
    $resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
    $totEmp = mysql_num_rows($resEmp);
    echo Usuario: "<strong>".$rowEmp['USER_NAME']."</strong><br>";
    echo Grupo: "<strong>".$rowEmp['GROUP_NAME']."</strong><br>";
    break;
    
    }
    }
    When I execute my first link the php i don't work correctly. I don't see nothing! Why???
     
  2. guif

    guif New Member

    Joined:
    Jul 25, 2008
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
    now it's work!!!!!
    in the consultas.php:
    Code:
    $conexion = mysql_connect("localhost", "user", "pass");
    mysql_select_db("my_BBDD", $conexion);
    
    
    if (isset($_GET['accion'])){
    switch ($_GET['accion']){
    
    	case 'A':
    		...la consulta y la impresión en pantalla...
    			}
    		}
    		break;
    
    	case 'B':
    		...la consulta y la impresión en pantalla...
    			}
    		}
    	case 'C':
    
    		...la consulta y la impresión en pantalla...
    
    			}
    		}
    		break;	
        }
    }  
    
    thanks!
     
    Last edited by a moderator: Aug 5, 2008

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice