Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Alright, something in PHP with asps case and urls..?

  1. #1
    Join Date
    Jan 2007
    Location
    Sweden
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Alright, something in PHP with asps case and urls..?

    Id wanna know if there's sumthing in php that matchees asps
    Code:
    <&#37;If Case "Ok" %>
    <!-- Just a remark, the url would be like file.php?id=0 or 1 -->
    TEXT HERE
    <% If Case Else %>
    OTHER TEXT HERE
    so i dont really remember the whole thing, long time since i last used ASP..

    so is the thing i wrote possible? Coz i was thinking like putting some pictures beside eachother. then when u click one, the "text" loads underneath or sumthing, and when u click the othher one, the new text loads.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I don't know any ASP, but there's not nearly enough information in that code for it to actually work. Thus, I've no idea what you're trying to do.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2007
    Location
    Sweden
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ill try to explain what i wanna do..

    Im fixing my clan website and I was thinking of putting a picture of all the members (until we get bigger i suppose) and when u click a certain picture, its gonna load a page, preferably team.php?id=0 etc. that "page" will have information about the member with id 0. I've already set up the database with the fields that's required and I thought that this would be a good idea. sorry for such messy text, aint a good writer

    edit: and about the ASP code, i dont really remember the code, just those parts..

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Well, you'd use the ID to construct the query:
    Code:
    <?php
      if(!(
        is_numerical(@$_GET['id']) &&
        $row = mysql_fetch_array(mysql_query(sprintf('select * from members where id=&#37;d limit 1', $_GET['id'])))
      ))
        die('Error, bad ID!');
      else {
    ?>
    <table>
      <thead>
        <tr>
          <th>ID</th>
          <th>Name</th>
          <th>Email</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td><?php print $row['id']; ?></td>
          <td><?php print $row['name']; ?></td>
          <td><?php print $row['email']; ?></td>
        </tr>
      </tbody>
    </table>
    <?php } ?>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Jan 2007
    Location
    Sweden
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i dont really get how i connect this to a picture. since its using GET, i need a submit right? ;O

  6. #6
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Just place the code that Twey posted in a new php file (make sure it has the extension .php), then just link the picture to that file like so:

    Code:
    <a href="page.php?id=2"><img src=".....
    Change the two to the member id you want to view (or link to).
    Hope this helps.

    //EDIT: If you were getting the list of pictures dynamically, simply replace the part in red (in the above code) with the variable for that row's "id".
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  7. #7
    Join Date
    Jan 2007
    Location
    Sweden
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    is there no easier way? hehe.

    i found my asp file, feel free to check it out, it'd be like that only with the cases involving the pictures.. ah, check it out, wont help if i keep on babblin ;p

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    The PHP equivalent is:
    Code:
    <?php
      switch($_GET['page']) {
      case 'news':
    ?>
    <br /><?php include('news.inc'); ?>
    <?php break; case 'bios': ?>
    <br />This is the bios page.
    <?php break; case 'guestbook': ?>
    There will be a guestbook here shortly.
    <?php break; case 'links': ?>
    LINKS
    <?php break; case default: ?>
    <br />This is the homepage.
    <?php } ?>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Jan 2007
    Location
    Sweden
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey View Post
    The PHP equivalent is:
    Code:
    <?php
      switch($_GET['page']) {
      case 'news':
    ?>
    <br /><?php include('news.inc'); ?>
    <?php break; case 'bios': ?>
    <br />This is the bios page.
    <?php break; case 'guestbook': ?>
    There will be a guestbook here shortly.
    <?php break; case 'links': ?>
    LINKS
    <?php break; case default: ?>
    <br />This is the homepage.
    <?php } ?>
    thanks! ima try it out, just one last question i guess, how do i get the script to work with the pictures? do i use Thetestingsites advice?

  10. #10
    Join Date
    Apr 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Simply put all the images in one static directory(www.example.com/pics/). Then, on the page where you display the member's picture/info, use something like:
    Code:
    <?php
    function fix_results($s){
    return htmlentities(stripslashes($s));
    }
    $getMember=mysql_query("SELECT * FROM members WHERE id = '".$_GET['id']."'") or die(mysql_error());
    $showMember=mysql_fetch_assoc($getMember);
    echo '<img src="/pics/'.fix_results($showMember['image']).'" />';
    ?>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •