Jump to content

yobo

Members
  • Posts

    87
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

yobo's Achievements

Member

Member (2/5)

0

Reputation

  1. yobo

    Mysql Join Issue

    Thanks Barand, But I am still getting errors; mysql> select postname, name from posts p join lookup l on p.id = l.postid join postcategory c on l.categoryid = c.id; ERROR 1146 (42S02): Table 'p3-blog.lookup' doesn't exist mysql> select postname, name from posts p join category l on p.id = l.postid jo in postcategory c on l.categoryid = c.id; ERROR 1054 (42S22): Unknown column 'l.postid' in 'on clause' mysql> select postname, name from posts p join postcategory l on p.id = l.posti d join postcategory c on l.categoryid = c.id; ERROR 1054 (42S22): Unknown column 'name' in 'field list' mysql> select postname from posts p join postcategory l on p.id = l.postid join postcategory c on l.categoryid = c.id; I have replaced the names with my tables: my lookup table is called 'postcategory' my category table is called 'category' and my posts table is called 'posts'
  2. yobo

    Mysql Join Issue

    Thanks Barand for your help however I am still getting errors, from folling your guidance, my lookup table is called 'postcategory' my category table is called 'category' and my posts table is called 'posts' using your sQL above mysql> select postname, name from posts p join lookup 1 on p.id = 1.postid join postcategory c on 1.categoryid = c.id; I get a Mysql error.
  3. Hello All, I am working on a small PHP / Mysql project and I have ran aground on this issue, and I am looking for some advice as to why this is not working. What I am trying to acheive is to show a list of blog post titles, along with their respective categories that they are assigned too, However I am unable to get my query to work. below are my 3 tables structure: The Posts table +-------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | postname | varchar(255) | NO | | NULL | | | postcontent | varchar(255) | NO | | NULL | | | postdate | date | NO | | NULL | | | authorid | int(11) | NO | | NULL | | +-------------+--------------+------+-----+---------+----------------+ The Category Table +-------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(255) | NO | | NULL | | +-------+--------------+------+-----+---------+----------------+ The Lookup table +------------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+---------+------+-----+---------+-------+ | postid | int(11) | NO | PRI | 0 | | | categoryid | int(11) | NO | PRI | 0 | | +------------+---------+------+-----+---------+-------+ My query mysql> select id, postname from posts join postcategory on posts.id = categoryid; Empty set (0.00 sec) so far example it should look like this on the web page Post Name Post Category Linux DNS How Too Linux Windows 10 Hacks Windoiws Again grateful for any help. Joe
  4. Hey All, I am having some issues my data gets added to the database ok but since I am using a header redirection (to clear the $_post variable) my success message is not displayed or my error if there is an error. Basically I would like my message to be displayed just above the form to say success it worked or error if it did not. header("Location: addproduct.php"); echo ' <div class="span9" id="content"> <div class="alert alert-success"> <div id="success"><p>Product has been added to the database</p></div> </div> </div>'; exit; the above code is a snippet of my main code I am also using ajax to help with this. my simple ajax code $('#btnSave').click(function() { $.post($("#addproduct").attr("action"), data, function(info){ $("#success").html(info); }); clearInput()); }); $("#addproduct").submit( function() { return false; }); function clearInput() { $("#addproduct :input").each( function() { $(this).val(''); }); } Many Thanks J
  5. Hey All, I am in the process of learning PHP so I am not an expert by any means. I am looking for some advice on how I would go about implementing this idea. 1. I have a page called addproduct.php with a form and which also includes the header.php file 2. when the form is submitted on the addproduct.php it goes to the database processing script called addproduct-func.php, 3. the addproduct-func.php page has a conditional that checks to see if the database query succeeded if so it redirects using the header function back to addproduct.php. however what I would like to implement is some form validation and checking before it gets submitted to the addproduct-func.php and only if validation and form checking passes then goto addproduct-func.php. I also would like to output a little success msg informing the user that the record had been added to the database just above the addproduct.php form. I am using bootstrap as my css framework. Many Thanks for your time and help J
  6. Hey All I have a page where a users types in a number and using Ajax if that number exsist in the DB it will say on the same page "this record was found in the DB click here to view this record" and the opposite happens if the record does not exsist instead of view the record a link says "not found click here to create this record" now this is where I cant seem to find solutions in my Ajax books at the moment when a user clicks the link it goes to the correnponding page example "addrecord.php or viewrecord.php" what I would like is for a popup to show with the content of those pages rather than going to the seperate pages unless JS has been disabled. hope that kinda makes sense Joe
  7. Hey All, I am making a small application to help me learn, my question is this I am making a page where the users enters a number asset number that is they click submit and if that record exsists it will have a link underneath the input box saying record found click here to view details if the record does not exsist there will be a link saying record not found click here to add the record. my problem is that I dont know how to do this on one page I can do it with seperate pages but not sure how to do it on one any ideas please? Joe
  8. Hey Guys, I am having a strange issue I have a form where a user can enter there name and it will echo it out on the next page (it is a bigger script but i am doing some testing bit by bit) The form page <form action="includes/runtime.php" method="post"> <p>Asset ID: <input type="text" name="asset_id" size="15" maxlength="20" value="<?php echo $_GET['asset_id'];?>" /></p> <label>Select Hardware Type:</label><select name="hw_type"> </select> <input type="hidden" name="rma_status" size="20" maxlength="20" value="New"/> <p>Submitter Name: <input type="text" name="name" size="20" maxlength="20"/></p> <p>Fault Description: <textarea name="fault_desc" rows="20" cols="30"></textarea></p> <p><input type="submit" name="submit" value="Add Record" /></p> <input type="hidden" name="newrma" value="new"/> </form> and the runtime page code foreach ($_POST as $key => $value) { $post[$key] = $value; echo $post['name']; } basically it echos the value of name but outputs 4 copies for example if i added name john it would output JohnJohnJohnJohn I only need it to output the once any ideas J
×
×
  • 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.