Jump to content

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


johnrlhunter

Recommended Posts

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

 

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 "<table width=830 border=0 cellpadding=5 align=center>";

 

while($info = mysql_fetch_array( $data ))

{

Print "<tr>";

// Print out the contents of the entry

print "<td><b>Project Name:</b>  ".$info['project_name'] . ", ";

print " ".$info['street'] .", ";

print " ".$info['CityOrTown'] .", ";

print "".$info['country'] .".<br>";

print "<b>  Project Type:</b> ".$info['projectType'] ."<br>";

print "<b>  Client:</b> ".$info['client'] ."<br>";

print "<b>  Main Contractor:</b> ".$info['mContractor'] ."<br>";

print "<b>  Structural Engineer:</b> ".$info['structEng'] ."<br>";

print "<b>  Value: </b> &pound".$info['value'] ."M<br>";

print "<b>  Project Description:</b> ".$info['description'] ."<br>";

print "</td><td>";

 

//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?

*/

"<br></td></tr>";

 

}

Print "</table>";

 

?>

 

 

Archived

This topic is now archived and is closed to further replies.

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