Jump to content

Search the Community

Showing results for tags 'MySQL'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

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


Languages

  1. I'm creating a simple login and registration form. What I'm trying to do is when a user registers, it should log them in. In order to get logged in, the user's ID that gets registered needs to be sent to the home page so the username can be displayed. I'm not sure what is wrong with my code. Register: <!DOCTYPE html><?php session_start(); if(isset($_SESSION['userID']) AND !empty($_SESSION['userID'])) { header("Location: home.php"); } if(isset($_POST['register'])) { $firstName = mysqli_real_escape_string($dbConnect, $_POST['firstName']); $lastName = mysqli_real_escape_string($dbConnect, $_POST['lastName']); $username = mysqli_real_escape_string($dbConnect, $_POST['username']); $email = mysqli_real_escape_string($dbConnect, $_POST['email']); $password = mysqli_real_escape_string($dbConnect, $_POST['password']);{ // Check if data exists already in the database $exists = mysqli_query($dbConnect, "SELECT user_id, username, email FROM users WHERE username = '$username' AND email = '$email'"); $row = mysqli_fetch_array($exists); $dbusername = $row['username']; $dbemail = $row['email']; if ($username == $dbusername) { die("Username already taken."); } else if ($email == $dbemail) { die("Email already registered."); }} $registerUser = "INSERT INTO users (first_name, last_name, username, email, password) VALUES('$firstName', '$lastName', '$username', '$email', '$password')";{ // Select ID from registered user $selectID = "SELECT user_id FROM users WHERE username = '$username'"; $selectID_Query = mysqli_query($dbConnect, $selectID); $fetch = mysqli_fetch_array($selectID_Query); $userID = $fetch['user_id']; $_SESSION['userID'] = $userID;} if(mysqli_query($dbConnect, $registerUser)) { header("Location: home.php"); } else { echo "<script>alert('error while registering you...');</script>"; } } include "includes/head.php"; include "includes/nav.php";?> <div id="main-content"> <div class="welcome-msg"> <h1 class="huge">Registration form</h1> <h3 class="medium">Please fill in all the inputs</h3> <form id="login-form" method="post"> <label for="firstName">First Name</label> <input type="text" name="firstName" id="firstName" required> <label for="lastName">Last Name</label> <input type="text" name="lastName" id="lastName" required> <label for="username">Username</label> <input type="text" name="username" id="username" required> <label for="email">Email</label> <input type="email" name="email" id="email" required> <label for="password">Password</label> <input type="password" name="password" id="password" required> <button type="submit" name="register">Register</button> </form> </div> </div></body> Home: <!DOCTYPE html><html><?phpsession_start();if(!isset($_SESSION['userID'])) { header("Location: index.php");}$tUsers_Select_Query = mysqli_query($dbConnect, "SELECT * FROM users WHERE user_id=".$_SESSION['userID']);$row = mysqli_fetch_array($tUsers_Select_Query);include "includes/head.php";include "includes/nav.php";?> <div id="main-content"> <h1 class="huge">Welcome back, <?php echo $row['username'] ?>!</h1> <a href="/lr/logout.php?logout">Logout</a> </div></body> If you need any more details, please comment.
  2. I am trying to make a result page so I can get some information from the database by using php coding. I need it to be able to find a patient name and date of service. Which will be if I type in (Search:) Joe Doe and add (from:) 02/02/2015 (to:) 02/14/2015. It will find the patient name and all date of service. Here is my code ... I know mysql is not good but it will work for now. <?phpmysql_connect('localhost', 'root', 'no_password');mysql_select_db('timeclock');$results = array();if(isset($_GET['search'])) { $search = $_GET['search_box']; $from = $_GET['from']; // or $from = $_get['from']; $to = $_GET['to']; // or $to = $_get['to']; $sql = mysql_query("SELECT * FROM info WHERE patient_name = '".$search."' AND (date_of_service BETWEEN '".$from."' AND '".$to."')"); while($row = mysql_fetch_assoc($sql)) { $results[] = $row; }}?><!-- form --><form name="search_form" method="GET" action="">Search: <input type="text" name="search_box" value="" />Dates From : <input type="text" name="from" value=""/> To : <input type="text" name="to" value=""/><input type="submit" name="search" value="Look up Patient ..."></form><!-- end --><table width="70%" cellpadding="5" cellspace="5"><tr> <td><strong>Care Provider</strong></td> <td><strong>Patient Name</strong></td> <td><strong>Date of Time</strong></td> <td><strong>Time In</strong></td> <td><strong>Time Out</strong></td> <td><strong>Remarks</strong></td></tr><?php if(!empty($results)): ?><?php foreach($results as $row){ ?><tr> <td><?php echo $row['care_provider']; ?></td> <td><?php echo $row['patient_name']; ?></td> <td><?php echo $row['date_of_service']; ?></td> <td><?php echo $row['time_in']; ?></td> <td><?php echo $row['time_out']; ?></td> <td><?php echo $row['remarks']; ?></td></tr><?php } ?><?php endif; ?></table>
  3. Hi, I have doubt in AJAX Database, In that getuser.php what should i write in the place of ajax_demo. Please anybody help me. And the link is http://www.w3schools.com/php/php_ajax_database.asp
  4. I'm writing an application using PHP and MySQL that is a TV Guide/TV Listings to pull the results of the following fields: id – int(11) name – varchar(255) chan_position – int(3) src_image – varchar(255) time – varchar(255) title – varchar(255) date – varchar(25) This is the code I've tried so far that basically displays all results as a table: <?php require('db.php'); ?> <div class="container"> <? //Start table echo "<table id='guide'>"; echo "<th>Channel</th>"; echo "<th>Title</th>"; echo "<th>Time</th>"; echo "<th>Date</th>"; echo "</tr>"; // Loop through database for ($i = 1; $i < $rowcount; $i++) { $row = mysqli_fetch_assoc($result); $chan_name = $row['name']; $chan_num = $row['chan_position']; $chan_logo = $row['src_image']; $time = date("g:i a", strtotime($row['time'])); $title = $row['title']; $date = $row['date']; // Show entries echo "<tr> <td style='text-align: center;'>"."<img src='".$chan_logo."'><br>".$chan_name."</td> <td>".$title."</td> <td>".$time."</td> <td>".$date."</td> </tr>"; } echo "</table>" ?> The ultimate goal is to have it display closely (but not exactly) to how its done here: http://www.zap2it.com/tvlistings 1. Getting the pagination to be horizontal and the loop through the results based on the time that is stored in the `time` column from 00:00 to 23:00 (use of AJAX necessary?) **Additional details** This is what is currently being output and the link above is what is needed to be output in terms of scrolling and pagination functionality. The output of the table at the moment is how the data is currently stored in the table as well.
  5. i found this script online: http://stackoverflow.com/questions/8022353/how-to-populate-html-dropdown-list-with-values-from-database <?php $conn = new mysqli('localhost', 'username', 'password', 'database') or die ('Cannot connect to db'); $result = $conn->query("select id, name from table"); echo "<html>"; echo "<body>"; echo "<select name='id'>"; while ($row = $result->fetch_assoc()) { unset($id, $name); $id = $row['id']; $name = $row['name']; echo '<option value="'.$id.'">'.$name.'</option>'; } echo "</select>"; echo "</body>"; echo "</html>"; ?> But what I want is to get the table names from the database. Does anyone know how?
  6. I want to update more than one column in php using mysql. fr example: $sql="update table_name set where username='$user'; $sql="update table_name set where password='$pass'; how to concatenate this querie? could you tell anyone how to solve this? Thanks in advance
  7. Hello everyone Anyone can help me i want show mysql records on .html page so plz tell me how i done and 2nd i m creat a sms submit form for user using text area but when i creat view.php page for show sms then show sms in one line of all text from sms so how i can do plz help me
  8. hello everyone m New In Php anyone Can Help I Want Upload Mutltifile with form name 2nd name file 1 file 2 file 3 file 4 than i want save in mysql like this id name 2ndname file3 file 4
  9. Hi guys, I'm new in PHP. I cannot find tutorial about how to get all categories article is listed in together with article title, author printed on the article list. I have 4 tables in DB: articles = DB for articles detailse: id, title, user_id, post_date articles_categories = id, category_id categories = category_id, category_name users = user_id, user_name, user_mail I want to do this: Which script logic do you suggest? Any kind of help is welcomed.
  10. Unknown column 'col' in 'field list' Is the error message, i tried all kinds of backticks, and quotes but doesnt work So I was thinking, how can I check (in phpmyadmin or in the mysql console) whether a table has the columns that are needed?
  11. My script gives a sort of an errormessage. Actually i can see a part of the code at the output screen in the browser. Like wth the php parser you get a notice or fatal error, but in this case the script does not work. How can i avoid these problems in the future?
  12. The idea is to insert with the browser a multiple input field, a loop, into mysql database. Is the solution to first put this loop input variable in an array and after that create in this case multible tables? Or is an array not necessary?
  13. I have a script and a MYSQL query its supossed to create a new table $variable now I have $sql = "CREATE TABLE '$variabele' "; But it doesnt work. I think CREATE TABLE works for constants not for variables. Which query should I use?
  14. Here's a fully working login system. Where users can sign up and access a members page. Features Include: - Login & Sign Up Page - Members Page Only **NOTE: I have not added any security code, you'll need to add this by yourself...** Step 1: Creating a Login and Sign Up Form. This will be a simple login page where users can enter their username and password, then click the submit button to access the members page. "login.php" will be the script that will be executed when they login. This processes the user information entered to check the validity through a database of users. HTML LOGIN FORM:<form method="post" action="login.php"><input type="text" placeholder="username" name="username"><input type="password" placeholder="password" name="password"><input type="submit" value="Submit"></form> This will be a simple register page where users can enter their desired username and password, then click the submit button to register button to make an account. "register.php" will be the script that will be executed when they register. This processes the user information and enters the information to the database <form method="post" action="register.php"><input type="text" placeholder="Desired Username"><input type="password" placeholder="Desired Password"><input type="password" placeholder="Password Again"><input type="submit" value="Register"></form> Step 2: Creating the login.php and register.php scripts Login Script<?phpsession_start(); //Starts User Session... will explain laterinclude("connect.php")//I'm going to assume you know how to connect to a database.$username = $_POST["username"];$password = $_POST["password"];//Sanitize DATA HERE//Assuming you have the corresponding column names...$q = mysqli_query($connect, "SELECT * FROM users WHERE username='$username' AND password='$password' ")$numrows = mysqli_num_rows($q);//Here we get the number of rows that correspond with the users informationif($numrows == 1){//If the number of rows is equal to 1, let them loginwhile($rows = mysqli_fetch_assoc($q)){//Here we retrieve values from database and initiate SESSION Variables $_SESSION["username"] = $row["username"]; $_SESSION["password"] = $row["password"];}header("location: memberspage.php")//redirect to members page... information correct.} else {header("location: index.php")//go back to login page... information incorrect.//error message here...} Register Script<?phpsession_start(); //Starts User Session... will explain laterinclude("connect.php")//I'm going to assume you know how to connect to a database.$username = $_POST["username"];$password = $_POST["password"];$password2 = $_POST["confirm"];//Sanitize DATA HEREif($password == $password2){//Assuming you have the corresponding column names...$q = mysqli_query($connect, "SELECT * FROM users WHERE username='$username'")$numrows = mysqli_num_rows($q);//Check if username is taken...if($numrows == 0){//If the number of rows is equal to 0, let them register$q = mysqli_query($connect, "INSERT INTO users (username, password) VALUES ('$username', '$password")header("location: index.php")//redirect to login page//login success message here} else {header("location: index.php")//go back to login page//username taken message}} else {//password no match message} Step 3: Members Page This is the members page... you can only access this page after login. memberspage.php<?phpif(!isset($_SESSION["username"])){//IF user is not logged in, redirect to login page. This checks whether the username session var has been created yet.header("location: index.php");}//else... load the members page?><!DOCTYPE html><!--HTML HERE FOR MEMBERS PAGE--> This is pretty much it... Remember to change column names where necessary... Don't forget the connect.php file ! Its is suggested you change mysqli_query() to prepared statements. You can do this on your own.
  15. Im, a beginner and i just wanna know how to save html table data to mysql database using php..please help..thank you
  16. One example of a multiple query, which runs fine in my server is: SELECT city, name FROM customers However, another way (though not a better way) of writing same has been running fine in a tutorial I saw, but is not running in my case: SELECT city FROM customers; SELECT name FROM customers; I would appreciate any thought on why it runs for that person and not for me, noting that there was no typos in my queries, which I attempted many times. MySQL Server version: 5.6.16, Xampp 1.8.33 for windows.
  17. I want to update users when they purchase premium by their email OR database ID, either one would work, BUT the only way it's working for me at the moment is by me entering their ID in the $_SESSION at the top. I want the page to get the users ID OR email after they purchase. I have asked this many places and have got no answer, people basically tell me to just type it. That would be crazy to do that for every single user. If you have an answer, PLEASE! I literally beg for you to copy the code above and place stuff where it needs to be, I've been stuck for days/weeks. I've tried EVERYTHING, except the right thing. Nothing is working for me on this, I also can't find anything on Google about it. I'm not an expert with PHP, so I may be missing bits, if I am, feel free to tell me I'm doing it wrong and let me know what I need to do. <?phprequire_once ('vendor/autoload.php');$_SESSION['user_id'] = '?';$stripe = array( "secret_key" => "sk_test_vDYOBYxCErhrgGCeWQJhR4mQ", "publishable_key" => "pk_test_4mIuE3OsajKO4cnFppcDDISu" ); StripeStripe::setApiKey($stripe['secret_key']);$db = new PDO('mysql:host=127.0.0.1;dbname=blog', 'root', '');$userQuery = $db->prepare(" SELECT id, username, email, premium FROM users WHERE id = id "); $userQuery->execute(['user_id' => $_SESSION['user_id']]); $users = $userQuery->fetchObject();
  18. hello so i created a registration page in html and a php code to connect to a database and enter the information to the database that all works. Now i want to ask if the user wants to log in would they need a separate php code to have a sort of certification that the account is valid? i made a html page for login but i need it to look back to the database to see if the user is registered so they can log in, not just anyone can log in...any ideas? or advice where i can find information about this? i see a lot of tutorials for making a log in page, making a registration page but how about when someone registers and wants to log in but to make sure the database can also check to see if the user is registered.
  19. Cat and sub category Table (cat_tbl) : id | cat_n | parent_id1 | cat | 02 | dog | 03 | tiger | 24 | lion | 05 | abc | 06 | bcd | 3 Now i have a product table as below (prod_tbl) : id | pwght | cid | cpid10 | 1.2 | 1 | 011 | 2.4 | 2 | 012 | 3.4 | 2 | 013 | 4.5 | 6 | 3 and user final weight product table is below (userprod_tbl) id | pwght | cid | cpid | prod_id ( is above prod_tbl primary id )1 | 1.1 | 1 | 0 | 102 | 2.3 | 2 | 0 | 113 | 3.1 | 3 | 2 | 124 | 4.0 | 6 | 3 | 13 **RESULT : ( OUTPUT WHICH I WANT ) IS comparison of prod_tbl with userprod_tbl as below :** Prod tbl Userprod tblcat 1.2 cat 1.1dog 2.4 dog -- -- 2.3dog 3.4 dog tiger -- 3.1dog 4.5 dog tiger bcd 4.0 Hence in above result 2.4,3.4,4.5 are belong to Parent 2**But i am getting as below** Prod tbl Userprod tblcat 1.2 cat 1.1dog 2.4 dog -- -- 2.3dog 3.4 dog tiger -- 3.1 here i am not getting 4.5 value as 4.5 has 6,3 relation from above prod table but its parent of 2**Below is my query which i have return:** SELECT pt.pwght , upt.pwght ,ct.cat_n,uct.cat_n,umct.cat_nFROM prod_tbl AS ptLEFT JOIN userprod_tbl AS upt ON (pt.id = upt.prod_id)LEFT JOIN cat_tbl AS ct ON pt.packet_id = ct.idLEFT JOIN cat_tbl AS uct ON upt.packet_id = uct.idLEFT JOIN cat_tbl AS umct ON upt.parent_packet_id = umct.id Please let me know what is missingThanks
  20. Hi everybody!Im newbie to php. please,suppose we have a MYSQL DATABASE with table CUSTOMERS.In the page: addCustomer.php, we echoed this table and it returned us a number of rows.on the same page, we have a form that contains empty fields. (name, birth, adress).Questions:How to add a button front of each displayed row? and how to when we click on the related button we fill the content of the form and submit it to the table CUSTOMERS. we want to verify if the customer exists when echoing...if so we click on the relative row, and the form is filled. if no we fill the form manually thanks <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"><!--.style2 {font-size: 36px}.style4 {font-size: 24px}#hauttableau { background-color:black; color:white; text-align:center; padding:5px;}--></style><script language="JavaScript" type="text/JavaScript"><!--function MM_reloadPage(init) { //reloads the window if Nav4 resized if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) { document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }} else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();}MM_reloadPage(true);//--></script></head><body><p align="left" class="style2">NOUVEAU CLIENT </p><form name="form1" method="post" action="insert_pdo_ajout_client.php"> <p class="style4"></p> <p><span class="style4">CLIENT</span> </p> <p> NOM CLIENT<input name="nomclientField" type="text" id="nomclientField"> <p> PRENOM <input name="prenomclientField" type="text" id="prenomclientField"> <p>ADRESSE <input name="adresseclientField" type="text" id="adresseclientField"></p> <p>DATE NAISSANCE <input name="datedenaissanceField" type="text" id="datedenaissanceField"></p> <p> CIN <input name="cinclientField" type="text" id="cinclientField"> </p> <p>TEL <input name="telclientField" type="text" id="telclientField2"> </p> <p> <input type="submit" name="Submit" value="ENREGISTRER"> </p></form><p class="style2"> </p><?phpecho "<table style='border: solid 2px black;' class= 'hauttableau'>"; echo "<tr><th>Id</th><th>Firstname</th><th>Lastname</th></tr>";class TableRows extends RecursiveIteratorIterator { function __construct($it) { parent::__construct($it, self::LEAVES_ONLY); } function current() { return "<td style='width: 150px; border: 1px solid black;'>" . parent::current(). "</td>"; } function beginChildren() { echo "<tr>"; } function endChildren() { echo "</tr>" . "n"; }}$servername = "localhost";$username = "root";$password = "root";$dbname = "zg";try { $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $conn->prepare("SELECT idclient, nomclient,prenomclient,datedenaissanceclient,adresseclient, cinclient,telclient FROM client"); $stmt->execute(); // set the resulting array to associative $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) { echo $v; }}catch(PDOException $e) { echo "Error: " . $e->getMessage();}$conn = null;echo "</table>";?> </body></html>
  21. I love what w3schools is doing with the SQL tutorial - good stuff. I noticed that one of the most fundamental elements of w3schools (the "Try it now" button) goes missing about half-way through the SQL Tutorial. May I ask why? I teach sql at a local community colleg. I have gone through several textbooks with mixed results, and I am always keeping my eyes open for new ways to teach. I would love to incorporate w3schools SQL tutorial into my class; do you have a db dump available for download of the tables you use? One of my lessons will be having students figuring out how to get the data from the tutorial into a local database, but having the entire dataset available up front would be handy. If such a db dump is not available, no worries - easy enough to generate one. Thanks again for your time and attention.
  22. I need to upload my images to a folder and need the image name with file type to be places in a mysql database so it can be accessed by another page. This is my php where everything works except uploading the image name to the database; Instaead the column is populated with the word array. Does anyone know how to fix this. MySql column is set to varchar(50). <?php require_once("connect.php"); $name = $_POST['job_name']; $img = $_FILES['job_timg']; $desc = $_POST['job_desc']; $plug = "INSERT INTO tbl_job VALUES (NULL,'".$name."','".$desc."', '".$img."')"; $Set = mysql_query($plug); if($Set==1){ $qJob = "SELECT * FROM tbl_job WHERE job_name = '".$name."' "; $Result = mysql_query($qJob); $row = mysql_fetch_array($Result); $lastID = $row['job_id']; $Link1 = "INSERT INTO tbl_l_ji(ji_id, job_id, image_id) VALUES(NULL, '".$lastID."','".$cat."')"; $place1 = mysql_query($Link1); header("Location: index.php"); }else{ } if($_POST){// $_FILES["file"]["error"] is HTTP File Upload variables $_FILES["file"] "file" is the name of input field you have in form tag.if ($_FILES["job_timg"]["error"] > 0){// if there is error in file uploadingecho "Return Code: " . $_FILES["job_timg"]["error"] . "<br />";}else{// check if file already exit in "images" folder.if (file_exists("_/img/" . $_FILES["job_timg"]["name"])){echo $_FILES["job_timg"]["name"] . " already exists. ";}else{ //move_uploaded_file function will upload your image. if you want to resize image before uploading see this link http://b2atutorials.blogspot.com/2013/06/how-to-upload-and-resize-image-for.htmlif(move_uploaded_file($_FILES["job_timg"]["tmp_name"],"_/img/" . $_FILES["job_timg"]["name"])){// If file has uploaded successfully, store its name in data base$query_image = "INSERT INTO tbl_job (job_timg) VALUES ('".$_FILES['job_timg']['name'].")";if(mysql_query($query_image)){echo "Stored in: " . "_/img/" . $_FILES["job_timg"]["name"];}else{echo 'File name not stored in database';}}}}}?> My Form: div class="container"> <div class="row"> <div class="twelvecol last"> <form action="add_site.php" method="post" enctype="multipart/form-data"> <!--add in the enctype in order to handle file management--> <label>Name:</label><br> <input name="job_name" type="text" size="32"><br><br> <label>Job Front Image:</label><br> <input name="job_timg" type="file" size="32"><br><br> <label>Description:</label><br> <textarea name="job_desc" cols="80" rows="10"></textarea><br><br> </select><br><br> <input type="submit" value="Add Job"> </form> </div> Thank you, Connor McDonald
  23. RaRa3

    registration php

    hello so i am making a registration page using html and php, i need to make the information send to mysql that i made with table but i never made select statements..i am not sure on how to make it i need help i am new to this so please bare with me. So I this code to connect to mysql none I am not sure how to fix it i know there must be a problem with the code for the submit line and with the isset. I got them from another user but made minor changes to fit my database. My database has 2 tables one named UserAccount with the information listed in the registration page and then another table named Cart for purchases to be made. Please if you can help me with my code or if you see other errors i think i might have an error with my php where i put firstName, and etc. and if you know any other material or links that would help me for making product information and a cart send to a database if you can share it, im trying but having many issues
  24. Cat and sub category Table (cat_tbl) : id| cat_n | parent_id1 | cat | 02 | dog | 03 | tiger | 24 | lion | 05 | abc | 06 | bcd | 3 Now i have a product table as below (prod_tbl) : id | pwght | cid | cpid10 | 1.2 | 1 | 011 | 2.4 | 2 | 012 | 3.4 | 2 | 013 | 4.5 | 6 | 3 and user final weight product table is below (userprod_tbl) id | pwght | cid | cpid | prod_id ( is above prod_tbl primary id )1 | 1.1 | 1 | 0 | 102 | 2.3 | 2 | 0 | 113 | 3.1 | 3 | 2 | 124 | 4.0 | 6 | 3 | 13 **RESULT : ( OUTPUT WHICH I WANT ) IS comparison of prod_tbl with userprod_tbl as below :** Prod tbl Userprod tblcat 1.2 cat 1.1dog 2.4 dog -- -- 2.3dog 3.4 dog tiger -- 3.1dog 4.5 dog tiger bcd 4.0 Hence in above result 2.4,3.4,4.5 are belong to Parent 2**But i am getting as below** Prod tbl Userprod tblcat 1.2 cat 1.1dog 2.4 dog -- -- 2.3dog 3.4 dog tiger -- 3.1here i am not getting 4.5 value as 4.5 has 6,3 relation from above prod table but its parent of 2 **Below is my query which i have return:** SELECT pt.pwght , upt.pwght ,ct.cat_n,uct.cat_n,umct.cat_nFROM prod_tbl AS ptLEFT JOIN userprod_tbl AS upt ON (pt.id = upt.prod_id)LEFT JOIN cat_tbl AS ct ON pt.packet_id = ct.idLEFT JOIN cat_tbl AS uct ON upt.packet_id = uct.idLEFT JOIN cat_tbl AS umct ON upt.parent_packet_id = umct.id Please let me know what is missingThanks
  25. I have a mySQL posts table, a files table, and a relationships table. I need to sum file download counts grouped by the post the files are associated with. SELECTp.id, p.post_title, count(d.download_id) FROM posts p INNER JOIN file_log d ON p.id = d.file_idgroup by p.post_title The above query works as long as the titles of the files are the same, which is not always the case. I really need to group them by their relationship to the post they are associated with. The relationships are stored in relationships r, which shows r.post_id (which is p.id from posts), and r.file_id (which is d.file_id from file_log) I have tried a few subqueries, but I am not sure how to join the relationships table to my query and group counts by r.post_id Thanks for any help.
×
×
  • Create New...