Jump to content

sniesler08

Members
  • Posts

    13
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

sniesler08's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Now I am stumped this is far any help would be awesome This is what I have gotten so far, this is what it does right now is display each Header above each bit of data and spans across 5 columns for each foreach loop but what i am trying to understand here is i am trying to get the header then the data then another header and data and so on but only about 4 or number of my choosing grouped header/data but select how many are in each column up to 5 columns. Heres an example of what i am trying to do. A D K N S AlexandraHeadlands DickyBeach KingsBeach Nambour SandstonePoint Aroona Diddillibah KielMountain Ninderry ShellyBeach [/td] Doonan KundaPark NoosaHeads SippyDowns B Dulong Kuluin Ningi SunriseBeach Beachmere DeceptionBay Kilcoy NorthArm SunshineBeach BanksiaBeach Noosaville Scarborough Beerburrum E L Beerwah EerwahVale Landsborough O T Bellara Elimbah Tanawha Bellmere Eudlo M P TowenMountain Birtinya Eumundi Maleny Petrie Tewantin Bongaree Mapleton Palmview TwinWaters Bokarina F Marcoola Palmwoods BribieIslandArea Flaxton MarcusBeach Parklands U Buddina ForestGlen MaroochyRiver Parrearra UpperCaboolture Burnside Maroochydore PeregianBeach Buderim G Minyama Pinbarren V Burpengary GlassHouseMountains MoffatBeach PointArkwright Valdora BliBli Mons PelicanWaters H Montville PacificParadise W C Highworth Mooloolaba WeybaDowns CoolumBeach Hunchy Mooloolah Q Warana Caboolture MountainCreek WestWoombye CabooltureSouth I MountCoolum R Woombye Caloundra ImageFlat Morayfield Rosemount Woorim CastawaysBeach Mudjimba Redcliffe WamuranBasin Chevallum J Woodford CoesCreek WoodyPoint Cooroy Wamuran Currimundi Wurtulla X Y YandinaCreek Yandina Z [td] This is an example of how it is being displayed right now A Airlie Beach Andergrove Alexandra Armstrong Beach Alligator Creek B Bucasia Blacks Beach Beaconsfield Bakers Creek Balberra Bloomsbury Breadalbane Ball Bay Belmunda C Cannonvale Calen Crystal Brook Cremorne Chelona Campwin Beach Cape Hillsborough Conway Heres The Code i have so far. <?php $file = "widget.csv"; @$fp = fopen($file, "r") or die("Could not open file for reading"); $outputArray = array(); $count = 0; while(($shop = fgetcsv($fp, 1000, ",")) !== FALSE) { $outputArray[array_shift($shop)] = array_filter($shop); } echo "<table>"; foreach ($outputArray as $alphabetical=>$value){ echo "<th colspan='4'><b>" . $alphabetical ."</b></th>"; echo "<tr>"; foreach ($value as $key){ $afterkey=preg_replace('/\s+/','-',$key); if ($count == 4){ echo '</tr><tr><td><a href="map.php?mapaddress='.$afterkey.'-qld&mapname='.$key.'">'.$key.'</a></td>'; $count = 0; }else{ echo '<td><a href="map.php?mapaddress='.$afterkey.'-qld&mapname='.$key.'">'.$key.'</a></td>'; } $count++; } echo "</tr>"; $count = 0; } echo "</table>"; echo "\n<br />"; ?> Heres my CSV File:
  2. I've gotten it to display with the UL and LI Tags but the problem im having is it is all messed up now there listing from left to right and then in random spots is it possible i could get just a hint in the right direction please? <?php $file = "include/service_areas2.csv"; @$fp = fopen($file, "r") or die("Could not open file for reading"); $outputArray = array(); $count = 0; while(($shop = fgetcsv($fp, 1000, ",")) !== FALSE) { $outputArray[array_shift($shop)] = array_filter($shop); } foreach ($outputArray as $alphabetical=>$value){ echo '<ul class=box>'; echo "<li><b>" . $alphabetical ."</b></li>"; foreach ($value as $key){ $afterkey=preg_replace('/\s+/','-',$key); echo '<li><a href="map.php?mapaddress='.$afterkey.'-qld&mapname='.$key.'">'.$key.'</a></li>'; echo "</ul>"; } echo "\n<br />"; ?>
  3. Thats definitely something to think about i think i may not use tables in the future definitely but i think its mainly the php i really need help with. any help would be appreciated. Your definitely right about the tables n div tags even i see tables as the old way of doing it really i should be using div's these days
  4. right now it displays the first column of the array as a header for each foreach loop then i've got the data displayed under each header and it has 4 columns or a number of my choosing with data displayed under the Table Headings. I am trying to make it display 4 or so columns but with the each group having a certain number of grouped table (data/header) in each column. a different amount for each column that i can choose IF Possible i'd like the choice of being able to remove the headers eg. Z when there is no data in them. This is an example of how it is being displayed right now Any Help would be greatly appreciated Heres The Code i have so far. <?php $file = "widget.csv"; @$fp = fopen($file, "r") or die("Could not open file for reading"); $outputArray = array(); $count = 0; while(($shop = fgetcsv($fp, 1000, ",")) !== FALSE) { $outputArray[array_shift($shop)] = array_filter($shop); } echo "<table>"; foreach ($outputArray as $alphabetical=>$value){ echo "<th colspan='4'><b>" . $alphabetical ."</b></th>"; echo "<tr>"; foreach ($value as $key){ $afterkey=preg_replace('/\s+/','-',$key); if ($count == 4){ echo '</tr><tr><td><a href="map.php?mapaddress='.$afterkey.'-qld&mapname='.$key.'">'.$key.'</a></td>'; $count = 0; }else{ echo '<td><a href="map.php?mapaddress='.$afterkey.'-qld&mapname='.$key.'">'.$key.'</a></td>'; } $count++; } echo "</tr>"; $count = 0; } echo "</table>"; echo "\n<br />"; ?> Heres an example of what i am trying to do. A D K N S AlexandraHeadlands DickyBeach KingsBeach Nambour SandstonePoint Aroona Diddillibah KielMountain Ninderry ShellyBeach [bR] Doonan KundaPark NoosaHeads SippyDowns B Dulong Kuluin Ningi SunriseBeach Beachmere DeceptionBay Kilcoy NorthArm SunshineBeach BanksiaBeach [bR] [bR] Noosaville Scarborough Beerburrum E L [bR] [bR] Beerwah EerwahVale Landsborough O T Bellara Elimbah [bR] [bR] Tanawha Bellmere Eudlo M P TowenMountain Birtinya Eumundi Maleny Petrie Tewantin Bongaree [bR] Mapleton Palmview TwinWaters Bokarina F Marcoola Palmwoods [bR] BribieIslandArea Flaxton MarcusBeach Parklands U Buddina ForestGlen MaroochyRiver Parrearra UpperCaboolture Burnside [/td] Maroochydore PeregianBeach Buderim G Minyama Pinbarren V Burpengary GlassHouseMountains MoffatBeach PointArkwright Valdora BliBli Mons PelicanWaters H Montville PacificParadise W C Highworth Mooloolaba WeybaDowns CoolumBeach Hunchy Mooloolah Q Warana Caboolture MountainCreek WestWoombye CabooltureSouth I MountCoolum R Woombye Caloundra ImageFlat Morayfield Rosemount Woorim CastawaysBeach Mudjimba Redcliffe WamuranBasin Chevallum J Woodford CoesCreek WoodyPoint Cooroy Wamuran Currimundi Wurtulla X Y YandinaCreek Yandina Z [td]
  5. Now I am stumped this is far any help would be awesome This is what I have gotten so far, this is what it does right now is display the first column of the array as a header for each foreach loop then i've got the data displayed under each header in the loop but what i am trying to understand here is i am trying to get under each header it to have 4 columns or a number of my choosing. Heres an example of what i am trying to do. A airlie beachAndergroveAlexandraArmstrong Beach Alligator Creek B BucasiaBlacks BeachBeaconsfieldBakers Creek BalberraBloomsburyBreadalbaneBall Bay Belmunda This is an example of how it is being displayed right now A Airlie Beach Andergrove Alexandra Armstrong Beach Alligator Creek B Bucasia Blacks Beach Beaconsfield Bakers Creek Balberra Bloomsbury Breadalbane Ball Bay Belmunda C Cannonvale Calen Crystal Brook Cremorne Chelona Campwin Beach Cape Hillsborough Conway Heres The Code i have so far. <?php $file = "widget.csv"; @$fp = fopen($file, "r") or die("Could not open file for reading"); $outputArray = array(); while(($shop = fgetcsv($fp, 1000, ",")) !== FALSE) { $outputArray[array_shift($shop)] = array_filter($shop); } print_r($outputArray); echo "\n<br />"; //display echo "<table>"; foreach ($outputArray as $alphabetical=>$value){ echo "<th><b>" . $alphabetical ."</b></th>"; echo "<tr>"; foreach ($value as $key){ echo "<td>" . $key . "</td>"; } echo "</tr>"; } echo "</table>"; echo "\n<br />"; ?> Heres my Csv File which i am using as an array in the code
  6. Thanks guys that has helped quite a bit the next step is to add the associative letter as the header instead of the numbers which i had earlier hmm.
  7. Array(2) and others are just an empty array for some reason i do think it is to do with the preg_replace but don't have enough of an understanding about it to sort it out any help would be appreciated i don't particularly know if i need preg replace but i have tried with out it or other options and nothing has worked so far. Heres the code <?php $file = "widget.csv"; $delimiter = ","; $enclosure = '"'; @$fp = fopen($file, "r") or die("Could not open file for reading"); while (!feof($fp)) { $tmpstr = fgets($fp, 100); $shop[] = preg_replace("//", "", $tmpstr); /* $tmpstr = $shop; */ } for ($i=0; $i < count($shop); $i++) { $shop[$i] = explode($delimiter, $shop[$i]); } print_r ($shop); echo "<h1>Manual access to each element</h1>"; echo $shop[0][0]." costs ".$shop[0][1]." and you get ".$shop[0][2]."<br />"; echo $shop[1][0]." costs ".$shop[1][1]." and you get ".$shop[1][2]."<br />"; echo $shop[2][0]." costs ".$shop[2][1]." and you get ".$shop[2][2]."<br />"; echo "<h1>Using loops to display array elements</h1>"; echo "<table>"; /* for ($row = 0; $row < 3; $row++) */ for ($row=0; $row<count($shop); $row++) { echo "<th colspan='3'><b>" . $shop[$row][0]."</b></th>"; echo "<tr>"; /* for ($col = 1; $col < 6; $col++) */ for ($col=1; $col < count($shop); $col++) { echo "<td>".$shop[$row][$col]."</td>"; } echo "</tr>"; /* echo "</li>"; */ } echo "</table>"; ?> This is the CSV File widget.csv It is generating this as the output of the Array as this but the array(2) and others as you can see are empty C should of been the first one after B field had finished.
  8. i am having another problem thou i am trying to have it as the first column of the array output into the table as and so on i thought i was on the right track but having difficulties getting this to happen any help would be appreciated This is the output of how it stands so far.
  9. each row has 21 commas well at the moment till i add more data what happens if i add more data to it how would that effect it
  10. Unfortunately that seems to have no effect its still saying Notice: Undefined offset: 20 in C:\wamp\www\examples\ideas\new2.php on line 36 which is the $data_array[$c] = $data[$c]; hmm... any ideas
  11. this is my code im getting an error message Notice: Undefined offset: 20 in C:\wamp\www\examples\ideas\new2.php on line 33 <?php echo "<table>\n"; //Move through a CSV file, and output an associative array for each line ini_set("auto_detect_line_endings", 1); $current_row = 1; $d=0; $handle = fopen("widget.csv", "r"); while ( ($data = fgetcsv($handle, 10000, ",") ) !== FALSE ) { $number_of_fields = count($data); echo "<thead>\n<tr>"; if ($current_row == 1) { //Header line /* for ($c=0; $c < $number_of_fields; $c++) */ { $header_array[$d] = $data[$d]; echo "<th>" . $data[$d] . "</th>"; } echo "</tr>\n</thead>\n\n<tbody>"; } else { //Data line for ($c=1; $c < $number_of_fields; $c++) echo "<tr>"; { $data_array[$c] = $data[$c]; /* echo "<td>" . $data[$c] . "</td>"; */ } echo "</tr>\n"; } $current_row++; } fclose($handle); echo "</tbody>\n</table>"; echo $number_of_fields; echo "<br />"; echo $current_row; ?> this is my csv file Could anyone please help little stuck on why its causing this error.
  12. i've been able to load up a csv file and display it as a html table but what i'm having trouble with is sorting it out with headings a to z but what i am trying to do is have 4 columns like this. Surgestions about how to do what im after i was hoping i could span the say A across all columns and centering them in the future also but thats not really the problem mainly the getting the array of the csv file and code right iguess. any help would be appreciated <table> <tr> <th>A</th> </tr> <tr> <td>Apple1</td> <td>Apple2</td> <td>Apple3</td> <td>Apple4</td> <td>Apple5</td> <td>Apple6</td> </tr> <tr> <th>B</th> </tr> <td>Banana1</td> <td>Banana2</td> <td>Banana3</td> <td>Banana4</td> <td>Banana5</td> <td>Banana6</td> <tr> <th>C</th> </tr> <td>Cold1</td> <td>Cold2</td> <td>Cold3</td> <td>Cold4</td> <td>Cold5</td> <td>Cold6</td> </table> This is the code for inputting of the csv file i also have some other code i was wanting to use for the sorting of the array data from the csv file i'll past below.... Heres the code for the sorting of the table data from the array
×
×
  • 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.