Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5

Thread: Asp to Php

  1. #1
    Member mikaelsnavy's Avatar
    Join Date
    Jun 2005
    Location
    Oregon
    Posts
    48
    Member #
    10358
    Hi,
    I am making my first website with php. I am using dreamweaver and have some experience with asp. I was wondering what is the php equivelent of:

    <% IF recordset("field") = "Whatever" THEN %> The Data <%END IF %>

    Thank you,
    mikael

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    This code assumes that you have retrieved the data from the database table

    PHP Code:
    <?php
    if ($row[column_name] == "some value") { ?> The Data <?php ?>

  4. #3
    Member mikaelsnavy's Avatar
    Join Date
    Jun 2005
    Location
    Oregon
    Posts
    48
    Member #
    10358
    Ok, I have it working partially. Here is my code:

    <?php if ($row_database[TablePosition] == "1" or "3" or "5" or "7" or "9" or "11" or "13" or "15" or "17" or "19" or "21" or "23" or "25" or "27" or "29" or "31" or "33" or "35" or "37" or "39" or "41" or "43" or "45" or "47" or "49" or "51"){?>
    Data <?php } ?>

    What I have is alternating images which the url is pulled from the database. I am tring to have them alternating but for some reason, it shows all the records even though the "TablePosition" is false on half of them. I am new at php and eager to learn, so if anyone has any suggestions, it would be great.

    Thanks,
    Mikael

  5. #4
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Okay this code is untested, but its more efficient that all those or's

    PHP Code:
    <?php
    $therow 
    $row[TablePosition];
    switch (
    $therow)
    {
    case 
    1;
    // put the code here that is to be executed when row position is 1
    break; // keep this so the following code does not execute
    case 2;
    // put the code here that is to be executed when row position is 2
    break; // keep this so the following code does not execute
    case 3;
    // put the code here that is to be executed when row position is 3
    break; // keep this so the following code does not execute
    default: // put the code here that is to be executed when an invalid number is entered, such as non existing, or an even number
    }
    ?>
    More info: http://www.w3schools.com/php/php_conditionals.asp

    1 question: Is tableposition a column in your table?

  6. #5
    Member mikaelsnavy's Avatar
    Join Date
    Jun 2005
    Location
    Oregon
    Posts
    48
    Member #
    10358
    I think I got it, I used two database fields thought, one to put it on either the left or right, and I used the other to sort by.
    Thanks A lot,
    Mikael


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:05 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com