monkeytooth Posted January 31, 2008 Share Posted January 31, 2008 I have a weird issue.. I posted before with the similar topic, but I couldn't delete that topic or edit it (and I realized how gibberish sounding it was, which in the end this might to but i dunno..) First off I gotta know, is this even remotely possible or am I just a far off dreamer wishing for something that can't be done. Anyway... Here goes, I have created a chart that displays numbers in order 0-xxxx. I am currently using a "For" loop.. for ($i = 0; $i < $gme_total_count; $i++) { if ($xzz < $gme_tble_cellz) { if ($xzz == $gme_tble_cells) { $xzz = "1"; echo "<td align='center' valign='top' width='" . $gme_tble_tdsize . "'><font color='" . $gme_fnt_color . "' face='" . $gme_fnt_face . "' size='" . $gme_fnt_size . "'>" . str_pad($i, 2, "0", STR_PAD_LEFT) . "</font></td></tr>"; } else { $xzz++; echo "<td align='center' valign='top' width='" . $gme_tble_tdsize . "'><font color='" . $gme_fnt_color . "' face='" . $gme_fnt_face . "' size='" . $gme_fnt_size . "'>" . str_pad($i, 2, "0", STR_PAD_LEFT) . "</font></td>"; } } } which outputs something to the effect of: Works like I charm couldn't be happier. But what I want it to do is also find some predetermined numbers listed in another table (note: each number in its own separate row, with other information linked with that number). And best I can come up with is.. $query3="SELECT * FROM mt_gm3_active"; $result3=mysql_query($query3) or die ("Error in query: $query3. " . mysql_error()); while($result3a = mysql_fetch_array( $result3 )) { echo $result3a['gm3_picked']. "<br />"; } Now mind you both loops do what they are supposed to, thats not the issue. The issue is getting them to work hand in hand. To inevitably alter output of the above image to look something like: When the certain numbers are found on the other table. I am so incredibly lost, I have been banging my head against a wall tryin to make it work. to come up with scrapped conclusion after scrapped conclusion. One of my problems trying to make it work is no matter what I do one loop x's out the other eventually. Or turns itself into an endless loop.. Any help would be much appreciated. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/88655-solved-overlapping-problem-with-forwhile-loop-phpmysql-query/ Share on other sites More sharing options...
resago Posted January 31, 2008 Share Posted January 31, 2008 put all the ACTIVE numbers in an array first. then in your for loop, perform an in_array() to see if the current number is an active one. Quote Link to comment https://forums.phpfreaks.com/topic/88655-solved-overlapping-problem-with-forwhile-loop-phpmysql-query/#findComment-454058 Share on other sites More sharing options...
monkeytooth Posted January 31, 2008 Author Share Posted January 31, 2008 thats one of my problems, as bad as that sounds.. i cant get them into an array.. its been so long since ive really used sql that i have forgoten some of the simple stuff so to speak. And when I go search for a problem similar i keep coming across the same solution for a diffrent yet similar problem be it in tutorial form or otherwise.. do you have a sample of what i have to do to make a single var array like you mention Quote Link to comment https://forums.phpfreaks.com/topic/88655-solved-overlapping-problem-with-forwhile-loop-phpmysql-query/#findComment-454064 Share on other sites More sharing options...
resago Posted January 31, 2008 Share Posted January 31, 2008 $query3="SELECT * FROM mt_gm3_active"; $result3=mysql_query($query3) or die ("Error in query: $query3. " . mysql_error()); while($result3a = mysql_fetch_array( $result3 )) { $active[] = $result3a['gm3_picked']; } Quote Link to comment https://forums.phpfreaks.com/topic/88655-solved-overlapping-problem-with-forwhile-loop-phpmysql-query/#findComment-454066 Share on other sites More sharing options...
monkeytooth Posted January 31, 2008 Author Share Posted January 31, 2008 I was thinking something like that.. but wasnt sure of myself on that working. Ill give it a shot though, how would I use that? Would i do a row count against the array of results for how many returned a number in use. So I could then call upone $active[1],..[2],..[3].. or would i be able to just call the array itself as a single var and use the results from that single var alone.. I might be thinking to much into it.. but its still comes down to the for loop and how would it work for me.. Quote Link to comment https://forums.phpfreaks.com/topic/88655-solved-overlapping-problem-with-forwhile-loop-phpmysql-query/#findComment-454319 Share on other sites More sharing options...
monkeytooth Posted February 1, 2008 Author Share Posted February 1, 2008 can i use implode or explode some how? I know I'm looking to overall pull all data from this particular table.. but based on the number more so then less as the number is the connection between the 2 loops I have going. However if I'm going to use implode/explode i need just the numbers to part of an array.. I'm stupefied, and a stubborn jackass.. I'm doing something for someone.. and I know the concept is possible.. its just figuring out the work around to make it physically possible. I dunno.. I got such a headache from this.. an I'm frustrated right now so I'm sorry if I seem to be aggressively coming at this topic.. What can I do.. Quote Link to comment https://forums.phpfreaks.com/topic/88655-solved-overlapping-problem-with-forwhile-loop-phpmysql-query/#findComment-454882 Share on other sites More sharing options...
resago Posted February 2, 2008 Share Posted February 2, 2008 lookup in_array Quote Link to comment https://forums.phpfreaks.com/topic/88655-solved-overlapping-problem-with-forwhile-loop-phpmysql-query/#findComment-455829 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.