The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> JavaScript Development
|
database connection in a javascript
Discuss database connection in a javascript in the JavaScript Development forum on Dev Shed. database connection in a javascript JavaScript Development forum discussing JavaScript and DHTML, AJAX, and issues such as coding cross-browser JavaScript.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

July 19th, 2001, 05:59 AM
|
|
Contributing User
|
|
Join Date: Nov 2000
Posts: 109
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.
|

July 19th, 2001, 06:13 AM
|
 |
phpkid ~~~~~~ :o)
|
|
Join Date: Nov 2000
Location: NJ, USA
Posts: 2,534
 
Time spent in forums: 11 m 11 sec
Reputation Power: 15
|
|
|
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
|

July 19th, 2001, 06:22 AM
|
 |
.Net Developer
|
|
Join Date: Feb 2000
Location: London
Posts: 987
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
|
|
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..
}
}
?>
|

July 19th, 2001, 06:24 AM
|
|
Contributing User
|
|
Join Date: Nov 2000
Posts: 109
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.....?> "
|

July 19th, 2001, 06:27 AM
|
|
Contributing User
|
|
Join Date: Jun 2001
Location: Australia
Posts: 10
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..
|

July 19th, 2001, 06:35 AM
|
 |
.Net Developer
|
|
Join Date: Feb 2000
Location: London
Posts: 987
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
|
|
|
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...
|

July 19th, 2001, 08:30 AM
|
|
Contributing User
|
|
Join Date: Nov 2000
Posts: 109
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
|

July 19th, 2001, 08:40 AM
|
|
Contributing User
|
|
Join Date: Jun 2001
Location: Australia
Posts: 10
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Make the last bit of the script
}
}
?>
look like
}
}
}
?>
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|