Jump to content

date display


angelsRock

Recommended Posts

Function are not parsed inside strings, of course. You should be using something like this instead:

 

while($row2=mysql_fetch_array($exec2,MYSQL_BOTH))
{               
echo '<tr>';
echo "<td width=100 align=center>", substr($row2['datePosted'],0,10), "   </td>";               
}

Link to comment
https://forums.phpfreaks.com/topic/73094-date-display/#findComment-368626
Share on other sites

That'll hit errors (you've used commas instead of periods). Try this:

while($row2=mysql_fetch_array($exec2,MYSQL_BOTH))
                        {               
                           echo'<tr>';
      
                  
                           echo"<td width=100 align=center>".substr('$row2[datePosted]',0,10)."</td>";
               
}

 

Link to comment
https://forums.phpfreaks.com/topic/73094-date-display/#findComment-368628
Share on other sites

That'll hit errors (you've used commas instead of periods). Try this:

 

No, it doesn't. Language construct "echo" takes any number of arguments, separated by comma. Thus using something like "echo 'foo', 'bar';" will output "foobar". This is in fact better than using the concatenation operator (dot), because the PHP does not have to first combine the string before outputting them.

 

In addition, your code wont work as intended, because you put the variable inside single quotes, and variables are not parsed inside single quotes.

Link to comment
https://forums.phpfreaks.com/topic/73094-date-display/#findComment-368636
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.