Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> MySQL
Author Message
ThePiston
Worker
Worker



Joined: Dec 22, 2004
Posts: 135

PostPosted: Mon Jan 24, 2005 10:34 am Reply with quote

I need to create a search form from my "nuke_users" table to find all "users_address" if "users_location" = any number 1-8. I want to results to come out on a 2 column table in any order (preferrably random). So there will be 8 checkboxes in this form and any or all of them can be selected... the results will be addresses that fit the criteria of being in location 1-8.

I'm sorry to simply ask for code.. I know it's rude, but I've done my time on other forums... I'm not so bright at MySQL just yet... hopefully I will be answering more questions than asking soon!

PS- thanks to Phreek for helping me on the other question... I need more help than I thought....
 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Mon Jan 24, 2005 2:17 pm Reply with quote

I did not test it but went off the top of my head. It should get you close.
Code:
$sql = "SELECT users_address FROM ".$user_prefix."_users WHERE users_location BETWEEN 1 AND 8";

$result = $db->sql_query($sql);
$totRows = $db->sql_num_rows($result);
if ($totRows) {
  echo "<table>";
  for ($i=0;$i<$totRows;$i++) {
    $row = $db->sql_fetchrow($result);
    echo "<tr><td>Column ".$row[$i+1]."</td><td><input type=\"textbox\" name=\"c1\"></td></tr>";
  }
  echo "</table>";
}
 
View user's profile Send private message
ThePiston







PostPosted: Mon Jan 24, 2005 3:04 pm Reply with quote

Raven, what if I were to use a form with 8 checkboxes and the form spit out $checkbox as the "answer" and the results would be displayed in another page called "Results.php.... how would that go?

PS the code would be "user_location = $checkbox"
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> MySQL

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©