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;

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.