Jump to content

shenagsandnags

Members
  • Posts

    34
  • Joined

  • Last visited

    Never

Everything posted by shenagsandnags

  1. been trying to get a code up and working for a update database form, couldnt really get any working i found from google and then after a bit of help from here i got a crazy idea and stopped dead and my tracks and switched gears. so i thought, why not just use the form i used to insert my database and change it around a little. same concept, how should this not be possible ? for reference here are my tables and structure Movies ID(PK) Title Category(FK) URL 0 Name 1 http://www. Categories ID(PK) Category 1 Drama note: i know i should change Category from movies to CategoryID for less confusion. to make long story short when i tried i got errors, to much time to go back over everything so i will just stick with what i got for now. ok so my insert form inserts a movie title,category and url into my movies table. the dropdown for category is populated with a list of categories in my categories table, the way the code is writen it shows the actual category name instead of the id inside the dropdown. the form goes like: Title: textfield1 Category:dropdown URL:textfield2 so what i did was took the code from it, replaced title textfield1 with the same dropdown for category and just edited the select and echo to pull and show movie titles. i also added a WHERE to it so i can only select titles in a certian category. so it should look like, Title: dropdown Category:dropdown so here is the code below (ignore leftovers from URL or anything else i plan on taken them out pending the outcome) <html> <form id="form1" name="Update" method="post" action="ad3.php"> <label> Title: <input type="text" name="Title" id="Title" /> </label> <br /> <select name='dropdownt' id='dropdownt'> <?php $con = mysql_connect("localhost", "root", ""); if (!$con) { die('Could not connect to DB: ' . mysql_error() ); } mysql_select_db ("5", $con); $query = "SELECT Title FROM movies WHERE Category='1'"; $result = mysql_query($query) OR DIE ("There was an error" .mysql_error()); while($row=mysql_fetch_array($result)) { echo " <option value=\"{$row['Title']}\">{$row['Title']}</option>"; } php?> </select> <select name='dropdown' id='dropdown'> <?php $con = mysql_connect("localhost", "root", ""); if (!$con) { die('Could not connect to DB: ' . mysql_error() ); } mysql_select_db ("5", $con); $query = "SELECT ID, Category from categories"; $result = mysql_query($query) OR DIE ("There was an error" .mysql_error()); while($row=mysql_fetch_array($result)) { echo " <option value=\"{$row['ID']}\">{$row['Category']}</option>"; } php?> </select> <input name="" type="submit" value="send" /> </form> </html> one thing that i could not figure out (due to my lack of php knownledge) is that after my SELECT i have the echo " <option value=\"{$row['Title']}\">{$row['Title']}</option>"; before i had edited this code there was ID where the first 'Title' is. after trying to take one part of that out i got a error so i just left it. so what i thought i would do for the process page (ad3.php) i would just turn the INSERT into a UPDATE. <?php $con = mysql_connect("localhost", "root", ""); if (!$con) { die('Could not connect to DB: ' . mysql_error() ); } mysql_select_db ("5", $con); $sql="UPDATE movies SET Category = '$_POST[dropdown]', Title = '$_POST[dropdownt]' LIMIT 1"; if (!mysql_query($sql,$con)) { die ('Error: ' . mysql_error()); } echo "<a href=\"form2.php\">Record added. Click here to make a new entry</a>"; the surprising thing (to me anyways) is that it actually worked! well.. ALMOST it should work by letting me select a certian title thats in a certian category and change its current category into a different one and then submit. after a few hours i finaly got it to do what i need BUT the problem i am having is that when looking into my phpmyadmin, it just changes the name and category to the first record in my movies table which is id "0". one of the too. i almost done it on my own.. almost... sorry for the extended post but i didnt want to leave anyone confused. so my question is, did i forget to add anything, take anything out, miss a change i needed to make ? maybe its the echos after my SELECT in my form >
  2. again my tables are movies| ID(PK) - Titles - Category(FK) - URL 0 Name 1 www.xyz.com categories| ID(PK) - Category 1 Comedy say i create a query SELECT * FROM movies WHERE Category="1" and it gave me all the movies from my table that is in the comedy category which should look like this: ID - Title - Category - URL 0 Name Comedy www.xyz 1 xyz Comedy www.abc etc.. How can i add a drop down menu beside each movie listed in that result that would let me change the category for it and save it ? like this, ID - Title - Category - URL 0 Name Comedy www.xyz [Dropdown] 1 xyz Comedy www.abc [Dropdown] [save Button] being a newbie im going to guess that i will need a INSERT in here somewhere and not really sure how i would write my result echos. i have been trying all kinds of "update records" forms and cant get them right so i figured it may be easier to just try and create my own. if i could get some example or if you have more simple suggestions
  3. you know its weird because i should have already known that but it just goes to show how not focusing on one thing at a time will make you over look the simple solutions. thanks guys works great!
  4. here is my form layout, Title: txtfield URL: txtfield Category: dropdown (pulls the just category fields in my "categories" table submit - when working right this form is suppose to enter this info into my "movies" table. Code to form.php <html> <form id="form1" name="Update" method="post" action="add3.php"> <label> Title: <input type="text" name="Title" id="Title" /> </label> <br /> <label> URL: <input type="text" name="URL" id="URL" /> </label> <select name='dropdown' id='dropdown'> <?php $con = mysql_connect("localhost", "root", ""); if (!$con) { die('Could not connect to DB: ' . mysql_error() ); } mysql_select_db ("mydb", $con); $query = "SELECT Category from categories"; $result = mysql_query($query) OR DIE ("There was an error" .mysql_error()); while($row=mysql_fetch_array($result)) { $category = $row['Category']; echo " <option value=\"$category\">$category</option>"; } php?> </select> <input name="" type="submit" value="send" /> </form> </html> then here is the code to the process page (add.php) <?php $con = mysql_connect("localhost", "root", ""); if (!$con) { die('Could not connect to DB: ' . mysql_error() ); } mysql_select_db ("m5", $con); $sql="INSERT INTO movies (Category, URL, Title) VALUES ('$_POST[dropdown]','$_POST[url]','$_POST[Title]')"; if (!mysql_query($sql,$con)) { die ('Error: ' . mysql_error()); } echo "Record added"; after i submit my form i get "Error: Cannot add or update a child row: a foreign key constraint fails (`mydb`.`movies`, CONSTRAINT `movies_ibfk_1` FOREIGN KEY (`Category`) REFERENCES `categories` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE)" correct me if im wrong but im almost %99 sure that my tables are set up correctly for my project. just to be sure, movies ------------ ID (PK) Title Category (FK) URL categories --------------- ID (PK) Category at first i was also getting a "undefined index" along with this error but i reversed the values in the INSERT so now im just getting the CONSTRAINT error so this now leaves me to beleive that i may have made a error one of the tags possibly. also while i was looking around i decided to create a different procces page hoping i would run into some quick luck: add3.php <?php $Category=$_POST['dropdown']; $URL=$_POST['URL']; $Title=$_POST['Title']; $con = mysql_connect("localhost", "root", ""); if (!$con) { die('Could not connect to DB: ' . mysql_error() ); } mysql_select_db ("mymb", $con); $query = "INSERT INTO movies VALUES ('$Category','$URL','Title')"; $result= mysql_query($query); if ($result) { echo "Successful"; } else { echo "Failed"; } mysql_close(); ?> and this one gives me "Failed" error. i have noticed that there are many many ways of doing this so i went ahead and posted both process page hoping this could give some better ideas rather then confusion (i hope anyways). im not really sure which ones its more along the lines of php/form "standard" if there is any but whichever may be the easiest for you to take a look at it doesnt matter and i would be greatly thankful. IMO i think its just a varriation of not having the formats right and just not taylored correctly to my needs. many thanks in advanced.
  5. hey all. i previously posted about how i lost all my data so im trying to recreate my form again. after not many replies from my desperate call for help i tried to figure it out on my own, i spent hours and hours going through this forum and others but im just running into brick walls because of my minor knowledge of php (though i do have to say i am picking it up a little!) my form is short and simple so this shouldnt be too hard but this is what i have come up with. my tables ---------------- Movies: ID(P_id),Title,Category (F_K),URL Categories: ID (P_Id),Category All i am needing my form to do is enter records into my movies table, therefore it goes like this: Title: "textbox" URL: "textbox" Category: "dropdown menu" "submit" now the thing here is that the dropdown menu needs to be populated with data from Category.Categories table so i can add that info into category in the movies table. so pretty much it will be sending the ID from Categories table into Category in the Movies and yes they both have the same datatype. so here is what i have so far. my form.php <html> <form id="form1" name="Update" method="post" action="add.php"> <label> First Name: <input type="text" name="Title" id="textfield" /> </label> <br /> <label> Last Name: <input type="text" name="URL" id="textfield2" /> </label> <select name='Category'> <?php $con = mysql_connect("localhost", "root", ""); if (!$con) { die('Could not connect to DB: ' . mysql_error() ); } mysql_select_db ("mydb", $con); $query = "SELECT Category from Catgories"; $result = mysql_query($query) OR DIE ("There was an error .mysql_error()); while ($line = mysql_fetch_array($result,MYSQL_ASSOC)){ $categoryid = $line["playerid"]; $category = $line["category"]; echo "<option value='$categoryid'>$category</option>\n"; } php?> </select> <input name="" type="submit" value="send" /> </form> </html> and then my add.php <?php $con = mysql_connect("localhost", "root", ""); if (!$con) { die('Could not connect to DB: ' . mysql_error() ); } mysql_select_db ("mydb", $con); $sql="INSERT INTO movies (title, url) VALUES ('$_POST[title]','$_POST[url]')"; if (!mysql_query($sql,$con)) { die ('Error: ' . mysql_error()); } echo "Record added"; so first things first, although i have tested the code its throwing me a variable error i think on line 30 so i figured that instead of focusing on just the error i should just have everything looked over since i dont have anyone i can turn to about this stuff to make sure i didnt forget any " or { etc.. i am also not sure if the while loop is even needed in form.php, i kind of taylored this code to my own needs. THEN i have the add.php, granted that by some miracle that the form.php is correct i dont know what else i would need to add to it for my dropdown. i really need this bad and i hope someone can help me you know. if anyone has any ideas for a more simple code please, enlighten me but just give me some good examples because i really am a beginner. thanks alot.
  6. sort of, it didnt have all those elements and such, tables etc. but if you leave me with just that code i will be lost. i know the actual form page itself is pretty simple. the 2 things that are really stopping me is i have no idea how to put the drop down box inside the form and make it pull the categories from the categories table and then the post.php i have no clue what the code was for it.
  7. had a leak in my home which ruinned my pc but luckly i had most of my project and db info backed up on a stick but i didnt have my forms backed up! can someone please help me! the form was actually pretty basic but since i am still new too php simple things are still a challenge. (my db is based off 2 tables Movies,Categories) Movies: ID,Title,Category(FK),URL Categories: ID,Category so the first part was for entering movie info into my movies table while selecting a category from the categories table. ----------------------------------------------- Title: (txt field) Category: a dropdown/combo box that would list the categories from the categories table. URL: (txt field) and a sumbit button. like i said this was a pretty basic form. the second part showed a single list of all my movie titles, when i selected one i was able to change the category that the title was listed in, i dont know how to explain how it was setup but i am in such a rush to get this fixed and caught back up that i dont care how this next one works as long as it lets me do what i needed it too do. i also had another that let me add/delete categores in the categories table but i can deal with that another time and just manually enter it with myphpadmin when needed because i have to get the above asap.. i will be so greatful if anyone can help me get my stuff back on!
  8. ok i have just now noticed this echo "<tr><td><a href='".$row['URL']."'>" . $row['Title'] . "</a></td></tr><br/>"; whenever i hover my mouse over one of the links, in my browsers status bar it will show it as if its in my root directory "http://www.mysite.com/root/www.google.com" instead of just "www.google.com". and obviously when clicked on it wont work. through out this whole process i haven't touch the <a href" line so im kinda clueless on this one. besides i need to add the target function in this but im not sure where and how to put it. i have tried, echo "<tr><td><a href='".$row['URL']."' target="_blank">" . $row['Title'] . "</a></td></tr><br/>"; and a few other things but i just get a syntax error. help me get this figured out so i can seal this topic before they start charging me rent lol.
  9. yea but shouldnt echo " . $row['Category'] . " echo "<a href='".$row['URL']."'>" . $row['Title'] . "</a>"; just give me: Drama Movie1 Movie2 Comedy Movie3 Horror Movie4 Movie5 ? believe it or not as dumb as i sound about php i use to know a little html back in the day. i do know how to create tables but i really dont care to have the tables for this code unless i absolutely have to (not sure if its required in php). just a simple listing without boarders and such as shown above would be just fine for me
  10. ok so when i test the code i displays like this, DramaMovie1Movie2ComedyMovie3HorrorMovie4Movie5 so technically speaking this is almost exactly what i wanted but obviously there is a problem with the "way" its displaying it which i assume thats why you were telling me about the elements. im pretty sure i understood you correctly so i tried what you suggested and even took out the elements completely but the displays are still not changing, maybe there is something i am forgetting. Even this does not change anything. echo "<td><th>" . $row['Category'] . "</td></th>"; $last_category = $row['Category']; // 'remember' the new category value } echo "<tr><td><a href='".$row['URL']."'>" . $row['Title'] . "</a></td></tr>"; i really dont care for the tables i would rather just keep it simple and have no tables and just put the category names in bold and walla! just as long as i can have them display vertically rather then horizontally but when i take out the elements it throws me a syntax error *scratching my head*
  11. like this ? <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydb", $con); $result = mysql_query("SELECT a.ID, a.Title, b.Category, a.URL FROM Movies AS a JOIN Categories b ON a.Category = b.ID ORDER BY b.Category"); $last_category = ''; // initialize to a value that will never exist in the data while($row = mysql_fetch_array($result)){ // test if the category changed if($last_category != $row['Category']){ echo "<td width='150'>" . $row['Category'] . "</td>"; $last_category = $row['Category']; // 'remember' the new category value } echo "<td width='100'><a href='".$row['URL']."'>" . $row['Title'] . "</a></td>"; } mysql_close($con); ?>
  12. lol STILL no difference. if its working for you then what else could it be on my end ? or have you even tested it yourself ?
  13. lol, still no difference. double check that i made correct changes. <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydb", $con); $result =mysql_query("SELECT DISTINCT category FROM categories"); $result_num=mysql_num_rows($result); if(!empty($result_numm)) { echo "<table>"; while($result_array=mysql_fetch_array($result)) { $category=$result_array['category']; echo "<tr><td style='border-bottom:dashed 1px #000000'>$category</td></tr>"; $check_table2=mysql_query(sprintf("SELECT * FROM movies WHERE ID='%s'", mysql_real_escape_string($category))); $check_table2_num=mysql_num_rows($check_table2); if(!empty($check_table2_num)) { while($check_table2_array=mysql_fetch_array($check_table2)) { $title=$check_table2_array['Title']; echo "<tr><td>$title</td></tr>"; } } } echo "</table>"; } mysql_close($con); ?>
  14. still no difference, lol your such a tease
  15. believe it or not still no difference, here is the exact code just to make sure that i didnt mess anything up myself. <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydb", $con); $result =mysql_query("SELECT DISTINCT category FROM categories"); $result_num=mysql_num_rows($result); if(!empty($result)) { echo "<table>"; while($result_array=mysql_fetch_array($result)) { $category=$result_array['category']; echo "<tr><td style='border-bottom:dashed 1px #000000'>$category</td></tr>"; $check_table2=mysql_query(sprintf("SELECT * FROM movies WHERE ID='%s'", mysql_real_escape_string($category))); $check_table2_num=mysql_num_rows($check_table2); if(!empty($check_table2_num)) { while($check_table2_array=mysql_fetch_array($check_table2)) { $title=$check_table2_array['Titles']; echo "<tr><td>$title</td></tr>"; } } } echo "</table>"; } mysql_close($con); ?> so close so close i can taste it!
  16. nope, no difference. btw im not sure if this will help or not but heres an exact example of both tables, Movies (FK) ID - Titles - Category - URL 2 Avatar 1 www.blahkjhkfdjk.com Categories ID - Category 1 Drama just want to make sure i didnt leave anything out
  17. <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydb", $con); ================================================= (the way you join two tables seems to be wrong....as category and id cannot be connected) movies: id - title - category - url categories: id - category (FK) $result =mysql_query("SELECT DISTINCT category FROM categories"); $result_num=mysql_num_rows($result); if(!empty($result)) { echo "<table>"; while($result_array=mysql_fetch_array($result)) { $category=$result_array['category']; echo "<tr><td style='border-bottom:dashed 1px #000000'>$category</td></tr>"; $check_table2=mysql_query(sprintf("SELECT * FROM movies WHERE category='%s'", mysql_real_escape_string($category))); $check_table2_num=mysql_num_rows($check_table2); if(!empty($check_table2_num)) { while($check_table2_array=mysql_fetch_array($check_table2)) { $title=$check_table2_array['title']; echo "<tr><td>$title</td></tr>"; } } } echo "</table>"; } dude, that is soooooooooo close! the above code gives me Drama ------------- Comedy ------------- Horror ------------- Thriller ------------- the only thing missing is it is not listing the movie titles under each category! could it be a simple change in the query ? sooo close!
  18. im sorry im not exactly sure what you ment by that, i kind of do but i dont. please dont assume that my echos and queries are right because the echos and queries you see in the code are just me trying to guess and hope they are correct. im confident that the first query is correct but anything else after that is more then likely going to be wrong for what im doing. query #1 and the syntax to the while loops were wrote for me by someone else and i was told to type in the echos myself and then i was just left in the wind. they assumed i knew what i was doing i guess... so i was kind of hoping that someone would tell me the correct queries and echos and send me on my marry way. IF its that simple because everyone has told me that it was but yet i dont know enough php yet. i will take whichever way i can to get it to work or just even the simplest, if i need 2 loops then fine by me if i only need 1 then even greater. i dont really care just as long as it displays the way i need.
  19. i need some quick help, this project has been way over due and ive wasted huge amounts of time researching on my own and bothering others trying to figure this out and i just cant leave it be its like a damn drug. im desperate folks! my 2 tables, movies: id - title - category - url categories: id - category (FK) what im trying to do is have every category list as a table and then list the movies owned by that category in them, example: Category 1 --------------- title title Category 2 -------------- title title Category 3 -------------- title title the code im using is <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydb", $con); $result = mysql_query("SELECT a.ID, a.Title, b.Category, a.URL FROM Movies AS a JOIN Categories b ON a.Category = b.ID ORDER BY b.Category"); echo "<table border='1'> <tr> <th>Title</th> <th>Category</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td width='100'><a href='".$row['URL']."'>" . $row['Title'] . "</a></td>"; echo "<td width='150'>" . $row['Category'] . "</td>"; } echo "</table>"; $result2 = mysql_query("SELECT ID,Category FROM Categories"); while($row2 = mysql_fetch_array($result2)) { echo "<tr>"; echo "<td>" . $row2['Title'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> but obviously this code gives me a single table that lists all the titles with category next to them and then under the table it lists my categorys from left to right and its looks like Title Category --------------------- title1 Drama title2 Comedy title3 Horror title4 Thriller -------------------- DramaComedyHorrorThriller what exactly do i need to change to display the results i want ? btw dont hammer me on using 2 while loops, some tell me i need 2 and others say 2 is pointless. i myself have no clue!
  20. Im back from fishing and look what i caught paw! <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("M5", $con); $result = mysql_query("SELECT a.ID, a.Title, b.Category, a.URL FROM Movies AS a JOIN Categories b ON a.Category = b.ID ORDER BY b.Category"); $result = mysql_query("SELECT Title From Movies"); while($row = mysql_fetch_array($result)) { echo "<table border='1'> <tr> <th>Title</th> <th>Category</th> </tr>"; echo "<tr>"; echo "<td>" . $row['Title'] . "</td>"; echo "<td>" . $row['Category'] . "</td>"; echo "</tr>"; while($row2 = mysql_fetch_array($result2)) { echo "<tr>"; echo "<td>" . $row2['Title'] . "</td>"; echo "</tr>"; } echo "</table>"; } i have a Undefined Index on line 30 and if i take that line out completely i get another error about a variable on the next line or so but obviously that is the least of my problems because i know i got something in this code messed up but i feel that im sooooo close. i learned that i should go with "while loops" and this is about as far as i can get. what is it that i have wrong ? i know that this post has went on a little too long but you have no idea how much your help has been!
  21. ok got it all sorted out now (thanks again, really) but the SELECT statement is not working like the way it supose to be so its gotta be something i am doing wrong again. I entered 4 sample movies into the database and then ran this as test.php <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("M5", $con); $result = mysql_query("SELECT a.ID, a.Title, b.Category, a.URL FROM Movies AS a JOIN Categories b ON a.Category = b.ID ORDER BY b.Category"); echo "<table border='1'> <tr> <th>Title</th> <th>Category</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['Title'] . "</td>"; echo "<td>" . $row['Category'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> and obviously from reading the code i get: Title | Category -------------------------------------- Date Night | Comedy Up in smoke | Comedy Titanic | Drama Avatar | Drama Saw Horror Instead of each one of those categories having their own table. Just with my little knowledge that i have, i have a feeling that this may have something to do with something in the mysql_fetch_array ??? i know its not typed out right for the SELECT.
  22. well i guess i suck at fishing... so after messing around with it some somehow i ended up changing the password to my db and got locked out of phpmyadmin. i dunno what the hell i did but i thought i had it working but couldnt test it out because something was going on with apache from a previous problem that i had forgot about. ANYWAYS, i started fresh on a different computer annnnnnd this is my story... once upon a time i created 2 tables in phpmyadmin. CREATE TABLE `M`.`Movies` ( `ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `Title` VARCHAR( 24 ) NOT NULL , `Category` SMALLINT( 11 ) NOT NULL , `URL` VARCHAR( 24 ) NOT NULL ) ENGINE = InnoDB; CREATE TABLE `M`.`Categories` ( `ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `Category` SMALLINT( 11 ) NOT NULL ) ENGINE = InnoDB; I then index Categories/Category and click on relational view to set FK. under relational view/Category (second drop down menu, not internal relations) i select M' 'Categories' 'Category' ON DELETE AND ON UPDATE both cascade, click save and it creates: ALTER TABLE `categories` ADD FOREIGN KEY ( `Category` ) REFERENCES `M`.`categories` ( `Category` ) ON DELETE CASCADE ON UPDATE CASCADE ; So i then go back to my categories table and attempt to insert some data under Category and i get a error: SQL query: Edit INSERT INTO `M`.`categories` ( `ID` , `Category` ) VALUES ( NULL , 'Drama' ) MySQL said: Documentation #1452 - Cannot add or update a child row: a foreign key constraint fails (`m`.`categories`, CONSTRAINT `categories_ibfk_1` FOREIGN KEY (`Category`) REFERENCES `categories` (`Category`) ON DELETE CASCADE ON UPDATE CASCADE) now i know what your thinking, im trying to type in letters in the value when its SMALLINT, well even when i try to put in a number i still get the same error. ok so before i had my dumbass attack and locked myself from my old DB i had actually used INT. well everything worked smooth untill after doing some views i realized that it was only showing numbers instead of the actual name of the categorys, its obvious why, so i switched to VARCHAR just for the hell of it and i thought i had it working but as i was about to test out the select code is when i realized my apache problem and then right after that is when i locked myself out. note that when doing all this i had been past due for bedtime by about 4 hours and only had about 4 hours of sleep that day so ITS hard telling what the hell i did but point being i wasnt gettin the error i am getting now on the new computer and DB. this is probably like pissing in the wind for you but its had me scratching my head for hours.. i dunno what i have done different. oh and by the way, if i am supose to set MOVIES/Category and CATEGORIES/Category both to a numerical data type such as SMALLINT then how am i supose to type in my Category names in my CATEGORIES table ? i am going to continue going back everything just incase its something simple im missing here.. sorry like i said im still new.
  23. ok great great this is what i needed! ok first question given the chance that i get to try this out before you see this i may have it figured out but just to be on the safe side. so first im going to make sure MOVIES/Category field and CATEGORIES/Category should both be INT/11 or VARCHAR/24 ? (im going with INT/11) and then as far as the keys, i forgot to mention while i was typin out my db structure in my post that ID in both tables are set to PRIMARY. as i am just learning i am going to take a wild guess and assume that you are telling me that i need to change ID on the CATEGORIES table to FOREIGN KEY OR set Category in CATEGORIES to FOREIGN KEY ? to make sure it points to the PRIMARY on MOVIES. just a little side question here, you dont have to reply if you dont have the time this is just more of being curious and wanting to know how things work. in the select that you typed out i noticed that using a and b before the fields (a.Title,b.Category, JOIN Categories b). from all the tutorials and lessons i have read i have never seen those used like that and maybe its something i just haven't got to yet but could you tell me exactly what those are doing ? BTW thanks for taking the time out for you previous reply because what you are showing me i am using to go back to the tutorials go back over everything and now i am seeing more of what makes X do Y because of something that i "created" in my head and i know for most people the tutorials may do just fine but for some reason the way my mind works those alone are just too difficult so this is giving me the hands on that i need. in other words thanks for help teaching me how too fish
  24. Before i go any further, here is the structure of my DB. i only have 2 tables. Movies Table _____________ ID |Title |Category |URL _________________________________________ 1 Avatar Action www.abc.com 2 Bait Thriller www.whatever.com 3 Conair Drama www.sddfssdd.com 4 Craft Horror www.gdgsdfsd.com 5 Erie Horror www.fsadfa.com 6 Fighter Drama www.lkjlkjl.com 7 GTown Action www.jkkjlk.com Categories Table ________________ ID |Category _________________ 10 Action 11 Drama 12 Horror 13 Thriller Ok so I need to create a php page and add a statement to retrieve data from 2 tables. i need the statement to create a table for each category listed in the CATEGORIES Table. Like so, Drama -------- Action -------- Thriller -------- Horror -------- Then i need to fill each one of those Category tables (above) with the titles from the MOVIES Table, depending which category the titles have next to them in the MOVIES Table is what determines which category table they will fall into. : Drama -------- Conair Fighter Action -------- Avatar Gtown Thriller -------- Biat Horror -------- Craft Erie Also keep in mind that there may be times that i need to Add/Delete categories and i hope that if i was too add a new category in the CATEGORIES Table it would automaticly show on my php page without having to edit my statement (i hope thats possible anyways). As far as what order the tables would go it would be kind of neat if it would show the Category with the most Titles in it to be placed at the top and so on. One last thing, you may notice that there is a URL field in the MOVIES Table. thats because when the titles are being shown in the php statement page results i need the title to be the actual link itself insteal of it showning the URL link beside the title. i have already asked this once before but i dont know how i would add this into all of the above. I hope i dont seem im asking for alot but the least anyone can do is point me in the right direction, details in what exactly im looking for. i have been reading about order and sorting over and over so much and im just stuck.
  25. lol.. yessss i do know some html and i plan on focusing on php/mysql fully but i atleast have to part time with MS untill i can switch completely over. meanwhile, i have been going over s--t loads of tutorials for php/mysql and i would have thought that i would have figured this one out on my own after about literally the 5th time but im still in the dark somehow. i thought maybe creating virtual tables with VIEW is what i would need to do but after reading surely there has to be a more simple method especially if i might be adding or moving around my Categories aka tables.
×
×
  • 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.