Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm struggling with filters. I'm trying to create a page where I have list of checkboxes with several categories. Once the box is clicked it's retrieve results from mysql. One of the category has an array. Here is my html

<div id="options-list">
    <table>
    <tr><td>
        <label for="newstype">News:</label>
    </td></tr>
    <tr><td>
        <input class="cb" type="checkbox"  id="test" name="newstype[]" value="Generic News" checked=""/> Generic News<br />
        <input class="cb" type="checkbox" id="test"  name="newstype[]" value="Top News" /> Top News<br />
    </td></tr>
    <tr><td>
        <label for="category">Category: </label>
    </td></tr>
    <tr><td>
        <input class="cb" type="checkbox" id="test" name="category[]" value="Economy" checked=""/> Economy<br />
        <input class="cb" type="checkbox" id="test" name="category[]" value="Economic Indicators" /> Economic Indicators<br />
        <input class="cb" type="checkbox" id="test" name="category[]" value="Central Banks" /> Central Banks<br />
    </td></tr>
    <tr><td>
        <label for="regions">Regions:</label>
    </td></tr>
    <tr><td>                
        <input class="cb" type="checkbox" id="test" name="regions[]" value="EMU & Nordic" checked=""/> EMU & Nordic<br />   
        <input class="cb" type="checkbox" id="test" name="regions[]" value="UK" /> UK   <br />
        <input class="cb" type="checkbox" id="test" name="regions[]" value="North America" /> North America<br />               
    </td></tr>
    <tr><td>
        <label for="timezones">Time Zones:</label>
    </td></tr>
    <tr><td>
        <input class="cb" type="checkbox" id="test" name="timezone[]" value="EMEA Mkt Hours" checked=""/> EMEA Mkt Hours<br />
        <input class="cb" type="checkbox" id="test" name="timezone[]" value="US Mkt Hours" /> US Mkt Hours<br />            
    </td></tr>
    <tr><td>
        <label for="articletype">News Type:</label>
    </td></tr>
    <tr><td>
        <input class="cb" id="test" name="articletype[]" value="News" type="checkbox" checked=""> News<br />
        <input class="cb" id="test" name="articletype[]" value="Views" type="checkbox"> Views<br />
    </td></tr>
    </table>
</div>
<div class="headlines">
    <h1>HEADLINES</h1>
    <div class="block" id="newsdisplay">
    <table class="tableNews">
        <script type="text/html" id="headlines-temp">
            <tr>
                <td width="75px">  </td>
                <td><div data-bind="text:headline"></div></td>
            </tr>
        </script>
        <div class="example">  <? list_newsfeed(); ?></div>

Here is my mysql function:

function list_newsfeed() {
    $perpage=25;  
    if (isset($_GET["page"])) { 
        $page  = $_GET["page"]; 
    } else { 
        $page=1; 
    };

    $start_from = ($page-1) * $perpage;

    $result = mysql_query("SELECT * FROM headnews ORDER BY news_date DESC, news_time DESC LIMIT $start_from, $perpage");
    $rowColors = Array('rgba(0,0,0,0.22)', 'none'); $nRow = 0;

    while ($row = mysql_fetch_array($result)) {
        echo "<tr style=\"background-color:".$rowColors[$nRow++ % count($rowColors)]."\"><td width=\"75px\">".$row['news_time']. "</td><td> " .$row['name']. "</td></tr>";
    }

    $rs_result = mysql_query("SELECT COUNT(id) FROM headnews");
    $row = mysql_fetch_row($rs_result);
    $total_headnews = $row[0];
    $total_pages = ceil($total_headnews / $perpage);
    $pagLink = "<div class=\"pagination\">";
    for ($i=1; $i<=$total_pages; $i++) {
        $pagLink .= "<a href=\"headnews.php?page=".$i."\">".$i."</a> ";
    }

    echo $pagLink . "</div>";
}

Would greatly appreciate your help as I am very new to ajax but I need to be done asap and it's been driving me crazy for a couple days...

share|improve this question
1  
I don't see any ajax call. What exactly is your problem? – Olaf Dietsche Mar 4 at 22:52
indeed no ajax but okay...... please first debug your code before you ask. this will always fail > $result = mysql_query ("SELECT TIME_FORMAT(foo_hour, '%H:%i'"); you are missing a ) and where is foo_hour selected from ? and even worse doo you want $result to be the first query or the second......... sorry but i think you need to go back to the php/mysql tutorials before you promise people to create something for them – Miguelo Mar 4 at 23:26
Miguelo, sorry, I forgot to remove this line.. Obviously time format is not relevant here. – user2132990 Mar 5 at 4:50

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.