Jump to content

select function where = array ?


henricar

Recommended Posts

hey everyone, I am trying to fetch an array using the WHERE condition. What I would like to do is set the WHERE equal to multiple values (as an array). This is the code I have but it doesn't seem to be working.. could anyone please help me? Thank you!

$fetchfol = mysql_query("SELECT * FROM following WHERE bywho='$currentuserid'");
$folarray = mysql_fetch_array($fetchfol);
$folarray = $folarray['followwho'];

$fetchsresults = "SELECT * FROM posts WHERE (bywho = '$folarray') ORDER BY popularity DESC";

 

Link to comment
https://forums.phpfreaks.com/topic/235042-select-function-where-array/
Share on other sites

If I want a couple fields specifically, sure. But where's the clarity in typing out everything by hand?

SELECT post_id, topic_id, forum_id, poster_id, icon_id, poster_ip, post_time, post_approved,
    post_reported, enable_bbcode, enable_smilies, enable_magic_url, enable_sig, post_username, post_subject,
    post_text, post_checksum, post_attachment, bbcode_bitfield, bbcode_uid, post_postcount, post_edit_time,
    post_edit_reason, post_edit_user, post_edit_count, post_edit_locked
FROM phpbb_posts...

Compare that with

SELECT * FROM phpbb_posts

Will I use every field that comes back? Maybe not. But I'd much rather have extra data than maintain a gigantic list of fields.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.