newb Posted June 18, 2006 Share Posted June 18, 2006 [code]<?php include "../inc/connect.php"; $query = "SELECT fullsize FROM table1,table2 WHERE id='%'"; $result = mysql_query( $query ); if ( !$result ) { die($query.'<br />'.mysql_error()); } // Build Table while( $row = mysql_fetch_assoc( $result ) ) { echo "<br /><br />$row[fullsize]"; } ?>[/code]thats the code, what i want it to do is echo the fullsize of the image to the page when the url is view.php?id=1 or id=2 or id=3, etc...the data thats in the fullsize field is this:[code]<img border='0' src='http://mysite.com/image.jpg'>[/code]can anyone help me? please i been trying to figure this out for a long time kthanks. Quote Link to comment Share on other sites More sharing options...
poirot Posted June 18, 2006 Share Posted June 18, 2006 Why are you querying 2 tables? What is the table structure?How are the images stored? Quote Link to comment Share on other sites More sharing options...
newb Posted June 18, 2006 Author Share Posted June 18, 2006 im querying two tables because they both contain fullsize images i need to echo on that page when the url is view.php?id=1, 2, etc...the two tables have the same exact field names too. they just have different data in the fields. table1 contains id's 1-17 and table2 contains id's 18-49. Quote Link to comment Share on other sites More sharing options...
newb Posted June 18, 2006 Author Share Posted June 18, 2006 :( Quote Link to comment Share on other sites More sharing options...
trq Posted June 18, 2006 Share Posted June 18, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]table1 contains id's 1-17 and table2 contains id's 18-49.[/quote]Then you need to rethink your database design. Look into database normalization techniques. Quote Link to comment Share on other sites More sharing options...
newb Posted June 18, 2006 Author Share Posted June 18, 2006 [!--quoteo(post=385463:date=Jun 18 2006, 07:22 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 18 2006, 07:22 PM) [snapback]385463[/snapback][/div][div class=\'quotemain\'][!--quotec--]Then you need to rethink your database design. Look into database normalization techniques.[/quote]what do u mean???? Quote Link to comment Share on other sites More sharing options...
AndyB Posted June 18, 2006 Share Posted June 18, 2006 [!--quoteo(post=385465:date=Jun 18 2006, 07:27 PM:name=newb)--][div class=\'quotetop\']QUOTE(newb @ Jun 18 2006, 07:27 PM) [snapback]385465[/snapback][/div][div class=\'quotemain\'][!--quotec--]what do u mean????[/quote]Let's start slowly. Why do you have two database tables that contain the same fields for what appears to be the same type of data? Is the content of your 'full image' database field the name of the image, the image itself (as a blob field), or the html code you posted? Quote Link to comment Share on other sites More sharing options...
trq Posted June 18, 2006 Share Posted June 18, 2006 Why do you have two tables containing the same data? There is very rarely a good reason for this.As I said.... Look into database normalization techniques. Quote Link to comment Share on other sites More sharing options...
newb Posted June 18, 2006 Author Share Posted June 18, 2006 the two tables dont contain the same data, i never said that. i just said that the two tables contain the same field names. the data inside the fields are different though.[quote]Is the content of your 'full image' database field the name of the image, the image itself (as a blob field), or the html code you posted?[/quote][code]<img border='0' src='http://mysite.com/image.jpg'>[/code]that html code is in the 'fullsize' field of table2 in the 'id 18' field. i want that to echo when the browser's url is view.php?id=18i hope i cleared up a bit. Quote Link to comment Share on other sites More sharing options...
trq Posted June 19, 2006 Share Posted June 19, 2006 can I see what data is in table 1 where id = 15 please? Quote Link to comment Share on other sites More sharing options...
poirot Posted June 19, 2006 Share Posted June 19, 2006 [!--quoteo(post=385471:date=Jun 18 2006, 04:40 PM:name=newb)--][div class=\'quotetop\']QUOTE(newb @ Jun 18 2006, 04:40 PM) [snapback]385471[/snapback][/div][div class=\'quotemain\'][!--quotec--]the two tables dont contain the same data, i never said that. i just said that the two tables contain the same field names. the data inside the fields are different though.[code]<img border='0' src='http://mysite.com/image.jpg'>[/code]that html code is in the 'fullsize' field of table2 in the 'id 18' field. i want that to echo when the browser's url is view.php?id=18i hope i cleared up a bit.[/quote]I think that what he means is: "why do you have different tables when you could put them all in the same"?Like:table1:id, image [ids 1-15]table2:id. image [ids-16-26]There is no point in doing this. Quote Link to comment Share on other sites More sharing options...
newb Posted June 19, 2006 Author Share Posted June 19, 2006 [quote]can I see what data is in table 1 where id = 15 please?[/quote]yeah sure.[img src=\"http://img230.imageshack.us/img230/3748/data1ut.jpg\" border=\"0\" alt=\"IPB Image\" /]there's what it look like.[!--quoteo(post=385487:date=Jun 18 2006, 09:41 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 18 2006, 09:41 PM) [snapback]385487[/snapback][/div][div class=\'quotemain\'][!--quotec--]I think that what he means is: "why do you have different tables when you could put them all in the same"?Like:table1:id, image [ids 1-15]table2:id. image [ids-16-26]There is no point in doing this.[/quote]itll help me organize them better. some pictures belong in certain sections on the site. Quote Link to comment Share on other sites More sharing options...
poirot Posted June 19, 2006 Share Posted June 19, 2006 1st: Using VARCHAR for id's may be cumbersome. Using INT & AUTO_INCREMENT & PRIMARY KEY for id's is a good idea.2nd: Why are you storing HTML code in "thumb" and "fullsize"? Store just the image name - unless you want to change the <img> attributes for each image.[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]itll help me organize them better. some pictures belong in certain sections on the site.[/quote]3rd: Not a good practice, normalize your database. You may add a new field called category if you need one. Quote Link to comment Share on other sites More sharing options...
newb Posted June 19, 2006 Author Share Posted June 19, 2006 oh ok, will merge/normalize the tables then since they have the same fields. is there a way i can do this quickly since they all have the same fields so then i dont have to re-enter all the data again? Quote Link to comment Share on other sites More sharing options...
newb Posted June 19, 2006 Author Share Posted June 19, 2006 nevermind, i found the SQL query on how to merge the two tables into one. it's this:[code]CREATE TABLE `newtable` ( `id` varchar(32) NOT NULL default '', `title` varchar(32) NOT NULL default '', `artist` varchar(32) NOT NULL default '', `size` varchar(32) NOT NULL default '', `thumb` text NOT NULL, `fullsize` text NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1;INSERT INTO `newtable`Select * from table1UNIONSelect * from table2;[/code]thanks for the help guys. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.