Page 1 of 1

Passing Multiple values

Posted: Fri Oct 19, 2007 1:17 pm
by Addos
Hi,
I’m looking for some pointers with the following PHP that has me stuck. Basically I want to pass the values of an array from my form to my database so that I can update a ‘sort’ column in a specific numeric order.

If I run this

Code: Select all

<?php do { ?>
<?php echo $row_GetSolo_Inst['Solo_Title']; ?>
<? $sorte = array($row_GetSolo_Inst['sort']); ?>
<input type="text" name="<?php  $sorte[0]; ?>" value="<?php echo $sorte[0]; ?>" size="5">
<? $soloID = array($row_GetSolo_Inst['solo_ID']); ?>   
<input type="hidden" name="<?php echo $soloID[0]; ?>" value="<?php echo $soloID[0]; ?>">
<?php } while ($row_GetSolo_Inst = mysql_fetch_assoc($GetSolo_Inst)); ?>
<input type="submit" value="Update record">
I get exactly what I need in the browser window but my problem is that I want to then pass this to the following so that I can update all the detail from the form above in one go.

Code: Select all

$updateSQL = sprintf("UPDATE compositions_solo SET sort=%s WHERE solo_ID=%s",
                       GetSQLValueString("$sorte[0]", "int"),
                       GetSQLValueString("$soloID[0]", "int"));
I can see that when I run this I get
UPDATE compositions_solo SET sort=NULL WHERE solo_ID=NULL and my limited PHP knowledge is challenged now as I can’t see how to pass more than one value to the database using the above.

Can anyone give me a few pointes as to how I can pass the values of my array to the respective columns in the database?

Thanks for any help
B

Re: Passing Multiple values

Posted: Fri Oct 19, 2007 2:03 pm
by VladSun
Addos wrote:

Code: Select all

<input type="text" name="<?php  $sorte[0]; ?>" value="<?php echo $sorte[0]; ?>" size="5">
the PHP block for your name value, doesn't output anything ...

EDIT: On second thought, I can't say I understand what you want to do ...

Posted: Fri Oct 19, 2007 2:43 pm
by califdon
I also don't understand what you are trying to do. It might be better if you told us what you are trying to accomplish so we might be able to suggest ways of doing it.

Posted: Fri Oct 19, 2007 3:00 pm
by Addos
Ok really sorry for not being clear enough.

Basically I have a form and when it’s populated from the database there are a few fields. See example http://www.ahamay.com/sort.htm One of these fields has a ‘sort’ column so that I can change the order of the details that are retrieved and displayed in the browser. I can’t figure out how to update the sort fields in the database all at once. When I run the above script I get the sample in the link above ok but when I hit Update Record then I can see that there are null values passing to the Select Query so it’s at this point I’m stuck and can’t figure out what to write to pass these values to the database.

Hope this makes sense.
B