Jump to content

want to display images dependant on number in MYSQL field


nade93

Recommended Posts

Sorry, I meant str_repeat. My mistake, here is an example of it's usage:

 

$result = mysql_query("SELECT field FROM table WHERE condition = x") or trigger_error("Query Failed: " . mysql_error());

$output = "";
while ($row = mysql_fetch_assoc($result)) {
    $output .= str_repeat('<img src="star.gif" />', $row['field']);
}

echo $output;

I have no clue why it is not displaying. First up, you have to have "star.gif" image on your server. Second, you have to re-do that query to match your database. I do not know what you store in "field" if it is a number, then the code I provided should work.

 

If the only problem is the image is not displaying that is because you have to modify that to be where you have the actual image. If you would like us to help you more, please provide some code so we can see what you are doing. Without it we are left to our psychic abilities (which mind you are not very good).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.