Current location: Hot Scripts Forums » Programming Languages » PHP » dynamic html table


dynamic html table

Reply
  #1 (permalink)  
Old 04-22-11, 08:25 PM
williamh26 williamh26 is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 132
Thanks: 2
Thanked 0 Times in 0 Posts
dynamic html table

I have this code that populates a dynamic table data
PHP Code:

mysql_connect("localhost""taverna""taverna") or die(mysql_error());
mysql_select_db("taverna") or die(mysql_error());


// SQL query to interact with info from our database
$sql mysql_query("SELECT gal_id, pic_name FROM galeria ORDER BY gal_id DESC LIMIT 100");
$i 0;
// Establish the output variable
$dyn_table '<table border="1" cellpadding="0">';
while(
$row mysql_fetch_array($sql)){

    
$gal_id $row["gal_id"];
    
$pic_name $row["pic_name"];
    
//<img src='fiestaspic/$row[pic_name]'
    
if ($i == 0) { // if $i is divisible by our target number (in this case "3")
        
$dyn_table .= '<tr><td>' .$pic_name.'</td>';
    } else {
        
$dyn_table .= '<td>' $pic_name '</td>';
    }
    
$i++;
}
$dyn_table .= '</tr></table>';
?> 
PHP Code:

<?php echo $dyn_table?>

However i want to populate a image,,, but for some reason onlygive the name of the picture not the image.... can you guys help me please thank you
Reply With Quote
  #2 (permalink)  
Old 04-23-11, 05:49 PM
nafirici nafirici is offline
Newbie Coder
 
Join Date: Mar 2011
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
add the path to the image and put the name in like so:

PHP Code:

$dyn_table .= "<td><img src='path/to/image/" $pic_name "' /></td>"
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Create dynamic rows and columns in html using data from MYSQL table paligron PHP 5 09-17-11 01:47 AM
List of HTML 5 Tags digioz HTML5 11 02-27-11 08:06 AM
Dynamic table rows SUM problem azegurb JavaScript 1 09-22-09 02:48 PM
MYSQL database countll Database 2 06-19-07 04:20 PM
Dynamic Table in DOM (Add/Remove Rows) codexomega JavaScript 0 08-16-05 11:43 AM


All times are GMT -5. The time now is 08:47 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.