Sunday, April 27, 2008

MySQL/PHP Retrieving image paths from database and insert into News Release text (1 reply)

Help! I am not a programmer. I am looking for a php script to insert the following image paths from a MySQL database and their associated html "alt" and captions and insert them in their referenced comment line <!---img_2---> in the news release text when the page is displayed. The news release may have 0-3 images on a page, but staggered left, right, left.

Question: Do I reference a variable in the MySQL database field "release_text" or do I use the comment line <!---img_1---> ? What is the best way to handle this without causing too much overload on the page to display.

MySQL Fields:
img_1: /news_events/news_releases/images/bottleneck.jpg
img1_caption: Mathematics have yielded tremendous advances and powerful new technologies.
img_2: /news_events/news_releases/images/diagram.jpg
img2_caption: Dictyostelium was chosen by the scientists because it's the simplest organism in which to study the complex phenomena they hope to investigate.
img_3: /news_events/news_releases/images/floats.jpg
img3_caption: Dictyostelium has a solitary lifestyle in which each individual cell is on its own.
release_text: (to follow)
Physicists and biologists at the University of California, San Diego have been awarded $3-million from the National Science Foundation to collaborate in characterizing, in an integrated way, the development of the Dictyostelium discoideum, an organism popularly known as a slime mold.<br/>
<br/>
The five-year award, which includes researchers at Cornell University, was one of 16 research grants announced this month by the NSF to foster a better scientific understanding of the interrelationships that arise when living things at all levels-from molecular structures to genes to ecosystems-interact with their environment.<br/><br/>
<!---img_1--->
"Past investments in molecular biology, remote sensing, information science, and mathematics have yielded tremendous advances and powerful new technologies and tools that now make biocomplexity research possible," said Rita Colwell, director of NSF.<br/>
<br/>
In the biocomplexity award to UCSD, physicists, biologists and computational scientists from the two universities will attempt to connect the underlying genetic information about Dictyostelium to its morphology and multicellular organization. <br/>
<br/>
"Dictyostelium provides the simplest example of cellular biology mechanisms that go on everywhere," said Herbert Levine who heads the research collaboration. "In our investigations of the organism, we will try to bring a level of precision that will enable us to bridge the gap between genomics and multicellular organization."<br/>
<br/>
<!---img_2--->
Other UCSD researchers involved in the project include Jose N. Onuchic, professor of physics, which will receive approximately $700,000 of the $3-million award over the next five years. <br/>
<br/>
Levine said Dictyostelium was chosen by the scientists because it's the simplest organism in which to study the complex phenomena they hope to investigate, such as the cell's response to external signals that coordinate multicellular development.<br/>
<br/>
<!---img_3--->
"Dictyostelium has a solitary lifestyle in which each individual cell is on its own," he added. "But the organisms also go through a developmental cycle in which they cooperate when food becomes scarce-sending each other signals, aggregating together and forming rudimentary multicellular organisms, one of which is a slug that can crawl around looking for a better environment."<br/>
<br/>

Script which displays news release text.

<?php echo $row_news_release['release_text']; ?><br>
<br>

This is the sample div and html format which should be output for all images

<!-- inserted img_1--><br />
<div class="floatleft" style="width: 288px;">
<img src="/news_events/news_releases/images/bottleneck.jpg"

alt="Mathematics have yielded tremendous advances and powerful new technologies."

border="0" hspace="0" vspace="0" />
<p> Mathematics have yielded tremendous advances and powerful new technologies..
</p>
</div>
text
<!-- inserted img_2--><br />
<div class="floatright" style="width: 288px;">
<img src="/news_events/news_releases/images/diagram.jpg"

alt="Dictyostelium was chosen by the scientists because it's the simplest organism in which to study the complex phenomena they hope to investigate."

border="0" hspace="0" vspace="0" />
<p> Dictyostelium was chosen by the scientists because it's the simplest organism in which to study the complex phenomena they hope to investigate.
</p>
</div>
<!-- inserted img_3--><br />
<div class="floatright" style="width: 288px;">
<img src="/news_events/news_releases/images/floats.jpg"

alt=" Dictyostelium has a solitary lifestyle in which each individual cell is on its own."

border="0" hspace="0" vspace="0" />
<p> Dictyostelium has a solitary lifestyle in which each individual cell is on its. own.
</p>
</div>

I have looked all over for a solution or snippet of code which could handle this. Any help you can provide, I would most appreciate. Many thanks.