Jump to content

Is there a way.


Demonic

Recommended Posts

Alright I've gotten multiple form names with the same name but i don't know how to give the select a special ID so I can update the current ID for each row

 

<form method="post" action="index.php">

<select name="cat[]">

<option value="1" selected="selected">1</option>

<option value="2">2</option>

</select>

 

<select name="cat[]">

<option value="1">1</option>

<option value="2" selected="selected">2</option>

</select>

</form>

 

well when i do a check it selects current order for each row but tthe form doesn't have an unique id for each selection box.

 

Can i do:

 

<form method="post" action="index.php">

<select name="cat[1]">

<option value="1" selected="selected">1</option>

<option value="2">2</option>

</select>

 

<select name="cat[2]">

<option value="1">1</option>

<option value="2" selected="selected">2</option>

</select>

</form>

 

cat[x] x  being the row #

If so how can I update that so it updates each row.

 

I was thinking

 

$num = mysql_total_rows($tablename);

 

for($i=0;$i <= $num;$i++){

$catid = $_POST['cat[$i]'];

foreach($_POST['cat'] as $catord){

mysql_query("UPDATE `order` SET order id='$catord' WHERE id='$catid' ");

}}

 

But i doubt that would even work.

 

Any suggestions on how to do this differently or how I can actually make this work?

 

Link to comment
https://forums.phpfreaks.com/topic/40047-is-there-a-way/
Share on other sites

I might have to just do a for statement.

 

$total = mysql_num_rows($sqlquery);

 

 

for($i=1;$i <=$total;$i++){

 

$id = explode("cat",$_POST[cat$i]);

 

mysql_query("UPDATE order SET order='$_POST[cat$i]' WHERE id='$id' ") or die(mysql_error());

 

}

 

You think that will work?

 

wait I don't need $id part since it wont work i would just need $i wouldn't I?  humm. I'm going to try it.

Link to comment
https://forums.phpfreaks.com/topic/40047-is-there-a-way/#findComment-193782
Share on other sites

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.