Log in

View Full Version : Translating PHP to vB specifications


Anthony_RuBeZ
11-08-2009, 06:41 AM
Hi I've been using vB for a while now, while coding on the side I never got up the courage to ask for help on how to incorporate my style of coding with vB.
I learn best by visual representation and I was wondering if someone could a snippet of an example code that I provide, and rebuild it so that it fits the qualifications of vB.
Actually several little codes so that I can get the gist of how to do it myself, anyway here are the examples I need to be shown to translate into vB:



$query = "SELECT * FROM ".$prefix."users WHERE username='$loggedinname'";

$result = mysql_query($query);

$num = mysql_numrows($result);



//Loop out code

$i=0;

while ($i < 1) {



$newmessagenotify=@mysql_result($result,$i,"newmessagenotify");

$website=@mysql_result($result,$i,"website");



$website = stripslashes($website);


$i++;

}

I am trying to pick out codes that I know I need to use I need to make sure that I know how to write them correctly.

I realize my style of PHP is far from the effenciency that vB uses, which is why I am having so much trouble grasping it without visual representation.





$act=$_REQUEST["act"];
$action=$_REQUEST["action"];

if($act=="changesettings" and $action==""){ $action="";}







if($act=="changesettings" and $action=="1"){

<a href='?act=changesettings&action=1'><b>Profile Design</b></a>-
<a href='?act=changesettings&action=2'>Contact Info</a>-
<a href='?act=changesettings&action=3'>Personal Info</a>-
<a href='?act=changesettings&action=4'>Display Pictue</a>
<a href='?act=changesettings&action=5'>Friends</a>-
<a href='?act=changesettings&action=6'>Signature</a>
}
elseif($act=="changesettings" and $action=="2"){


<a href='?act=changesettings&action=1'>Profile Design</a>-
<a href='?act=changesettings&action=2'><b>Contact Info</b></a>-
<a href='?act=changesettings&action=3'>Personal Info</a>-
<a href='?act=changesettings&action=4'>Display Pictue</a>
<a href='?act=changesettings&action=5'>Friends</a>-
<a href='?act=changesettings&action=6'>Signature</a>

<form name='form1' method='post' action='accountpost.php'>
<p>Forum signature, a max character limit of 800 is in effect:<br />

<textarea name='signature' type='text' id='signature' cols='40' rows='3'>".$signature."</textarea><br>
<input name='act' type='hidden' id='act' value='changesettings'>
<input name='action' type='hidden' id='action' value='6'>
</p>

<p>

<input type='submit' name='Submit' value='Submit Details'>

</p>



</form>




}

elseif($act=="changesettings" and $action==""){



<a href='?act=changesettings&action=1'>Profile Design</a>-
<a href='?act=changesettings&action=2'>Contact Info</a>-
<a href='?act=changesettings&action=3'>Personal Info</a>-
<a href='?act=changesettings&action=4'>Display Pictue</a>
<a href='?act=changesettings&action=5'>Friends</a>-
<a href='?act=changesettings&action=6'>Signature</a>



}

Again I am trying to see how to translate the common things. Any suggestions that you can offer would be helpfull, I learn quickly and I like to try and teach myself but I also know when I am in above my head. So I am seeking help.

Lynne
11-08-2009, 04:14 PM
For queries, instead of:
$result = mysql_query($query);
$num = mysql_numrows($result);

Do this:
$result = $db->query_read($query);
$num = $db->num_rows($result);

I have found the best thing to do to learn this stuff is to take a look at the articles and also download a few modifications and see how the developer did things there.

Anthony_RuBeZ
11-10-2009, 12:48 AM
@Lynne - Your help is appreciated.

As I mentioned before, I work best with visual representation. If there are any coders out there experienced enough with working with vB, please PM if you can help this new comer get started. I can't do this properly if I don't have someone who can answer my questions and better understand the coding that goes with vBulletin. All help is appreciated.