0

I am currently working on a edit page where one can select a Date and edit the text he wrote that speicific date. I would like this to happen via a dropdown form (select) and then when redirecting opening the text from that date so it can be edited.

The problem is that the date in the select is from a mysql result and I dont know how to use it again after I get it via POST.

<form action="" method="POST">
                <select>

                <?php
                    foreach($test as $row) {
                        echo '<option value="'.$row['Date'].'">'.$row['Date'].'</option>';
                    }
                ?>
                </select>

            <input type="submit" value="Choose">
        </form>

So, I want to now use the selected value to search for the real text that user wrote that day with the following sql query:

$result =  "SELECT Text FROM Text '.WHERE $_POST['$row['Date']']'. = Date";

But that wont work I always get:

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

Can someone show me the error and explain to me why that doesnt work? Thanks in advance!

Reun
  • 5
  • 3
  • Try ` – Danilo Bustos Feb 12 '17 at 17:40
  • `$result = "SELECT Text FROM Text WHERE '".$_POST['Date']."'= Date";` – Danilo Bustos Feb 12 '17 at 17:44
  • @DaniloBustos Thanks, that cleared the first error but now I seem to have a error in the query. Call to a member function fetch_array() on boolean: SELECT Text FROM Text WHERE '".$_POST['Date']."' = Date" – Reun Feb 12 '17 at 18:01
  • @DaniloBustos My own stupidity strikes again :P It wasnt SELECT Text FROM Text, it was SELECT Text from Texts... Thank you very much for your help! – Reun Feb 12 '17 at 18:07

0 Answers0