Reputation: 119
I am a php programmer .I am uploading images in both the Localserver as well as the the database table (in case of table its the image location that is being stored in the table, field.
execution:When I click on a button the retrieve, the images are properly displayed in the browser properly.Its in the row wise gallary format(used css).Everything is fine till now.But the problem starts if I try to display four radio buttons for each photo(just below each photo along with their labels. I need to mention here that I have stored the names of four values of four buttons in an array.
below is the code snippet:
<?php
while($resultrow=mysql_fetch_array($query)){
?>
<div class="img">
<img src="<?php echo "$resultrow[1]"; ?>" height="100" width="120"/>
</div>
<?php
}
while($resultrow=mysql_fetch_array($query)){
for($i=0;$i<=3;$i++){
?>
<div class="rateselection">
<input type="radio" name="select" value="<?php echo "$imagearray[i]";?>"/>
</div>
<?php
}//for ends
}//while ends
?>
coming out of php and going again into it is for convenience,I hope you understand.Just tell me where I went wrong .PLEASE NOTE that the first "while" is executing properly ,but the 2nd while is not....Please suggest a solution
Upvotes: 0
Views: 1065
Reputation: 11
You should use an array for posting what you get from radio buttons.
For example you can write in the input element type='radio' name='array[]'
In your PHP code, when you access $_POST['array']
, you will have access to every value of the selected radio buttons with the same name.
Upvotes: 1
Reputation: 660
it will not run because you already iterated thorugh the result array, you either need to rewind it or save it while looping through it first... etc..
Upvotes: 0
Reputation: 4478
You probably need to reset the query cursor, or just re-execute the query. Here's how to reset the cursor:
https://www.php.net/manual/en/function.mysql-data-seek.php
Upvotes: 0
Reputation: 86336
should be $i
not i
<input type="radio" name="select" value="<?php echo "$imagearray[$i]";?>"/>
Upvotes: 0