PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
function printavataroption ($ammount,$type) {
global $users; // so i can grab avatar info for each user; not used yet
$t = $type; $i = 1; $y = $ammount;
while ($i <= $y){
echo "<option value="$t".$i.".gif">$t".$i.".gif</option>\n";
$i++;
}
}
?>
I have a directory filled with about 250 images. Instead of making an option tag for each image i instead renamed them into 4 catagories and numbered them from 1 to however many there is. The above function I made prints the <option>'s in the <select> in the <form> for me.
And this of course will send the value to the <option> to a database.
Now my question is how can I match the value in the database with one of the <option> tags being displayed so i can add the 'selected' value in the <option> tag?
This is got me playing around with various methods but none of them worked properly.
Did you just read over my shoulder?! I posted the exactly same, so I deleted it. Annoying...
I did it by making the query inside the actual function, outside the while-loop tho. Just because the not yet used global $users could be used to store username or similiar needed for the database transaction.