Jump to content

[SOLVED] Overlapping Problem with For/While Loop PHP/MySQL Query


monkeytooth

Recommended Posts

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:

numbers.jpg

 

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:

 

numbers2.jpg

 

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.