Jump to content

Search the Community

Showing results for tags 'union'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 4 results

  1. Hello I hope that someone can help me i am trying to do the following: i am trying to do the following i have a login name and password and the redirects me depending on the level the works correctly. Table Users id_user user pass city Type //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Table City id_city id_student city //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Table Student id_student id_city name last name grade number card city -------------- login.php--------------------------------------------------------------------------------------------- <form id="form1" name="form1" method="post" action="cargar_login.php"> <table width="800" border="0" align="center" cellpadding="5" cellspacing="5"> <tr> <td colspan="2">blablabla</td> </tr> <tr> <td width="370">User</td> <td width="389"><input type="text" name="user" id="user" /></td> </tr> <tr> <td>Password</td> <td><input type="text" name="pass" id="pass" /></td> </tr> <tr> <td><input type="submit" name="boton" id="boton" value="Send" /></td> </tr> </table> </form> --------------finish login.php (form)------------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// example name of the teacher name: Peter Pass .12345 or wteu12, wherever... City: Chicago Type :Teacher --------------Star cargar_login.php------------------------------------------------------------------------------- <?php include"conexion/conexion.php"; $consulta = "SELECT * FROM Users WHERE user = '{$_POST['user']}' AND pass = '{$_POST['pass']}'"; $datos = mysql_query($consulta, $id); $numDatos = @mysql_num_rows($datos); if ($numDatos <= 0) { echo"</p> <p> </p> <p> </p>"; echo"<link href='../stylesheets/tabla.css' rel='stylesheet' type='text/css' />"; echo "<center><table width='800' border='0' cellpadding='5' cellspacing='5'>"; echo"<tr>"; echo"<td class='textoerror'>"; echo "<img src='error.png' width='46' height='46'/>\n Error: User or Pass are Incorrect.\n<a href='login.php'>Tray Again</a>"; echo""; echo"</td>"; echo"</tr>"; echo"</table></center>"; } if(isset($_POST["boton"])) { $user = $_POST['user']; $pass = $_POST['pass']; $user = stripslashes($user); $pass = stripslashes($pass); $user = mysql_real_escape_string($user); $pass = mysql_real_escape_string($pass); $sql = "SELECT * FROM Users WHERE (user= '$user') AND pass='$pass'"; $resultados = mysql_query($sql); $count = mysql_num_rows($resultados);//counting table rows $derechos=mysql_fetch_array($resultados); //fetch contents from db @session_start(); $_SESSION['usuario'] = $user; if($derechos['type'] == "Supadmin"){ header("Location: supadmin/index.php"); // if userlevel admin } //if($derechos['type'] == "Admin"){ //print "<meta http-equiv=Refresh content=\"2 ; url=admin/index.php\">"; // if userlevel admin//} elseif($derechos['type'] == "Admin"){ header("Location: admin/index.php"); // if userlevel admin } elseif($derechos['type'] == "Teacher"){ header("Location: teacher/index.php"); // if userlevel teacher } elseif($derechos['type'] == "Students"){ header("Location: students/index.php"); // if userlevel students } elseif($derechos['type'] == "Parents"){ header("Location: parents/index.php"); // if userlevel parents } } else { echo "The user or Password is not Correct!"; } ?> --------------finish cargar_login.php------------------------------------------------------------------------------------ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Example he logs seccions teacher : Peter and called a teacher/index.php and already registered to be able to see all the students of teacher Peter, who lives in Chicago and he want to see all the students of Chicago in the main section of teacher (teacher/index.php). I think that to bring the data of teacher Peter what i have to do with the union of two tables i suppose that this is the Users and City and the union is for :id_city --------------this are secciob of teacher/index.php------------------------------------------------------------------------------------ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// <?php session_start(); if(!isset($_SESSION['user'])) { header('Location: ../login.php'); exit(); } $usuario = $_POST['user']; $clave = $_POST['pass']; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// And here is where you should get a list of all the students of the teacher Peter who is from Chicago In the code sample below(teacher/index.php) already concerned in many ways but i can't ... Help as i do so is what I do not understand please help I know that the code is bad, but this is my idea try to do this code...or call /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// --------------Satr teacher/index.php------------------------------------------------------------------------------------ $id = mysql_connect("localhost", "root", ""); mysql_select_db("nueva", $id); $consulta_mysql="select User.*, city.* FROM user, city WHERE (user= '$user') AND pass='$pass"; $res=mysql_query($consulta_mysql,$id); if (!$res) { die('Error in the table: ' . mysql_error()); } while($registro=mysql_fetch_array($res)) { echo"<td>"; echo $registro["user"] ; echo"</td>"; echo"<td>"; echo $registro["city"] ; echo"</td>"; } ?>
  2. I'm still working on my helpdesk report and am a long way down the line thanks to the help I've received in here. Now, imagine a chart with the list of helpdesk members going across, left to right. Underneath each of them they have two headings (calls logged, calls resolved). Going down the page we have months of the year. Using the following code I can populate an individual month's calls logged and calls resolved, but is there any way I can do a super-complicated UNION to fill in all the data, or even just one person's which could then be looped? Or is it a case of looping the query, replacing the user and the date? Here's the code - clearly 'user1' and '2012-11%' need replacing with variables. SELECT member, SUM(logged) as logged_count, SUM(resolved) as resolved_count FROM ( SELECT logged_by as member, COUNT(item) as logged, 0 as resolved FROM incidents WHERE logged_by = 'user1' AND logged LIKE '2012-11%' GROUP BY logged_by UNION SELECT resolved_by as member, 0 as logged, COUNT(item) as resolved FROM incidents WHERE resolved_by = 'user1' AND logged LIKE '2012-11%' GROUP BY resolved_by ) as results GROUP BY member
  3. Here is my dilemma. I have table 'mail'. I need to select all mail rows from the mail table based on two conditions: 1) There is only one message. There have not yet been any replies(orig_mess = 0). This would need to select the only message in the database in this condition. 2) There are one or more message related to the original message. This would be indicated by orig_mess = 'oringal message id'. If there are any responses to any of the original messages I need to retrieve them all and then order by their id. Here is a table example: mail.table id from_user to_user orig_mess message_body 1 37 54 0 Hello 2 54 37 1 Hello back 3 60 37 0 Test The task is that I need to display new mail messages. It could be a new conversation, or it could be a new message based off an older conversation. In either case I need to pull the most current(highest id) message and display that first. I then need to loop through any older messages(if applicable to the original) and display them from newest to oldest as well. I have tried and failed attempts to grab it all from one query, but that is what I want to do. If I can't do it from one, I would be fine with looping through a second query to get older messages. Any ideas on how this could be accomplished? Thanks. This is all I have at the moment: $result = mysql_query("SELECT Mail.id FROM Mail WHERE Mail.to_user='$_SESSION[user_id]' AND Mail.orig_mess='0' AND tbl.id2!=Mail.id UNION SELECT MAX(Mail.id) FROM Mail WHERE Mail.orig_mess!='0' ORDER BY id DESC")or die(mysql_error()); while($row = mysql_fetch_array($result)){
  4. I am a beginner with MySQL and was wondering what method advanced users would recommend to perform the simple task of looking through two tables to find one row. I don't need code from you, just a general idea of what type of query is best for this situation. If you can offer an explanation of why you like the method, that's even better. 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.