Current location: Hot Scripts Forums » Programming Languages » PHP » Help on dynamic php please


Help on dynamic php please

Reply
  #1 (permalink)  
Old 03-15-09, 02:52 PM
frobak frobak is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Help on dynamic php please

Hi

I am displaying dynamically the rows from a databse table, and inside this i want to display a php variable, which is a download count, the code:

<?php echo $dl_count; ?>

but when the html table is dynamically displayed, it isnt reading it as php and isnt doing anything with it.

ive tried this withough the php tags also which doesnt work.

Is it possible to have this small php script within dynamically produced html?

the code for producing the html is below:
PHP Code:

                <?php

                
include("includes/db_connect.inc.php");

                
$query="SELECT * FROM pbzarchive ORDER BY date_added";
                
$result=mysql_query($query);

                
$num=mysql_numrows($result);

                
mysql_close();

                
$i=0;
                while (
$i $num) {

                
$mix_title mysql_result($result,$i,'mix_title');
                
$djname mysql_result($result,$i,"djname");
                
$mix_length mysql_result($result,$i,"mix_length");
                
$mix_size mysql_result($result,$i,"mix_size");
                
$filename mysql_result($result,$i,"filename");
                
$dl_count mysql_result($result,$i,"dl_count");

                echo 
"<div class='mix'>
                        <table id='mix'>
                        <th colspan='2'>
$mix_title
                        </th>
                        <tr>
                            <td id='mix'>DJ's : 
                            </td>
                            <td id='mix'>
$djname
                            </td>
                        </tr>
                        <tr>
                            <td id='mix'>Mix length : 
                            </td>
                            <td id='mix'>
$mix_length
                            </td>
                        </tr>
                        <tr>
                            <td id='mix'>Mix size : 
                            </td>
                            <td id='mix'>
$mix_size
                            </td>
                        </tr>
                        <tr>
                            <td id='mix'><A href='../downloads/
$filename.php' onClick='popup = window.open('downloads/$filename.php', 'PopupPage', 'height=135,width=265,scrollbars=no,resizable=no'); return false' target='_blank'>Download</a><?php echo $dl_count; ?>
                            
                            </td>
                            <td id='mix'>
                            </td>
                        </tr>
                    </table>
                </div>"
;
                
$i++;
                }
                
?>
</div>

any help would be much appreciated as its driving me a little crazy.

thanks

alan

Last edited by frobak; 03-15-09 at 02:58 PM.
Reply With Quote
  #2 (permalink)  
Old 03-15-09, 03:09 PM
dgreenhouse's Avatar
dgreenhouse dgreenhouse is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: San Francisco
Posts: 457
Thanks: 0
Thanked 3 Times in 3 Posts
You're already echoing $dl_count inside of a php command,
so you don't need to (nor will it work), enclose $dl_count in "<?php ?>"again.
Reply With Quote
  #3 (permalink)  
Old 03-15-09, 03:15 PM
frobak frobak is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
but when i do that, it displays nothing actually in the html page, but if i view source it has the full php code eching the variable that i want it to, inside the php tags??

PHP Code:

<?php echo dl_count_show?>

but it isnt treating it as php?

Last edited by frobak; 03-15-09 at 03:17 PM.
Reply With Quote
  #4 (permalink)  
Old 03-15-09, 03:18 PM
dgreenhouse's Avatar
dgreenhouse dgreenhouse is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: San Francisco
Posts: 457
Thanks: 0
Thanked 3 Times in 3 Posts
I thought the variable was: dl_count not dl_count_show...
Reply With Quote
  #5 (permalink)  
Old 03-15-09, 03:19 PM
dgreenhouse's Avatar
dgreenhouse dgreenhouse is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: San Francisco
Posts: 457
Thanks: 0
Thanked 3 Times in 3 Posts
Anyway, if something is in the variable after querying the database, it should display.

If you're not getting output, and you know there's something in there, you're obviously
doing something else wrong along the way.
Reply With Quote
  #6 (permalink)  
Old 03-15-09, 03:20 PM
frobak frobak is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
yes the variable is dl_count, and the value of that variable is dl_count_show, which is correct, but its blank on the actual screen, and as above, if i view source it has the php tags displayed?
Reply With Quote
  #7 (permalink)  
Old 03-15-09, 03:22 PM
frobak frobak is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
i want the variable to display another variable, that will be populated by an sql query also run on this page
Reply With Quote
  #8 (permalink)  
Old 03-15-09, 03:34 PM
frobak frobak is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
I managed to get it to print the value of variable dl_count, and the value is $dl_count_show, but i want $dl_count_show to display the count of an sql query that has been run and is sat in the variable.

but when it is diplayed dynamically it is not reading it as php, but as just normal text?

Last edited by frobak; 03-15-09 at 03:37 PM.
Reply With Quote
  #9 (permalink)  
Old 03-15-09, 07:24 PM
dgreenhouse's Avatar
dgreenhouse dgreenhouse is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: San Francisco
Posts: 457
Thanks: 0
Thanked 3 Times in 3 Posts
I do not understand what you mean by: "not reading it as php".

Do you mean it's not an integer?
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
[SOLVED] it works on localhost but not on hosting account? myslowquietlife PHP 42 12-19-08 09:31 AM
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 10:17 AM
Creating dynamic movieclips using data from PHP ste Flash & ActionScript 1 04-11-07 09:49 PM
dynamic php page. tehnoobe PHP 4 04-02-04 11:49 AM


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