The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
SQL queries in vBulletin
Hi, I've looked at a lot of postings here and suspect I am being dense, but I am not quite understanding some things and need a little help.
I added a table (cNews) to my vBulletin db and wrote a php page to INSERT or SELECT but need some help integrating and then calling the variables ($num, $headline, $news) in throughout the site. I read Brad's 'vBulletin and mySQL' article (https://vborg.vbsupport.ru/showthread.php?t=75207) but still don't where and how to write SELECT, INSERT and UPDATE statements, Thanks very much Stephen Here's my code. Code:
$conn = mysql_connect($server, $userName, $password) or die(mysql_error()); mysql_select_db($db_name,$conn) or die(mysql_error()); $postback = $_POST["postback"]; if (empty($postback)) { //no new input so get last $sql="SELECT num, headline, news FROM cNews ORDER BY num DESC LIMIT 1"; $result = mysql_query($sql, $conn) or die(mysql_error()); } else { //insert new data then get last $headline = $_POST["headline"]; $news = $_POST["news"]; $sql = "INSERT INTO cNews VALUES (num,'".$headline."','".$news."')"; $result = mysql_query($sql, $conn) or die(mysql_error()); $sql="SELECT num, headline, news FROM cNews ORDER BY num DESC LIMIT 1"; $result = mysql_query($sql, $conn) or die(mysql_error()); } while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $num = $row['num']; $headline = $row['headline']; $news = $row['news']; } |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|