Latest Posts in PHP

Re: in PHP
 
0
 

oh thank you friends and i realy apologyse for late reply i had exam last week, and i couldn't be up here.
so according to last last reply of gentlemedia i'm going to check my code maybe the error is in a php somewhere and not thats tags, anyways friends i will kepp you up to date if i solve my problem

Re: in PHP
 
0
 

Ah, sorry to keep coming back here, but I've made more progress and it has ended in distaster!

See for yourself, Strong-Links.org - all the links are active. Here is the code for the HTML header:

<nav id="nav-wrap">
                    <ul class="nav" id="nav">
                        <li class="nav-parent"><a

            <?php

                if ($pageURL = "http://strong-links.org/index.php")
                    {
                        echo 'class="active"'; }
                    else {
                        echo ' '; }

            ?>
            href="index.php">Strong Links</a>

                        </li>
                        <li class="nav-parent"><a

            <?php

                if ($pageURL = "http://strong-links.org/about.php")
                    {
                        echo 'class="active"'; }
                    else {
                        echo ' '; }

            ?>

            href="about.html">About Us</a>

                        </li>
                        <li class="nav-parent"><a href="#">Projects</a>
                <ul>
                    <li><a href="synergy.html">Project Synergy</a></li>
                    <li><a href="iOS.html">Strong Links iOS</a></li>
                    </ul>

                        </li>
                        <li class="nav-parent"><a

            <?php

                if ($pageURL = "http://strong-links.org/volunteer.php")
                    {
                        echo 'class="active"'; }
                    else {
                        echo ' '; }

            ?>

            href="volunteer.html">Volunteer</a>

                        </li>
                        <li><a

            <?php

                if ($pageURL = "http://strong-links.org/contact.php")
                    {
                        echo 'class="active"'; }
                    else {
                        echo ' '; }

            ?>

            href="contact.html">Contact</a></li>
                        <li class="last donate"><a

            <?php

                if ($pageURL = "http://strong-links.org/donate.php")
                    {
                        echo 'class="active"'; }
                    else {
                        echo ' '; }

            ?>

             href="donate.html">Donate</a></li>
                    </ul>                
                </nav>
Re: in PHP
 
0
 

i put the mysqli_error() in

$status_replies = "";
$sql2 = "SELECT s.*, u.avatar
FROM status AS u ON u.username = s.author 
WHERE s.osid='$statusid' 
AND s.type='b' 
ORDER BY postdate ASC";

