|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
using MySQL field variable as text box names in HTML forms
I have some php in the middle of HTML that looks like this in order to build a table in the web page from the contents of a MySQL table. A field in the MySQL table is the name of the text box in the HTML page. I know, sounds strange...
<?php // products will be created in HTML table here from DB table $orderByCol = "partNumber"; $sqlCommand = "SELECT * FROM $productsTable WHERE activeProduct='1' ORDER BY $orderByCol"; $qryOK = mysql_query($sqlCommand); // php supplied function $numRecords = mysql_num_rows($qryOK); // # of records found. if($numRecords) { while($record = mysql_fetch_object($qryOK)) { // php supplied function $partNumber = $record->partNumber; $description = $record->description; $price = $record->price; $checkBoxName = $record->checkBoxName; $qtyFieldName = $record->qtyFieldName;// $tableRow = "<tr>"; $tableRow .= "<td colspan="2"> </td>"; $tableRow .= "<td width="26">"; $tableRow .= "<div align="center">"; $tableRow .= "<input type="checkbox" name="".$checkBoxName."" value="1">"; $tableRow .= "</div>"; $tableRow .= "</td>"; $tableRow .= "<td width="262">".$description."</td>"; $tableRow .= "<td width="99">".$price." USD</td>"; $tableRow .= "<td width="72">qty"; $tableRow .= "<input type="text" name="".$qtyFieldName."" size="5">"; // value="0" (at end) $tableRow .= "</td>"; $tableRow .= "</tr>"; print $tableRow; } } The MySQL table has fields like these (that are releative to my question: qtyFieldName -- the name of the text box where the user will enter a quantity checkBoxName -- the name of the check box on the HTML page I then want to use all the specific 'qtyFieldName' actual qty's The next page has this in it to get the selections: $orderByCol = "partNumber"; $sqlCommand = "SELECT * FROM $productsTable WHERE activeProduct='1' ORDER BY $orderByCol"; // $qryOK = mysql_db_query ($mysqlDB, $sqlCommand); // php supplied function (depricated) $qryOK = mysql_query($sqlCommand); // php supplied function $numRecords = mysql_num_rows($qryOK); // # of records found. if($numRecords) { while($record = mysql_fetch_object($qryOK)) { // php supplied function $partNumber = $record->partNumber; $description = $record->description; $price = $record->price; $checkBoxName = $record->checkBoxName; $qtyFieldName = $record->qtyFieldName; print $qtyFieldName; // obviously just gives the field name what I really want here is the value of this variable fromthe previous page I have also tried: eval ("$qty = "$qtyFieldName";"); echo $qty; but it just gives the field name also Any ideas??? |
|
#2
|
|||
|
|||
|
RE: using MySQL field variable as text box names in HTML forms
Would there be a better way to do this and just scrap this idea???
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > using MySQL field variable as text box names in HTML forms |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|