View Full Version : How are array variables show to post?
Sinan COSKUN
01-11-2012, 01:22 PM
Hi everyone,
My table,
userid ------ threadid ---------- value
1----------------- 2 -------------- deger1
1----------------- 2 -------------- deger2
2----------------- 3 -------------- deger3
When I write “{vb:raw post.degerler}” at the postbit_legacy template, I want to see “deger1” and “deger2” (deger1 - deger2) the same time in the post, but I can see only “deger 2”. I’d ask you to help me about this situation.
Thank you
Best regards
Sinan Coşkun
I thikn we need to see the code where you set $post['degerler'].
Sinan COSKUN
01-11-2012, 02:02 PM
I forgot, sorry :)
$vericek= $db->query_read("SELECT value FROM ".TABLE_PREFIX."tablo WHERE threadid=2");
while ($veri=$db->fetch_array($vericek)){
$post[degerler]= $veri['value'];
}
You need to do something like this:
$vericek= $db->query_read("SELECT value FROM ".TABLE_PREFIX."tablo WHERE threadid=2");
while ($veri=$db->fetch_array($vericek)){
$degerler[] = $veri['value'];
}
$post[degerler]= implode(' - ', $degerler);
Sinan COSKUN
01-11-2012, 02:35 PM
Ok, but it was required separately as “deger1” and “deger2”, not “deger1-deger2”. Because i want to do hmm..
Examp:
<a href="......./deger1">deger1</a> - <a href="......deger2">deger2</a>
and thanks ;)
OK, you could do this:
$vericek= $db->query_read("SELECT value FROM ".TABLE_PREFIX."tablo WHERE threadid=2");
while ($veri=$db->fetch_array($vericek)){
$degerler[] = '<a href="http://.....' . $veri['value'] . '">' . $veri['value'] . '</a>';
}
$post[degerler]= implode(' - ', $degerler);
or if you want to keep your html separate from the code you could make a small template for the link and render it. There is a vb:each tag you can use in a template to loop through an array, but I don't know how you'd to the ' - ' between them.
Edit:...unless there can only be one or two values? Then you could put them in separate values (like $post['degerler1'] and $post['degerler2']), then you could use a <vb:if... to check if the second one exists.
Sinan COSKUN
01-11-2012, 02:51 PM
Yeees, that's :) thanks... very thanks
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.