Do you know VB and PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
reh
Forum Newbie
Posts: 9
Joined: Tue Aug 17, 2004 10:35 am

Do you know VB and PHP

Post by reh »

Hello there,

i have a question to any programmers who are knowlegable in VBscript and PHP.

Last year while i was at university i was doing a project in VB script for an ASP site, and now im am doin a similar thing but in PHP. I remember using a peice of code in VB script that was vey handy, but i do not know how to do the same in PHP.

It was basically a link that would enable the posting of information for use with variables. It would allow me to display a page with the content pulled from a database depending on a information posted in the address bar.

the code in VB script is:

Code: Select all

<TD><A HREF="StaffDetails.asp?ID=<%=objRs("Staff_ID")%>">More...</A>
Please let me know if anyone needs me to explain more on what i am trying to do above or provide more of the code that i have posted.

Cheers to anyone taking the time to read this post.

I Reh
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

There are a bunch of ways to do this. In your example you are using an object call. So here is PHP's version:

PHP Class:

Code: Select all

<?php

class DevForumExample{ 
    
  var $id; 
  var $name; 
    
  function DevForumExample($x){ 
    
      $qry = "SELECT id, name FROM my_table where id=$x"; 
      $result = mysql_query($qry); 
    
        while($row = mysql_fetch_array($result)) 
        { 
          $this->id = $row["id"]; 
          $this->name = $row["name"]; 
        }//END WHILE 
    
  }//END FUNCTION CALL 
    
  function getId(){ return $this->id; } 
  function getName(){ return $this->name; } 
    
  function setId($x){ $this->id=$x; } 
  function setName($x){ $this->name=$x; } 
    
   
} 
?>
Linke to HREF:

Code: Select all

<?php
    $ObjClass= new DevForumExample($someID_to_search_by); 
    $id=&$ObjClass->getId(); 
?>

Code: Select all

&lt;TD&gt;&lt;A HREF="StaffDetails.php?ID=&lt;?php echo $id;?&gt;"&gt;More...&lt;/A&gt;
reh
Forum Newbie
Posts: 9
Joined: Tue Aug 17, 2004 10:35 am

Post by reh »

Cheers mate,

Im gonna try that.

Thanks again

I Reh
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

a slightly less complex example

Code: Select all

<td><a href="StaffDetails.php?ID=<?=$rs['id']?>">More...</a>
Post Reply