Page 1 of 1

display table column names in edit query

Posted: Tue Feb 01, 2005 9:22 am
by reiqwan
Hi all;

I am trying to find a solution to the following problem:

I have a page which creates a table with columns depending on the checkboxes you select. I have managed to construct that fine, but my client wants to be able to allow visitors to go to a page to edit this info. This is not the problem bcos all I did was dropped the old table and created a new table, but now he wants the visitor to be able to see what selections they previously made, my problem is that I'm not too sure how this would be done easily.

The way I propesed to do it was by creating a new relational table and adding info to all the fields that would have their table selected, but the problem is that there's about 50 options and this table would be ridiculously big.

Is there any other way I could possibly keep a record of all the columns selected; I guess another way would be to pass it through the URl querystring but isnt there a 256 character limit on that string and I guess that's also a bit ridiculous.

If you need more of an explanation or to see some of the code I'll be more than willing to explain.

Thanks for any help.

Posted: Tue Feb 01, 2005 9:32 am
by feyd
the url limit is about 2048 to 4096 characters I believe.. but instead of displaying an insanely long url, maybe a unique id, that relates to a table of previous selected columns. You could store the columns' (numeric) offset instead of the name. This would then only require you to fetch the table's structure (at most) when displaying those selections.

Sounds good

Posted: Tue Feb 01, 2005 11:50 am
by reiqwan
Thats a good idea I'll try it out.

Array variable creation

Posted: Tue Feb 01, 2005 1:29 pm
by reiqwan
Hi all;

I've managed a way to start using your suggestion
You could store the columns' (numeric) offset instead of the name. This would then only require you to fetch the table's structure (at most) when displaying those selections.
but at the moment I'm a bit stuck with allowing the array to put all the fields into a variable I can echo it just fine using the following method:

Code: Select all

mysql_select_db($database_RespondNow, $RespondNow);
$dbfields = mysql_list_fields($database_RespondNow, $table, $RespondNow);
	
	$dbfield_num = mysql_num_fields($dbfields);

for($y=0; $y < $dbfield_num; $y++) &#123;
      $field_name = mysql_field_name($dbfields, $y);
     
      echo("<strong>$field_name</strong><br>");
    &#125;
But when I try and put it into an array I just get the last field, I know I'm doing something wrong but just cant figure it out yet.

This is the method I'm trying:

Code: Select all

mysql_select_db($database_RespondNow, $RespondNow);
$dbfields = mysql_list_fields($database_RespondNow, $table, $RespondNow);
	
	$dbfield_num = mysql_num_fields($dbfields);

for($y=0; $y < $dbfield_num; $y++) &#123;
      $field_name = mysql_field_name($dbfields, $y);
     
      $test = ("$field_name");
    &#125;

echo $test;
But like I said I just get the last field displayed.

Any help would be appreciated.

Thanks

Posted: Tue Feb 01, 2005 5:53 pm
by feyd
if you echo'd $test on each iteration through the for loop, you'd see all the names.

Posted: Tue Feb 01, 2005 6:15 pm
by JAM
Regarding request (URI) limit.
Just felt that I should mention the below, as some might want to have it in mind, for any reasons and for good or bad.
http://apache.active-venture.com/mod/core6.htm wrote:LimitRequestLine directive
Syntax: LimitRequestLine bytes
Default: LimitRequestLine 8190
Context: server config
Status: core
Compatibility: LimitRequestLine is only available in Apache 1.3.2 and later.

This directive sets the number of bytes from 0 to the value of the compile-time constant DEFAULT_LIMIT_REQUEST_LINE (8190 as distributed) that will be allowed on the HTTP request-line.

The LimitRequestLine directive allows the server administrator to reduce the limit on the allowed size of a client's HTTP request-line below the normal input buffer size compiled with the server. Since the request-line consists of the HTTP method, URI, and protocol version, the LimitRequestLine directive places a restriction on the length of a request-URI allowed for a request on the server. A server needs this value to be large enough to hold any of its resource names, including any information that might be passed in the query part of a GET request.

This directive gives the server administrator greater control over abnormal client request behavior, which may be useful for avoiding some forms of denial-of-service attacks.

For example:

LimitRequestLine 16380

Under normal conditions, the value should not be changed from the default.
There are also other ways of sending extended info in the URI, with using serialize(), base64_encode() and/or similiar functions.
</end_sidenote>

thanks

Posted: Wed Feb 02, 2005 2:38 am
by reiqwan
this is what i did and works all good now thanks for the help.

Code: Select all

$selected = '';

for($y=0; $y < $dbfield_num; $y++) &#123;
      $field_name = mysql_field_name($dbfields, $y);
     
      $selected .= ("$field_name ");
	 // echo $test;
	 //  $test .= $test;
    &#125;

	//echo $test;
?>