![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Feb 2005
Posts: 74
Rep Power: 4
![]() |
Would this work?
Just curious if this should work.
$mshirt = "select item_image from store_items where item_title = mshirt"; $display_table .= " <td><a href=\"mshirt.php\"><img src=\"$mshirt\" /></a></td> Just a piece of the code, but I think you get the idea. item_image is a path to where the pics are stored.
__________________
Lorem ipsum dolor sit amet... |
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
no it would not work it would just put the string in there.
|
|
|
|
|
|
#3 |
|
Programmer
Join Date: Feb 2005
Posts: 74
Rep Power: 4
![]() |
so how would get the path to the file to work in the img tag?
__________________
Lorem ipsum dolor sit amet... |
|
|
|
|
|
#4 | |
|
Programming Guru
![]() ![]() |
Quote:
if $item_image held the path you could do it. this is how i would write it. Note: This is code for a postgresql db, but you are probally using mysql. [PHP] //connect to the db $pgConnection = pg_connect("dbname=users user=me password=foobar"); $sql = "select item_image from store_items where item_title = mshirt"; //then with your connection to the db, execute the query above: $res = pg_query($pgConnection, $sql); //now check to see if the query returned anything. if (pg_num_rows($res) <> 0) { //now we can loop and creat output table. for ($x=0; $x<pg_num_rows($res); $x++) { $data = pg_fetch_object($res, $x); $display_table .= " <td><a href=\"mshirt.php\"><img src=\"" . $data->item_image . "\" /></a></td>"; } } else { //error message: ?> <center> <b>There are no shirt images.</b> </center> <?PHP } [/PHP] anyways, if you are using mysql, you'll have to do a little research on what functions you'd need to use.
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! Last edited by Pizentios; May 9th, 2005 at 11:39 AM. |
|
|
|
|
|
|
#5 |
|
Programming Guru
![]() |
yes but he isnt using sql at the time Piz, so it would just print the string into where he had the thingy there :p.
there was no sql mentioned thank you ![]() http://www.berto.org/test123.php [php] <?php $mshirt = "select item_image from store_items where item_title = mshirt"; $display_table .= "<td><a href=\"mshirt.php\"><img src=\"" . $mshirt . " /></a></td>"; echo $display_table; ?> [/php] edited the code slightly. Last edited by Berto; May 10th, 2005 at 3:25 AM. |
|
|
|
|
|
#6 |
|
Programming Guru
![]() |
You probably want something along the lines of this. Assuming that what you're trying to do is a basic MySQL query, and yes Berto no SQL was mentioned but since he said "item_image is a path to where the pics are stored" and that sure looks like SQL to me i can only assume.
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("database name");
$mshirt = mysql_query("select item_image from store_items where item_title= mshirt");
while($row = mysql_fetch_array($mshirt))
echo "<td><a href=\"mshirt.php\"><img src=\"{$row["mshirt"]}\"/></a></td>";i
mysql_close();
?>
__________________
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|