Jump to content

For loop giving to much out put


mdmartiny

Recommended Posts

Hello Everyone,

 

I am working on a project where I have to go in and grab the names of the fields in a table. I got it to work and for it to show me the field names but it also displays a lot more than what I would like for it to do.

 

I keep getting the following error. It is repeated over my screen like 15 times.

 

Warning: mysql_field_name() [function.mysql-field-name]: Field 5 is invalid for MySQL result index 7 in C:\xampp\htdocs\CMS\admin\includes\get_table.php on line 44

 

This is the section of code that it is referring to. Line 44 is

 

$tablecolumn .= "<p>" . mysql_field_name($fieldnamesquery_result, $table_field) . "<input type='text' name='" . mysql_field_name($fieldnamesquery_result, $table_field) . "' id='" . mysql_field_name($fieldnamesquery_result, $table_field) . "'/>";

 

$tablecolumn = "<form name='insert_table' id='insert_table' action='get_database.php' method='post' >
<fieldset>
<legend>table information</legend>";
    for ($table_field = 2; $table_field < $fieldnamesquery_result; $table_field++) {
        $tablecolumn .= "<p>" . mysql_field_name($fieldnamesquery_result, $table_field) . "<input type='text' name='" . mysql_field_name($fieldnamesquery_result, $table_field) . "' id='" . mysql_field_name($fieldnamesquery_result, $table_field) . "'/>"; <-----This is line 44
    }
    $tablecolumn .= "
<p>
<input type='submit' name='submit_info' id='submit_info' />
</p>
</fieldset>
</form>
";

    echo $tablecolumn;

Link to comment
https://forums.phpfreaks.com/topic/259672-for-loop-giving-to-much-out-put/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.