Passing Multiple values

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!

Moderator: General Moderators

Post Reply
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Passing Multiple values

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Passing Multiple values

Post 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 ...
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post 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.
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Post 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
Post Reply