vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   grabbing results even though some WHERE's are false (https://vborg.vbsupport.ru/showthread.php?t=61930)

AN-net 02-25-2004 11:43 PM

grabbing results even though some WHERE's are false
 
ok basically im writing a searching script but when i dont type in an image name, an artist name,but i type in a gallery id it says there are none cause its selecting with image name and artist name being nothing. is there a away around this so it will just select everything with that gallery id even though image name and artist name are set to nothing?

Andreas 02-25-2004 11:49 PM

Or :)

AN-net 02-25-2004 11:55 PM

but i still want to if like artist name has some value that it will also refine the results from gallery id and remove those results which arent equal to artist name

Andreas 02-26-2004 12:07 AM

OK, so let's figure out what you want ;)

If I am right we're talking about 3 fields: Image Name, Artist Name and Gallery ID.

Pleasse tell me what you want to have returned in each of the following cases:
  • Only Gallery ID given
  • Only Artist Name given
  • Only Image Name given
  • Artist Name and Image Name given
  • Artist Name and Gallery ID given
  • Image Name and Gallery ID given
  • Artist Name, Image Name and Gallry ID given

AN-net 02-26-2004 12:22 AM

in all those cases i want all the data in my gallery table to be returned which matches the criteria in WHERE

Andreas 02-26-2004 12:28 AM

Yeah ;)
And what IS the criteria?

LordJMann 02-26-2004 12:32 AM

Can you post the query or the code for us to see? Would help solve the problem.

AN-net 02-26-2004 02:12 AM

PHP Code:

$fresults=$DB_site->query("SELECT * FROM gallery WHERE gallery_id='$gallery' AND artist_name='$artistname' AND image_name='$imgname'"); 


Andreas 02-26-2004 08:27 AM

This will return all rows from table gallery wher gallery_id is $gallery, artist_name ist $artitstname and image_name is $imgname.

But it seems like this is not what you want.

I've asked before how you want your conditions, but you did not gave me a useful answer so I can only guess:

[sql]
SELECT * FROM gallery WHERE (gallery_id = '$gallery' AND '$artistname'='' AND '$imgname'='') OR (gallery_id='$gallery' AND artist_name='$artistname' AND image_name='$imgname')
[/sql]

This will return all rows table gallery wher gallery ID is $gallery, artist_name ist $artitstname and image_name is $imgname, or all rows from table gallery where gallery ID is $gallery and $artistname, $imgname are empty.

A better way would be to construct your query in PHP so it does only contain conditions for columns you really care for.

AN-net 02-26-2004 09:58 AM

ok i see how it will work;)
did you see mess up on the first one? '$imgname'='' ?


All times are GMT. The time now is 07:20 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01208 seconds
  • Memory Usage 1,721KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete