The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Fetch Row isn't grabbing all data in row
Hey there, basically I'm making something for my group and currently being a newbie in VB Classes & hooks.
Anyways, I made a query that would fetch every row in the table which it does because when I do this. PHP Code:
PHP Code:
Code:
<div class="blockbody"> <div class="blockrow"> {vb:raw firstname} </div> </div> Lets say I got Alpha Bravo Charlie and I use row to show them all but in the end only Charlie comes out but I want Alpha and Bravo too. What am I doing wrong? |
#2
|
|||
|
|||
You are overwriting the value of $ffname every time through the loop, so that in the end it is just set to the last name, as you saw. You could do this:
Code:
$result = $db->query_read("SELECT * FROM uksfroster"); while ($fname = $vbulletin->db->fetch_row($result)){ $ffname .= $fname[1] . '<br />'; } $templater->register('firstname', $ffname); Then you should see them all. You could also render a small template inside the loop to format the data for each user, so that you wouldn't need to have any html in the code. Another way to do it would be to use the vb4 loop template tags. WHat you'd do is build an array of the names, register that to the template, then put the loop tags in the template, like: Code:
$result = $db->query_read("SELECT * FROM uksfroster"); while ($fname = $vbulletin->db->fetch_row($result)){ $ffname[] = $fname[1]; } $templater->register('firstname', $ffname); Then in the template: Code:
<vb:each from="firstname" key="key" value="username"> Name: {vb:var username}<br /> </vb:each> |
Благодарность от: | ||
Alwandy |
#3
|
||||
|
||||
I remember i do this sometime ago in a mod.. What's the template where you are registering the variable?
you can try something like this: PHP Code:
--------------- Added [DATE]1372083944[/DATE] at [TIME]1372083944[/TIME] --------------- Kevin get it first yes that's what i've used, that's like the foreach function in php |
#4
|
|||
|
|||
Thanks for the help!
First way worked but didn't get 2nd way work, I'll look into it as 2nd way looks more easier to do and have since it'll be a roster. Resolved it, thanks! |
#5
|
|||
|
|||
I fixed the template code above - I had used 'ffname' instead of 'firstname' that you used to register the variable. Maybe that's why it didn't work for you.
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|