121
xgarb
Re: Bit of a toughie - database column into select field - how?
  • 2003/10/28 10:41

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


Hiya,

I just got an empty pull down with your code. I moved it around a bit to this...

$sql = "SELECT DISTINCT location FROM ".$xoopsDB->prefix("users")." ORDER BY location";
$result = $xoopsDB->query($sql);
echo "<SELECT name='location_text'>";
while ($location = $xoopsDB->fetchArray($result)) {
echo "<OPTION value='".$location."'>".$location."</OPTION>";
}
echo "</SELECT>";

Which gives me a pull down with "Array" as the key and the value for five select options rather than the country names. There are five countries in the DB but only 4 unique, so I'm not sure what's going on there.

The other problem is that I can't just stick this on the page with the code. Maybe I'd need to make a function or something.

Thanks,

Andrew



122
xgarb
Re: Criteria class for SQL 'OR'
  • 2003/10/27 18:33

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


oops! Spoke too soon.

Using this code stops any of the other membersearch form elements from having any effect.

ie. Searching for a username and an interest returns all the members with that interest, not just those with a username match.

oh bother!



123
xgarb
Re: Criteria class for SQL 'OR'
  • 2003/10/27 18:04

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


That works perfectly!

Many thanks,

Andrew

PS Code for 4 columns below for anyone that's following this..

____________________________________

if ( !empty($HTTP_POST_VARS['interest']) ) {
$criteria = new CriteriaCompo(new Criteria('interest1', '%'.$myts->addSlashes(trim($HTTP_POST_VARS['interest'])).'%', 'LIKE'));
$criteria->add(new Criteria('interest2', '%'.$myts->addSlashes(trim($HTTP_POST_VARS['interest'])).'%', 'LIKE'), 'OR');
$criteria->add(new Criteria('interest3', '%'.$myts->addSlashes(trim($HTTP_POST_VARS['interest'])).'%', 'LIKE'), 'OR');
$criteria->add(new Criteria('interest4', '%'.$myts->addSlashes(trim($HTTP_POST_VARS['interest'])).'%', 'LIKE'), 'OR');
}



124
xgarb
Re: Bit of a toughie - database column into select field - how?
  • 2003/10/27 18:02

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


Netherlands at the moment. Makes it easier for the user info page.

Andrew



125
xgarb
Re: Criteria class for SQL 'OR'
  • 2003/10/27 16:10

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


Hi,

Doesn't seem to work ...

I've the following in xoopsmembers/index.php...

if ( !empty($HTTP_POST_VARS['interest']) ) {
$criteria = new CriteriaCompo(new Criteria('interest1', '%'.$myts->addSlashes(trim($HTTP_POST_VARS['interest'])).'%'));
$criteria->add(new Criteria('interest2', '%'.$myts->addSlashes(trim($HTTP_POST_VARS['interest'])).'%'), 'OR');
}

'interest' is the form variable and 'interest1/interest2' are column headings.

The following works, but only for column interest1 of course

if ( !empty($HTTP_POST_VARS['interest']) ) {
$criteria->add(new Criteria('interest1', '%'.addSlashes(trim($HTTP_POST_VARS['interest'])).'%', 'LIKE'));
}

Andrew



126
xgarb
Criteria class for SQL 'OR' - solved!
  • 2003/10/27 14:40

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


Hi all.

Anybody any idea how to make a Criteria class that will do a MySQL 'OR' rather than the available '=' or 'LIKE'.

I'd like to have members be able to search on one term across 4 columns. ie WHERE column1 = searchitem OR column2 = searchitem OR column3...etc

Thanks!

Andrew



127
xgarb
Re: Bit of a toughie - database column into select field - how?
  • 2003/10/26 11:39

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


Hi,

Thanks for your answer.

I've actually changed the user input and editing forms already to include a 'choose your country' pull down list (which is populated from xoopslists).

I now want it so when people want to use the member search form to find members they are only given the choice of countries that actually have members.

The SQL would be something like SELECT DISTINCT country FROM users, but I've no idea how to do this with the way XOOPS generates it's pull down form fields.

Thanks,

Andrew



128
xgarb
Bit of a toughie - database column into select field - Solved!
  • 2003/10/24 17:11

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


Hi all,

I'm in xoopsmembers/index.php, changing some of the search choices in the form. I want one of them to be a pull down that is populated from the user table (it's a country list) rather than populated from xoopslists.

This is so members can only search countries where there are actually members, rather than pulling the whole country list from xoopslists.

I took a look at the 'criteria' class, but have no idea how it works!

Thanks,

Andrew



129
xgarb
Re: template_c and system_userinfo.php
  • 2003/10/19 23:32

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


Ah! That works.

I did look in the database to see if there was something in it that would need updating but couldn't see it.

Which table is updated when I update the system module? ( Just so I can get more of an understanding what's going on)

Thanks for your help - I can sleep now!

Andrew




130
xgarb
template_c and system_userinfo.php
  • 2003/10/19 18:13

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


Hi all,

Can't seem to work this out...

My assumption..
/userinfo.php is built from /template_c/db%3Asystem_userinfo.html which in turn is built from /modules/system/templates/system_userinfo.html

So how come if I make changes to system_userinfo.html and delete all the cache files in template_c I still get a page without the changes?

Thanks for any pointers

Andrew




TopTop
« 1 ... 10 11 12 (13) 14 »



Login

Who's Online

261 user(s) are online (187 user(s) are browsing Support Forums)


Members: 0


Guests: 261


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits