Foreign key help

2

I have an intranet system where the user creates a message for different sectors of the company, after creating the message, it can be edited and when it changes, it places an edited hyperlink at the end of the message, which when clicked , opens a modal with the original message.

So that's fine, the problem is when a message suffers more than one change, my select always picks the first record, instead of picking all up. I'll try to describe how it works:

RECORDED TABLE has (id, message, date, time) and so on. TABLE REPLIES_EDITED has (id, rec_id

asked by anonymous 28.11.2015 / 21:51

1 answer

0

Do the following:

$select = "SELECT * FROM recadosedit WHERE idRecados = {$id}";
    if($query = mysql_query($select)){
        if(mysql_num_rows($select)){
            while($resultado = mysql_fetch_array($select)){
                $resultados[] = $resultado; 
            }   
        }   
    }

    if(!empty($resultado)){
        foreach($resultados as $resultado){
            print " Recado: " . $resultado['recado'];
            print " Alterado(data): " . $resultado['dtAlterado']    
            print " Alterado(horas): " . $resultado['hrAlterado']   . "<br/>";
        }   
    }

Well, I do not have much time, so I'll be simple and objective.

The problem is how you return the values of this query with mysql_fetch_array :

$v = mysql_fetch_array($select);

In this case, you store only the value of the first column of the results found in this query. To do this, simply enter mysql_fetch_array into a loop, as in the example above:

while($v = mysql_fetch_array($select))
{
...
}
  

Why should not we use functions of type mysql_ *?

    
29.11.2015 / 01:51