post array of selected array element

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
kliz
New php-forum User
New php-forum User
Posts: 1
Joined: Tue Mar 07, 2017 6:30 pm

Tue Mar 07, 2017 6:46 pm

guys i have a problem from week and a half i use an array to display pictures gallery i want to click in a button to ask for the new picture to upload... but i need to post the index elelemt of the array... how can i post the info of THE CLICKED ELEMENT?? tnx in advance
if(isset($_POST['idx'])){
$id=$_POST['idx'];
echo $id;
}
//echo $id;
}

<?php
$colum=0;
$idx=0;
while($rows=mysql_fetch_array($result)){
?>
<p><?php echo $colum; ?></p>
<p><?php echo $indx; ?></p>
<p><?php echo $rows['category']; ?></p>
<p><img src="folder/<?php echo $rows['image']; ?>" width="180" height="80"></p>
<p>Código<input name="codenumber[]" type="text" value="<?php echo $rows['codenumber']; ?>"></p>
<p>Precio<input name="price[]" type="text" value="<?php echo $rows['price1']; ?>"></p>
<p><input name="idx[]" type="hidden" id="idx" value="<?php print $idx; ?>"></p>
<p><input type="submit" name="chngpic" id="chngpic" value="CHange Picture" />
<input type="submit" name="delete_p" id="delete_p" value="Delete Picture" />
</p>
</td>
<?php
$colum ++;
$idx++;
if ($colum == 4) {
$colum=0;
?>
</td><tr><td>
<?php
} else{
?>
<td>
<?php
}
?>

<?php
}
?>
</form>
</table>

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 742
Joined: Mon Feb 22, 2016 5:52 pm

Thu Mar 09, 2017 2:02 pm

Your page is not set up correctly.

First you need to see if the form has been submitted or if this the the first time it has been displayed to the user, then process accordingly.

Unless there is a lot more code, then I suspect you are getting lots of errors.

You are also making life difficult for yourself by mixing <p> tags and <table> tags

Post Reply