vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   create link to a forum using "title_clean" as tag? (https://vborg.vbsupport.ru/showthread.php?t=179056)

jfk1 05-13-2008 07:34 AM

create link to a forum using "title_clean" as tag?
 
hi, i'm new to vbull, new to php.... :(
i am trying to define links to forums using title_clean as the identifier. (i believe this to be the only aplha unique field within table).
can anyone please point me in the right direction...
more info...
what i really want is a link to a forum which coresponds to a specific vbad page. the idea being that the vbad page is the "entry point" for visitor, which then has a link to forum which coresponds to that page. i have created tables in mysql which have identical values for "pageid" and "title_clean".
thanx in advance
jfk

--------------- Added [DATE]1210668489[/DATE] at [TIME]1210668489[/TIME] ---------------

here is an example of what i trying to achieve... tho not correct!... the link must be defined by a variable (to enable multiple entries into db)
$url/forums/forumdisplay.php?f=$foruminfo[title_clean=pageid] ... (title_clean and pageid have identical values in the db) or something like this :confused:

jfk1 05-18-2008 02:45 PM

i see a lot of views to my post, but no replies :( which probably means i'm not asking the correct question.
here is what i want to do. i have created a list of vb_adv pages. i have created a list of vbul forums. both pages and forums are from the same list. i want to make a link from the "page" to the corresponding "forum" (and vice-versa) using $variable.
i know which data i want to look up, but my problem is that i dont know the syntax.
i would like vbull to look at the page it is currently displaying, using whatever $variable it used to create that page eg. sql_table "adv_pages"- field "title", then take this piece of data and go look in sql_table "forum"- field "title_clean", compare the data and return a match which then displays the relative forum.

i guess i've made this a complicated question again :( .... sorry.

GameWizard 05-19-2008 12:57 PM

I think the best anyone can offer you is the following:

Use the following conditional in your forumdisplay template:
Code:

<if condition="$forumid == X">Your ad here</if>
Whereas X is the forum ID where you'd like the content to appear. If you'd like the same ad to appear on a number of boards, then use the following:

Code:

<if condition="in_array($forumid, array(X,Y,Z))">Your ad here</if>
Where as X Y Z refer to different forum ID's

More conditionals:

http://www.vbulletin.com/forum/showthread.php?t=200894

jfk1 10-22-2008 11:50 AM

hello again, i'm back! :)
i am sure there are a number of ppl here who can solve this problem for me, if i can just attract their attention for a few mins. i am half way through my second year of vbull license, and still dont have a working forum. this must be a record! :)
i am member of vbulletin (obviously), vbulletin.org, vbadvanced, and vbulletinsetup, and somehow i can't seem to ask the right question.... to get the right answer. i will try a different tack here, again! :)
essentially, i want to "query the sql database". how hard can that be, u might ask? all over the world, vbull scripts must be "querying the database" a million times a second! :) the whole script "survives" on "querying the database". this is precisely why i have opted for vbull, BECAUSE it uses mysql! i am getting a little despondent, at this stage. i should by this time, be an expert in PHP, MYSQL, and any number of programming langs! :)
ok, enough of waffle.
why does this not work?
Code:

$get_forumid = $db->query("SELECT forumid FROM " . TABLE_PREFIX . "forum WHERE title LIKE '$getpage'");
where $get_forumid is a new $var that i want to create, $getpage is a preset $var, which i want to submit (compare) to the db, and the result (returned value of $get_forumid) i want to use here:
Code:

<a href="http://mysite.com/forums/forumdisplay.php?f="$get_forumid">

Marco van Herwaarden 10-23-2008 08:26 AM

You probably want to use $db->query_first() instead of $db->query().

also make sure that $getpage is cleaned before using it in the query.

jfk1 10-25-2008 03:52 PM

Quote:

Originally Posted by Marco van Herwaarden (Post 1650975)
You probably want to use $db->query_first() instead of $db->query().

also make sure that $getpage is cleaned before using it in the query.

thanx for reply. i have tried query_first, doesnt appear to make a diference. could u possible give me an example of a "working" query..... or better still suggest a place in the script, where i could drop my query in.... i want to place a link in the navbar. thanx

--------------- Added [DATE]1224954048[/DATE] at [TIME]1224954048[/TIME] ---------------

here is an of what i have tried so far:
here's where i up to.... inserted query here (in vba_cmps_include_top.php)

Code:

// Figure out which page to grab
$pagevar = $vba_options['portal_pagevar'];

if (defined('VBA_PAGE'))
{
$getpage = VBA_PAGE;
}
else if(isset($_REQUEST[$pagevar]))
{
$getpage = $_REQUEST[$pagevar];
//jfk
$get_forumid = $db->query("SELECT forumid FROM " . TABLE_PREFIX . "forum WHERE title LIKE '$getpage'");

//end jfk

i figured this is precisely where the page name is set, therefore this is the value i need to submit to the forum table....
then i have inserted this link here (in navbar template)

Code:

<!-- nav buttons bar -->
<div class="tborder" style="padding:$stylevar[cellspacing]px; border-top-width:0px">
<table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
<tr align="center">
<!--######### jfk #############-->
<td class="vbmenu_control"><a href="$vboptions[homeurl]">$vboptions[hometitle]</a></td>
<td class="vbmenu_control"><a href="http://ntra.org.uk/forums/forumdisplay.php?f="$get_forumid">Forum</a></td>


<!--######### end jfk ######### -->

i dont get a "reported error" exactly, however when i look at sourcecode in compiled page i see "<a href="http://ntra.org.uk/forums/forumdisplay.php?f="Resource id #15">

Marco van Herwaarden 10-28-2008 12:36 PM

PHP Code:

$get_forumid $db->query_first("SELECT forumid FROM " TABLE_PREFIX "forum WHERE title LIKE '$getpage'"); 

This will return an array with the values of the selected data (assuming this will only return a single row!!). In your templates you will need to use $get_forumid[forumid].

jfk1 10-28-2008 03:31 PM

Quote:

Originally Posted by Marco van Herwaarden (Post 1654466)
PHP Code:

$get_forumid $db->query_first("SELECT forumid FROM " TABLE_PREFIX "forum WHERE title LIKE '$getpage'"); 

This will return an array with the values of the selected data (assuming this will only return a single row!!). In your templates you will need to use $get_forumid[forumid].

am i amissing a step somewhere... using $get_forumid[forumid] in the html doesnt show a value. do i need use fetch_array (to interpret db result) even though result will only be a single value... [forumid].... which is an integer.

Marco van Herwaarden 10-29-2008 08:40 AM

What is the value of $get_forumid after the database call?

jfk1 10-29-2008 03:54 PM

Quote:

Originally Posted by Marco van Herwaarden (Post 1655160)
What is the value of $get_forumid after the database call?

i assume you are asking, what "should" be the value of $get_forumid after the database call, as this exercise is solely intended to ascertain this value (in order that i can use this value in the href). with the present code that i am using i am getting a return value (result) like this... "/forumdisplay.php?f="Resource id #15"> ". the actual value is contained within the "Resource id #15", apparently, and must be "interpreted" in order to use it in php code (or html).
the "real" expected value would be as follows: if i submit (to db) a $pagetitle var which= "Stockport", for example... the query will find a forum which also has a "title" of Stockport, and this would have a "forumid" value of "395". (this is the actual entry in the db)


All times are GMT. The time now is 09:15 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01478 seconds
  • Memory Usage 1,759KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_code_printable
  • (2)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete