Page 2 of 2

Posted: Mon Aug 16, 2004 5:11 am
by sryuuza
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##

Posted: Mon Aug 16, 2004 5:18 am
by feyd
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...

Posted: Mon Aug 16, 2004 5:34 am
by sryuuza
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?

Posted: Mon Aug 16, 2004 5:25 pm
by feyd
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..

Posted: Mon Aug 16, 2004 6:45 pm
by sryuuza
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?

Posted: Mon Aug 16, 2004 10:08 pm
by protokol
Instead of using SELECT * FROM table, you just specify the columns. SELECT col1, col2, col3 FROM table

Posted: Mon Aug 16, 2004 11:45 pm
by d3ad1ysp0rk
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";

Posted: Tue Aug 17, 2004 5:21 am
by sryuuza
thank you, it ended up working great....

http://djmdevelopment.com/address2.php

but then i changed the fields for numbers... and ran into a whole new problem...

http://djmdevelopment.com/propertieslist.php

i have made a new post regarding this issue here...

http://www.devnetwork.net/forums/viewto ... 249#128249

any help is greatly appreciated :D