PHP Question: How to fix these if/elseif statements

前端 未结 4 916
别跟我提以往
别跟我提以往 2021-01-23 16:30

I am trying to use these if/else if statements to display these php pages. The if/elseif statements allow for the php page to show up. The data is stored in the mysql. How do we

4条回答
  •  渐次进展
    2021-01-23 17:15

    How about using a switch statement?

    switch $result_array[0] {
         case 'Politics':     include('politics.php'); break;
         case 'This': include(...); break;
         case 'That': include(....); break;
         default: include('default.php'); break;
    }
    

    for a loooong set of if/then/else tests with simple "todo" sections, a switch statement is ideal.

提交回复
热议问题