1989gta Posted December 8, 2006 Share Posted December 8, 2006 I am in the process of writing a page and I need a point in the right directionBasically the page will resemble a spread sheet with 8 columns. I have all the queries worked out my code will look something like this (below) the information in column A will be used in every query through out the page.echo "<table border=1>"; echo "<tr>";echo "<td>column_A</td>"; echo "<td bgcolor=#f8f3df> column_B</td>"; echo "<td bgcolor=#f8f3df> column_C</td>"; echo "<td bgcolor=#f8f3df> column_D</td>"; echo "<td bgcolor=#f8f3df> column_E</td>"; echo "<td bgcolor=#f8f3df >column_F</td>"; echo "<td bgcolor=#f8f3df> column_G</td>"; echo "<td> column_H</td>"; echo "</tr>"; /////column_A////// $query = ""; $result = mssql_query ($query); while($line = mssql_fetch_array($result)){ echo "<tr border=1>"; $app =$line[0]; $install_date =$line[1]; echo "<td>"; echo $A); echo "</td>"; } ////b////$current_date = date('m-d-y');$query = ""; $result = mssql_query ($query); while($line = mssql_fetch_array($result)){ $todays_count = $line[0]; echo "<td>"; echo $B; echo "</td>";} and so on with the remaining 6 queries...The problem I'm having is this seems to work fine when i have one piece of data echoed for column A all the query's run and echo what needs to, but when i have more that one piece of data it only echo's the last piece of data queriedso i need to change the page so when the query for column A and it finds more than one entry it takes that piece and runs the 7 query's and echoes the data and moves on the next and does the same thing. I hope that i got my point acrossedThank you for viewing this post Link to comment https://forums.phpfreaks.com/topic/29865-problems-finishing-page/ Share on other sites More sharing options...
drifter Posted December 8, 2006 Share Posted December 8, 2006 I think I get what you are saying so here is what you need to do.[code]$data=Array();Now for each query something like thisquery A $data['a']=Array();while($line = mssql_fetch_array($result)){ array_push($data['a'],$line);}query B $data['b']=Array();while($line = mssql_fetch_array($result)){ array_push($data['b'],$line);}[/code]do this for each of your 7 - give you an array or arrays.now [code]$j=strlen($data['a']);for($i=0;$i<$j;$i++){ echo "<tr>"; echo "<td>" . $data['a'][$i] . "</td>"; echo "<td bgcolor=#f8f3df>" . $data['b'][$i] . "</td>"; echo "<td bgcolor=#f8f3df>" . $data['c'][$i] . "</td>"; echo "<td bgcolor=#f8f3df>" . $data['d'][$i] . "</td>"; echo "<td bgcolor=#f8f3df>" . $data['e'][$i] . "</td>"; echo "<td bgcolor=#f8f3df >" . $data['f'][$i] . "</td>"; echo "<td bgcolor=#f8f3df>" . $data['g'][$i] . "</td>"; echo "<td> column_H</td>"; echo "</tr>"; }[/code]Now obviously this is incomplete code, but will hopefully get you going in the right direction. Link to comment https://forums.phpfreaks.com/topic/29865-problems-finishing-page/#findComment-137257 Share on other sites More sharing options...
1989gta Posted December 8, 2006 Author Share Posted December 8, 2006 ah i see it pumps all my data into a stored array then once all the querys have exhausted them selfves it will echo everything. Yes that is exactly what i was looking for thank you Link to comment https://forums.phpfreaks.com/topic/29865-problems-finishing-page/#findComment-137548 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.