Jump to content

budimir

Members
  • Posts

    522
  • Joined

  • Last visited

Posts posted by budimir

  1. You are on a good forum.

     

    Try to google for basics of PHP and you will get your answer.

     

    The thing you are asking are very basic steps of PHP. Learn it, post some code and will help you with your problems.

     

    Good luck...

  2. You have a problem with your if statment:

     

    if $num is smaller then 0 show something?? Impossible...

     

     

    This is fixed:

    <?php
    $sql = "SELECT * FROM `pilots` ORDER BY `date` DESC LIMIT 7";
    $query = mysql_query($sql) or die(mysql_error());
    $num = mysql_num_rows($query) or die(mysql_error());
    ?>
    
    <table width=73% align="center">
        <tr bgcolor=#EEEEEE>
        <td width="10%">PID</td>
        <td width="15%">Name</td>
        <td width="17%">Hub</td>
        </tr>
       
    <?php 
    if($num>0) {   // <---- Bracket ONE opened                                                                  
        while ($data = mysql_fetch_assoc($query)) {  // <---- Bracket TWO opened ?>                   
            <tr bgcolor=#EEEEEE>
            <tr style="background-color:#EAEAEA;" onmouseover="this.style.backgroundColor='#0099FF'" onmouseout="this.style.backgroundColor='#EAEAEA'">
            <td><?php echo "{$data["login"]}"?></td>
            <td><?php echo "{$data["fname"]}","{$data["lname"]}"?></td>
            <td><?php echo "{$data["hub"]}"?></td>
            </tr>
            <?php
        } // <---- Bracket ONE closed 
            ?>                                                                               
        </table>
        <?php
    } // <---- Bracket TWO closed                                                                                       
    ?>

  3. $id is ID field form DB in table cancellation_train

     

    As you wrote:

    The table "cancellation_train" will have same fields plus id (primary key)

     

    So, if you want info about some train you do:

     

    $id = 4; //this is just an example
    $sql = "SELECT * FROM  train_cancellation WHERE id = '4' ORDER BY id, day, month, year, hour, direction";

     

    Hope it's more clear now...

     

     

  4. Try this:

     

    <td align=”left” valign=”top”><img src=”images/left_top.gif” border=”0”></td>

     

    Are you sure that picture extension is .gif ???

     

    Change slash \ to / for the picture path!

  5.         
    <?php  if($_POST["profile"])        {
              $username=$_GET["username"]; //Why are you using this???
              mysql_connect("localhost","root",""); //You need pass, although it's empty
              mysql_select_db("Plp");
              $query= mysql_query("UPDATE members WHERE pkid= '$pkid'") or die (mysql_error()); //Where do you get $pkid variable???
              $num=mysql_num_rows($query);
              if($num == 1)
              {
                echo "update successful";
              }
              else
              {
                $loginError= "didnt match with the database";
              echo "$loginError";
            }
           } 
          ?>

     

    I assume that you took somebodys code and now it's not working. The code that you wrote is very bad and non functional, you had a lot of errors.

     

    I don't know will this work in the way you wanted, becasue I don't know what is it supposed to do. I just corrected the code so it could work.

    :)

  6. You're file "Update_ac.php" is not complete you are missing couple of things.

     

    This is wrong:

    <?php
    $host="localhost";
    $username="wowdream_domaine";
    $password="mypassword";
    $db_name="wowdream_domaine";
    $tbl_name="members";
    
    mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");
    
    $sql="UPDATE $tbl_name SET username='$username', password='$password', access='$access' WHERE id='$id'";
    $result=mysql_query($sql);
    
    if($result){
    echo "Successful";
    echo "<BR>";
    echo "<a href='editadmin.php'>View result[/url]";
    }
    
    else {
    echo "ERROR";
    }
    
    ?>

     

    This is right:

     

    <?php
    $host="localhost";
    $username="wowdream_domaine";
    $password="mypassword";
    $db_name="wowdream_domaine";
    $tbl_name="members";
    
    mysql_connect("$host", "$username", "$password") or die ("cannot connect"); 
    mysql_select_db("$db_name") or die ("cannot select DB");
    
    $id = $_POST["id"];
    $username1 = $_POST["username"];
    $password1 = $_POST["password"];
    $access1 = $_POST["access"];
    
    $sql="UPDATE $tbl_name SET username='$username1', password='$password1', access='$access1' WHERE id='$id'";
    $result=mysql_query($sql) or die (mysql_error());
    $num=mysql_num_rows($result);
    
    if($num == 1){
    echo "Successful";
    echo "<br />";
    echo "<a href='editadmin.php'>View result[/url]";
    }
    ?>

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