help in php and mysql

Status
Not open for further replies.

Sridhar_Rao

In the zone
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
 

pknissar

Right off the assembly line
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?
 
OP
Sridhar_Rao

Sridhar_Rao

In the zone
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

हॉर्न ओके प्लीज़
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.
 
Status
Not open for further replies.
Top Bottom