Jump to content

need some help with a kinda complicated code (maybe)


newb

Recommended Posts

[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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

[!--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.
Link to comment
Share on other sites

[!--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????
Link to comment
Share on other sites

[!--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?
Link to comment
Share on other sites

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=18

i hope i cleared up a bit.
Link to comment
Share on other sites

[!--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=18

i 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.
Link to comment
Share on other sites

[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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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 table1
UNION
Select * from table2;
[/code]

thanks for the help guys.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.