passing variables in url

K

kysa

Guest
thank you for creating a great database tool

i've not been successful with passing variables into the search form via a url... for instance, i would like to be able to create a url link that, when clicked, shows the results for a search... maybe something like:

http://x.com/dadabik/form.php?do=search&field=variable&field_select_type=like

such capability would be very handy for creating links that, say, can search for entries added to the database within the last 2 weeks (via an entrydate field)

after doing a dadabik search, the url currently just shows 'form.php' in the browser address bar... it would be interesting to be able to see how these variables are being passed into dadabik
 
J

jeff collins

Guest
try this one, this has an image to click, ( you can use a submit button by changing the type to "submit" and erase the source)



<form method="post" action="/your domain/form.php"><input type="image" src="/images/yourbuttonimage.gif"><input type="hidden" name="function" value="search"><input type="hidden" name="sql" value="select * from YOURTABLENAME where YOURFIELDNAME = 'YOURFIELDRESULT' and YOURFIELDNAME = 'YOURFIELDRESULT'></form>

Obviously replace your table name and your field names and results, these need to be exactly as spelled in your databse, case sensitive too.
 
E

Eugenio

Guest
kysa wrote:
>
> thank you for creating a great database tool
>
[......]
> after doing a dadabik search, the url currently just shows
> 'form.php' in the browser address bar... it would be
> interesting to be able to see how these variables are being
> passed into dadabik

In DaDaBIK all the variables are passed via POST.

(Latest version of DaDaBIK when this message was posted: 1.6)
 
R

Rachel

Guest
Hi Kysa,

If you want this to look like a text link and don't mind a little javascript, you can submit the form this way...


<form NAME=WHATEVER method="post" action="/your domain/form.php">
<input type="hidden" name="function" value="search">
<input type="hidden" name="sql" value="select * from YOURTABLENAME where YOURFIELDNAME = 'YOURFIELDRESULT' and YOURFIELDNAME = 'YOURFIELDRESULT'>
<a href=javascript:document.WHATEVER.submit()>
<font size=-1>YOUR TEXT LINK</font></a>
</form>
 
K

kysa

Guest
thanks much rachel & jeff!... very helpful

a tip to consider... if you wish to provide a link/button so that users can view the most recent database entries (and assuming you have an entrydate field), you can insert the following php code into your php document, then call the variable ($oneweek) in the link/button's sql

<?
$oneweek = date ("Y-m-d", mktime (0,0,0,date("m") ,date("d")-7,date("Y")));
?>

if your sql calls "where entrydate > '$oneweek' ", you'll see entries added the past week...
 
T

Tacha

Guest
Being able to do this is very important to what we are setting up and we cannot seem to get this to work. Can anyone help? Here is our code and error message:

CODE:

<form method="post" action="/dadabik/form.php"><input type="submit" value="Active"><input type="hidden" name="function" value="search"><input type="hidden" name="sql" value="select * from projects where Status = 'Active'></form>


ERROR:

Error during query execution.
select * from projectsselect * from projects where Status = \'Active\'> MySQL server said: You have an error in your SQL syntax near '* from projects where Status = \'Active\'> </t' at line 1

OTHER INFO:

We have a drop down box called Status where Active is one of the things you can select. We want it to bring up all project records where Active was selected.

YOURTABLENAME = projects
YOURFIELDNAME = Status
YOURFIELDRESULT = Active

YOURTABLENAME = projects
YOURFIELDNAME = Status
YOURFIELDRESULT = Active


Please help?!
Thank you :)
 
S

Stan

Guest
\t" is a tab character. I see this in the error output. Could be related????

Do you have debug turned on?
 
T

Tacha

Guest
Yes we do have debugging turned on.

The /t seems to be part of a table tag actually because as we try different things we seem to always get part of a table tag at the end of the error message.
 
E

Eugenio

Guest
Tacha wrote:
>
> Being able to do this is very important to what we are
> setting up and we cannot seem to get this to work. Can anyone
> help? Here is our code and error message:
>
> CODE:
>
> <form method="post" action="/dadabik/form.php"><input
> type="submit" value="Active"><input type="hidden"
> name="function" value="search"><input type="hidden"
> name="sql" value="select * from projects where Status =
> 'Active'></form>
>
>
> ERROR:
>
> Error during query execution.
> select * from projectsselect * from projects where Status =
> \'Active\'> MySQL server said: You have an error in your SQL
> syntax near '* from projects where Status = \'Active\'> </t'
> at line 1

Example :

http://www.site.com/form.php?&table_name=albums_tab&function=search&sql=+where+title_album+%3D+%27californication%27&name_mailing=&page=0&order=author_album


with the above url I query the table albums_tab, I want to display the album with title_album='californication', orderd by author album.

(Latest version of DaDaBIK when this message was posted: 2.0 beta)
 
T

Tacha

Guest
Thank you so much, We tried it that way and it worked perfectly!

Thank you!
 
B

bglkk

Guest
Hi:

A year later, but better late...

This URL query works great until I use the navigation tool in the footer. (The navigation tool inserted in the header works fine.)

Navigating in the header, only the page value changes:

http://www.mysite.com/form.php?&table_name=computer&function=search&sql=+where+type_comp+%3D+%27~desktop~%27&name_mailing=&page=0&order=model_comp

http://www.mysite.com/form.php?&table_name=computer&function=search&sql=+where+type_comp+%3D+%27%7Edesktop%7E%27&name_mailing=&page=1&order=model_comp

Navigating in the footer, my query is lost:

http://www.mysite.com/form.php?&table_name=computer&function=search&sql=&name_mailing=&page=0&order=model_comp

What's going on?
 
E

Eugenio

Guest
bglkk wrote:

> Hi:
>
> A year later, but better late...
>
> This URL query works great until I use the navigation tool in
> the footer. (The navigation tool inserted in the header works
> fine.)
>
> Navigating in the header, only the page value changes:
>
>
> http://www.mysite.com/form.php?&table_name=computer&function=search&sql=+where+type_comp+%3D+%27~desktop~%27&name_mailing=&page=0&order=model_comp
>
>
> http://www.mysite.com/form.php?&table_name=computer&function=search&sql=+where+type_comp+%3D+%27%7Edesktop%7E%27&name_mailing=&page=1&order=model_comp
>
> Navigating in the footer, my query is lost:
>
>
> http://www.mysite.com/form.php?&table_name=computer&function=search&sql=&name_mailing=&page=0&order=model_comp
>
> What's going on?


The footer bar link "search" is used to start a new search, so you loose your current query.


(Latest version of DaDaBIK when this message was posted: 2.2.1)
 
Top