$query_replies = mysqli_query($db_conx, $sql2);
$replynumrows = mysqli_num_rows($query_replies)
if($replynumrows > 0){
while ($row2 = mysqli_fetch_array($query_replies, MYSQLI_ASSOC)) {
$statusreplyid = $row2["id"];
$replyauthor = $row2["author"];
$replydata = $row2["data"];
$mysqli_error();

and im getting Parse error: syntax error, unexpected T_IF in /home/letsswin/public_html/template_status.php on line 54

Re: in PHP
 
0
 

So far, this is one link on my navigation bar:

<li class="nav-parent"><a "class="active" href="index.html">Strong Links</a>

This is the active one at the homepage.

I then made some PHP code to return the name of the current page:

<?php
function curPageURL() {
    $pageURL = 'http';
    $pageURL .= "://Strong-Links.org";
    $pageURL .=$_SERVER["SERVE_NAME"].$_SERVER["REQUEST_URI"];

    return $pageURL;
}
?>

and used that with the following code:

<?php
                curPageURL();
                if $pageURL = "http://test.strong-links.org/index2.php"
                    {echo "class="active"";}
                    else {echo "";} ?> href="index.html">Strong Links</a>

</li>

...But this doesn't seem to do anything :/

in PHP
 
0
 

Hi there,

My PHP is appalling/non-existant. I have a HTML website with a PHP header that I've 'included' on all the pages. The problem is that this header colours red whichever page we are currently on, defined under the CSS as being 'active'.

Therefore, from what I see, I need a way in my header.php file to be able to see what webpage is currently open on the site, and use that answer to set active on or off.

e.g.,

IF current webpage = about.php THEN set about.php to active
else
IF current webpage = home.php THEN set home.php to active
...etc, etc.

Is there a relatively simple way to accomplish this?

Re: in PHP
 
0
 

Hey guys,

So so sorry for the delay in response - been out of service for the last two weeks.

madCoder your suggestion worked :) I renamed it to .php and the header popualted fine! Thanks so much!

Re: in PHP
 
0
 

In the application that I'm working on, I have a series of formats that I'll be testing against, but my question was more general. I was thinking about a way to take any format that strtime will accept, and test if it's relative or absolute. Another way to put it, I think, is: did the user enter a year? If not, then it's an annual event.

For the app I'm working on, I might just end up using regex to figure out if the user entered a year. I haven't quite decided yet.

Re: in PHP
 
0
 

You have a few options for sending to multiple recipients, but the best is probably:

NOTES

id | date | text | title | sender_id

MESSAGES

note_id | recipient_id | status_id (PK on note_id and recipient_id)

That way you can send this to as many people as you like:

Note

1 | 2001-01-08 12:09:07 | Some text | This is a Title | 8

Messages (note #1 sent to users 5,6,9)

1 | 5 | 1
1 | 6 | 1
1 | 9 | 2

However you could do this in a number of ways as I said. You could also adapt it to create a group conversation - more like a chat or forum type communication.

OP Kudos: in PHP
 
0
 

Hello.
Is there any other way for not using the submit button?

<?php

$user_choice = $_POST['font_styles'];

if ($user_choice == "font_style_1"){
    $font = 'firstfont';
}elseif ($user_choice == "font_style_2"){
    $font = 'secondfont';
}elseif ($user_choice == "font_style_3"){
    $font = 'thiredfont';
}elseif ($user_choice == "font_style_4"){
    $font = 'forthfont';
}

?>

<html>
<head>
<style>

h1 {
font-family = $font;
}

</style>
</head>
<body>

    <form method='post'>
    <select name="font_styles">
    <option value="font_style_1">font_style_1</option>
    <option value="font_style_2">font_style_2</option>
    <option value="font_style_3">font_style_3</option>
    <option value="font_style_4">font_style_4</option>
    </select>
    <input type="submit">
    </form>

    <h1>username</h1>

 </body>
 </html>

I want when a user opens the drop-down menu and chooses an option, the font of the <h1> tag changes and the user can see his/her name in that font to see if he/she wants to save changes or choose an other font.
But I dn't want any submit button to be there, I want the font of the <h1> tag changes just by selecting a drop-down option. Is it possible?

Re: in PHP
 
0
 

Hi Diafol,

Thanks for the reply. To the first part: yes, that's what I mean but I also mean dates like "January 1st", which will change value every year.

My logic is that strtotime ( "January 1st, 2020", $x ) is going to be January 1st, 2020 whether $x is today or $x is 45 years ago, but strtotime ( "January 1st", $x ) is going to change depending on the value of $x.

My value 1 as the second parameter is somewhat arbitrary, as long as it's a date that will not to be used, which is true for my purpose.

Re: in PHP
 
0
 

hmm i get it but not at all, i have table kladilnica and im getting the values title, text, and date for ex. so in your example you have one more row which is to but i dont have that row in the database i dont understand what i need to do. Should i create one more row and that row to be the noteReceiver if yes, what if i want to send it to two users the note ?

Re: in PHP
 
0
 

What does relative mean? Do you mean like 'last week' or something like that?

I'm not sure that strtotime ( $date ) == strtotime ( $date, 1 ) is right. My understanding is that the second parameter stands for the base timestamp for the relative dates. So this would be at 1 second after the start of Unix Time, back in 1970.

So unless you had an exact match to that particular calculated timestamp, you'd get false - so you'd probably never get true.

If you're trying to see if a 'date' is not equal to the current date, there is a easier option:

$dt = new DateTime($date);
if($dt->format('Y-m-d') !== date('Y-m-d'))
{
    echo 'boo';
}else{
    ech 'yay';
}

There are many ways you could do the above, that's just off the top of my head.

Re: in PHP
 
0
 

If you have a db table ('notes') like so:

id | date | text | title | to | from

Then all you need to do is create a prepared statement (PDO or mysqli):

SELECT `id`, `date`, `title`, `text` ... FROM `notes` WHERE `to` = ? ORDER BY `date`  DESC 

Then bind the session user id to it - this is assuming that you have a user login system ad that you store the user's user_id in the session on successful login.

Obviously you can make it more sophisticated by getting the sender's name and by limiting this to say 20 notes (pagination):

SELECT n.id, n.date, n.title, n.text, u.username ... FROM `notes` AS n INNER JOIN `users` AS u WHERE n.to = ? ORDER BY n.date DESC LIMIT ?,?

If you have inbox and outbox tabs (like DW), it's a similar thing to do sent items:

SELECT n.id, n.date, n.title, n.text, u.username ... FROM `notes` AS n INNER JOIN `users` AS u WHERE n.from = ? ORDER BY n.date DESC LIMIT ?,?

If you want conversation type output:

SELECT n.id, n.date, n.title, n.text, u.username ... FROM `notes` AS n INNER JOIN `users` AS u WHERE n.to = ? OR n.from = ? ORDER BY n.date DESC LIMIT ?,?

This can be even more complicated is you have message statuses, like 'read', 'deleted', etc. Limitless options! This is fun stuff to play with.

in PHP
 
0
 

Hello i cant understand how i can send database info to user for example i want to send my note which contain (date, text, title and other info) and this info is under ID for ex. (123456) please someone explain me how i can do that or help me thank you :)

Re: in PHP
 
0
 

Hello,

This is going to be due to the settings in Apache that CPanel sets up. Is your new server running CPanel also if not it gets trickier. If it is running CPanel then you should set the user and group o the user id that owns the web site. If you can run ls -la /home/<your user> from a ssh connection and post the results I can give you an idea of the command to use to get it to work. For the time being you could do a chmod 775 on the upload directory so that the group can write and it might work. Need to see the actual listings to get a good idea.

PHP Tag Cloud