DIGIT-ARC read-only archive · snapshot: July 23, 2026

help in php and mysql

4 posts · originally from https://geek.digit.in/community/threads/help-in-php-and-mysql.90097/

Sridhar_Rao
Sridhar_Rao Original post #1
Jun 9, 2008 at 7:21 PM
Dear friends,
I have a unique problem as I am new to mysql and php. don't ask me why I want it that way, but that is my requirement. Please look at the image which will give you clear picture. Anyone with skill in mysql and php is requested to help me in achieving this. Please bear in mind that number of fields is 49, which cannot be changed or split.*www.microrao.com/temp/table.gif
P
Jun 18, 2008 at 5:49 PM
If your problem is writing long code with same kind of variable name, you can use $$variable facility in PHP.

or you can do it in a loop using mysql_fetch_fields() function to get all fields dynamically


*dev.mysql.com/doc/refman/5.0/en/mysql-fetch-fields.html
If it is not your problem, please tell me where you stuck actually? Where should I help?
Sridhar_Rao
Jun 26, 2008 at 11:35 PM
Never mind Pknissar, I figured it out myself.
I was using crude ways to get it done and was hoping someone would point me a simple way of doing it. My first script in achieving this ran over 100 hundred lines, now I reduced it to 15 lines.
victor_rambo
Jun 27, 2008 at 12:14 AM
For 1st problem, it can be achieved in a single SQL query:
[CODE
$sql="UPDATE table_name SET product=test1*test2*test3*test4*......*test49 WHERE id='$id'";

//You may use a loop to create the test1*test2*test3*... part of the SQL
[/CODE]


For the 2nd question, gues you will have to do it manually by fetching values and deriving from them.