php4 how do I show images on a web page that are listed in m


#1

Hi I have been struggling for nearly two months, I have tried many different statergies, but I just can’t seem to figure out what I am doing wrong. Could someone please look at my code and let me know how I can display images on my web page

-- Table structure for table `project_details`
-- 

CREATE TABLE `project_details` (
  `project_id` int(10) unsigned NOT NULL auto_increment,
  `project_name` varchar(50) NOT NULL,
  `street` varchar(60) NOT NULL,
  `CityOrTown` varchar(50) NOT NULL,
  `county` varchar(30) default NULL,
  `country` varchar(50) NOT NULL default '',
  `pCode` varchar(30) NOT NULL,
  `description` text NOT NULL,
  `value` varchar(6) default NULL,
  `client` varchar(90) default NULL,
  `structEng` varchar(50) NOT NULL,
  `mContractor` varchar(50) NOT NULL,
  `projectType` varchar(25) default NULL,
  `projectType2` varchar(60) default NULL,
  `keywords` varchar(255) default NULL,
  `projectDate` datetime default NULL,
  `pImage_name` varchar(60) default NULL,
  `image_name` varchar(60) default NULL,
  PRIMARY KEY  (`project_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=30 ;
-- Table structure for table `project_image`
-- 

CREATE TABLE `project_image` (
  `pImage_id` int(10) unsigned NOT NULL auto_increment,
  `project_id` int(10) unsigned NOT NULL default '0',
  `pImage_name` varchar(60) NOT NULL default '',
  `iDescription` varchar(255) default NULL,
  `image_name` varchar(30) default NULL,
  `iKeywords` varchar(255) default NULL,
  PRIMARY KEY  (`pImage_id`),
  KEY `project_id` (`project_id`),
  KEY `pImage_name` (`pImage_name`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;

[php]

<?php require_once ('mysql_connect.php'); $data = mysql_query("SELECT * FROM project_details, project_image WHERE project_details.project_id = project_image.project_id LIMIT $from, $max_results") or die ('Cannot select database'); Print ""; while($info = mysql_fetch_array( $data )) { Print ""; // Print out the contents of the entry print ""; } Print "
Project Name: ".$info['project_name'] . ", "; print " ".$info['street'] .", "; print " ".$info['CityOrTown'] .", "; print "".$info['country'] .".
"; print " Project Type: ".$info['projectType'] ."
"; print " Client: ".$info['client'] ."
"; print " Main Contractor: ".$info['mContractor'] ."
"; print " Structural Engineer: ".$info['structEng'] ."
"; print " Value: &pound".$info['value'] ."M
"; print " Project Description: ".$info['description'] ."
"; print "
"; //print .info['pImage'] . /* this is where I am stuck! I want to display an image which is stored on the project_image table where the project_details.project_id = project_image.project_id. Does anyone know how this can be done? */ "
"; ?>

[/php]

Admin Edit: Added PHP and CODE tags for readability. Please see http://phphelp.com/guidelines.php for posting guidelines.


#2

You appear to already have the data from the select query that you have done… You just need to echo it out with the appropriate html tags (i.e. <img src=… ) using the array variable of $info[‘image_name’]


#3

I still don’t seem to get the syntax, I know that if I write print $info[image_name] I get the name of the image that I want to see, but I can’t figure out how I work into the syntax. :cry:

Help!


#4

[php]
print ‘’;
[/php]


#5

Hi peg110

What can I say?

Thank you so much for taking the time to help. :D

Thanks again.

John