Page 1 of 1

Do you know VB and PHP

Posted: Fri Aug 20, 2004 6:00 am
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

Posted: Fri Aug 20, 2004 8:11 am
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;

Posted: Fri Aug 20, 2004 10:35 am
by reh
Cheers mate,

Im gonna try that.

Thanks again

I Reh

Posted: Fri Aug 20, 2004 10:55 am
by lostboy
a slightly less complex example

Code: Select all

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