Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/29/2021 in all areas

  1. I ran your code and it functions OK. The only way I can see that $result is not defined is if $_GET['id'] is empty or not an integer. But you say that you are inputting a valid id value so I'm out of guesses. Good luck.
    1 point
  2. the sql query you are showing and the output you are (trying) to produce from that query make no sense. if this was working, you are querying for the row of data WHERE the id column matches the $_GET['id'] value and looping to produce a (one) link with ?id=$row['id'] in it, i.e. a link containing the same id that was in $_GET['id']. you need to step back and come up with a stateable definition of what your code needs to do. you are doing two things, 1) producing navigation links, and 2) when a link has been clicked, you are displaying the content that corresponds to the id in the clicked link. to do item #1, you would query to get ALL the page ids, and page names/titles, which i assume are in the menuheader column (if you list out the columns you are selecting in a query, rather than using *, it helps make your code/query self-documenting.) you would then test and loop over the result from this query to produce navigation links. Note: almost every if() conditional test needs an else so that code does something when the main condition fails. for navigation link data, if there is no data, rather than outputting nothing, you should output a 'sorry, nothing to display' or similar message. to do item #2, you would test for a $_GET['id'] value and use it to query to get the matching row of data, fetch that single row of data (no loop needed), and if there was a matching row of data, output the content for the page. if there was no matching row of data, you would instead output a 'nothing to display' or similar message.
    1 point
  3. instead of that, make your data function return your games variable. return $games; Then you can assign it when you call your data function and access whatever you want. $game = new CsvToArray(); $games = $game->data(); echo $games[64]['Home Team']; Make it a function argument. function data($file){ $fileName = fopen($file,'r+'); ...
    1 point
  4. No. Using eval is a really bad idea. There are always better solutions to problems than using eval. $num is the only unknown part, right? Look at this: $gm = array( 9 => array( "hodds" => $games[53]["BP"], "aodds" => $games[52]["BP"] ) ); echo $gm[$num]["hodds"]; Really easy.
    0 points
This leaderboard is set to New York/GMT-04:00
×
×
  • 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.