Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
sryuuza
Forum Newbie
Posts: 14 Joined: Mon Aug 16, 2004 1:18 am
Location: Olympia, WA
Contact:
Post
by sryuuza » Mon Aug 16, 2004 5:11 am
hmmm, i guess i dont understand how to make the variable work, so that it changes... would use of rand() help maybe?
##EDIT##
Code: Select all
//get field names
$kv = rand(0,1);
print "<tr>\n";
print "
<th><a href='address2.php?id=$kv'>ID</a></th>
<th><a href='address2.php?fname=0'>First Name</a></th>
<th><a href='address2.php?lname=0'>Last Name</a></th>
<th><a href='address2.php?email=0'>Email</a></th>
<th><a href='address2.php?pnum=0'>Phone Number</a></th>\n";
print "</tr>\n\n";
the above code works, but not consistenly... is there a way to tell it to toggle between 0 and 1, and not randomly generate?
##EDIT##
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Aug 16, 2004 5:18 am
not especially...
Code: Select all
echo $_SERVER['PHP_SELF'] . '?your_recognized_key_here=' . ((int)!(isset($_GET['your_recognized_key_here']) ? $_GET['your_recognized_key_here'] : 1));
you can make that into a function or something...
sryuuza
Forum Newbie
Posts: 14 Joined: Mon Aug 16, 2004 1:18 am
Location: Olympia, WA
Contact:
Post
by sryuuza » Mon Aug 16, 2004 5:34 am
so, i would just make up a recognized key of my choice...
like a variable...
and then where would i put that code, and how would i call it up?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Aug 16, 2004 5:25 pm
you'd use that whereever you wanted to write out a url for your sorting.. depending on if you made that a function or switched it around to store the variable you can save off the url to echo out later..
sryuuza
Forum Newbie
Posts: 14 Joined: Mon Aug 16, 2004 1:18 am
Location: Olympia, WA
Contact:
Post
by sryuuza » Mon Aug 16, 2004 6:45 pm
everything is working great....
http://therandomjoe.com/DJM/idea4/address2.php
how do i specify certain fields that i want to show up, right now i just query the data base, and get all the fields... but i dont want to display the ID... how do i make it do i get everything but that field?
protokol
Forum Contributor
Posts: 353 Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:
Post
by protokol » Mon Aug 16, 2004 10:08 pm
Instead of using SELECT * FROM table , you just specify the columns. SELECT col1, col2, col3 FROM table
d3ad1ysp0rk
Forum Donator
Posts: 1661 Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA
Post
by d3ad1ysp0rk » Mon Aug 16, 2004 11:45 pm
reduce code:
index.php?o=lname
Code: Select all
if(isset($_GET['o'])){
$o = $_GET['o'];
}
else {
$o = "default_column";
}
$sql = "SELECT * FROM table ORDER BY $o ASC";