JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 19th, 2001, 05:59 AM
thuynh7 thuynh7 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Posts: 109 thuynh7 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 42 m 43 sec
Reputation Power: 13
database connection in a javascript

I have the following link that belongs to a javascript:-

<A target="_new" href="http://www.othersite.com" onClick="return frameBranding('http://www.othersite.com', 'page.htm', 'rows');">

however I want to insert a link from a mysql database instead of http://www.othersite.com, with the following:-

<?php

$db = mysql_connect("localhost", "username", "password");
mysql_select_db("ISS",$db);

$result = mysql_query("SELECT link FROM table WHERE id = '$id'",$db);

do {

if ($myrow[0] != "") {

echo "$myrow[0]";

}

} while ($myrow = mysql_fetch_array($result));

?>


what's the best way to go about this.

Reply With Quote
  #2  
Old July 19th, 2001, 06:13 AM
jdk's Avatar
jdk jdk is offline
phpkid ~~~~~~ :o)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Nov 2000
Location: NJ, USA
Posts: 2,534 jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 11 m 11 sec
Reputation Power: 15
Send a message via Yahoo to jdk
cant get u.

hey friend,

can u explain again what u want to accomplish ?
i dont understand .

do u want to change the parameter passed to framebranding function ?? [ i can guess only that but i m not sure ]

so plz explain.

jd
__________________
_____________________________
d.k.jariwala (JD)
~ simple thought, simple act ~
I blog @ http://jdk.phpkid.org

Reply With Quote
  #3  
Old July 19th, 2001, 06:22 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan
I'm not sure what you are trying to do here..but i assume that you are trying to get the following...


PHP Code:
<?php 

$db 
mysql_connect("localhost""username""password"); 
mysql_select_db("ISS",$db); 

$result mysql_query("SELECT link FROM table WHERE id = '$id'",$db); 
 
  if(
mysql_num_rows($result)>0){
  
// record is there in db

 
while ($myrow mysql_fetch_array($result)){
   
    if (!empty(
$myrow["link"])) { 
 
echo 
"<A target=\"_new\" href=\"".$myrow["link"] ."\" onClick=\"return frameBranding('".$myrow["link"]."', 'page.htm', 'rows');\">\n";
//print that java script here..
 
   

 }
?>
__________________
SR -
webshiju.com
www.lizratechnologies.com

"The fear of the LORD is the beginning of knowledge..."

Reply With Quote
  #4  
Old July 19th, 2001, 06:24 AM
thuynh7 thuynh7 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Posts: 109 thuynh7 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 42 m 43 sec
Reputation Power: 13
basically the javacript, is a frame branding script, where a user clicks on a link and the link takes them to the site they want to go to but the site is displayed in a frameset, like what lycos does and other portals.

so the user click on a hyperlink as normal:-

<A target="_new" href="http://www.othersite.com" onClick="return frameBranding('http://www.othersite.com', 'page.htm', 'rows');">

However the link (or the site that it's going to) is constantly changing and is dependant to the page that they're on.

so that's why I need to connect it to a database. So intead of
"href="http://www.othersite.com" I want to it to be something like:-

href="<?php ......get link from mysql database.....?> "

Reply With Quote
  #5  
Old July 19th, 2001, 06:27 AM
nih58 nih58 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Australia
Posts: 10 nih58 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have a script that does exactly what you want on my site..
With a little customisation I'm sure it will do what you want..
__________________
-=-=-=-=-=-=-=-=-=-=-=-=-
PHP Scripts n Stuff
http://www.bcnstech.net/
-=-=-=-=-=-=-=-=-=-=-=-=-

Reply With Quote
  #6  
Old July 19th, 2001, 06:35 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan

so that's why I need to connect it to a database. So intead of
"href="http://www.othersite.com" I want to it to be something like:-

href="<?php ......get link from mysql database.....?> "


i think you may try what i have written earlier...

Reply With Quote
  #7  
Old July 19th, 2001, 08:30 AM
thuynh7 thuynh7 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Posts: 109 thuynh7 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 42 m 43 sec
Reputation Power: 13
are you sure that's right Shiju

I'm getting parse errors

Reply With Quote
  #8  
Old July 19th, 2001, 08:40 AM
nih58 nih58 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Australia
Posts: 10 nih58 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Make the last bit of the script
}
}
?>
look like
}
}
}
?>

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > database connection in a javascript

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap