Strydaris Posted April 19, 2007 Share Posted April 19, 2007 Ok hopefully someone can help me out with this. I am really new at writing PHP code and have done alot of searching around on this but cant seem to find anything about it. Most of this code is actually working just fine its jsut the images I cant get working. Take a look then I will expalin what I am trying to do. <?php defined( '_VALID_MOS' ) or die( 'Restricted access' ); global $mosConfig_live_site; $query = "SELECT cb_class, COUNT(user_id) FROM jos_comprofiler GROUP BY cb_class"; $result = mysql_query($query) or die(mysql_error()); echo "<table border='1' bgcolor='blue'>"; echo "<tr> <th colspan='2'>Class</th> <th>Amount</th> </tr>"; // setting the images and their path $urlImgPath = $mosConfig_live_site."/modules/mod_recruitment/"; $imgname = "_small.gif"; $testing = $row['cb_class']; $fullimgname = $urlImgPath .$testing .$imgname; while($row = mysql_fetch_array($result)){ // Print out the contents of each row into a table echo "<tr><td>"; echo '<img border="0" src="'.$fullimgname.' ">'; echo "</td><td>"; echo $row['cb_class']; echo "</td><td>"; echo $row['COUNT(user_id)']; echo "</td></tr>"; } echo "</table>"; ?> Basically what I am trying to do is make a list of people that have registered on my website in a nice neat table for everyone to see. In this table I want it laid out with. Class image(an image file) | Class name | Class count(in numbers) I have the last 2 parts are working as intended. What I am trying to do is use the Class name defined by $row['cb_class']; to create a string that includes the image file directory as well as the first part of the image name. If I replace $testing = $row['cb_class']; with something like $testing = "IMAGE NAME"; it works fine. Can someone please point me in the right direction on what I can do here? Link to comment https://forums.phpfreaks.com/topic/47758-how-do-i-use-a-table-from-my-database-to-define-images/ Share on other sites More sharing options...
Strydaris Posted April 19, 2007 Author Share Posted April 19, 2007 nevermind I solved it Had to move $testing = $row['cb_class']; $fullimgname = $urlImgPath .$testing .$imgname; into the while statement!! lol Link to comment https://forums.phpfreaks.com/topic/47758-how-do-i-use-a-table-from-my-database-to-define-images/#findComment-233284 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.