PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
JellyFish
DevNet Resident
Posts: 1361 Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA
Post
by JellyFish » Tue Jul 18, 2006 3:12 pm
I was wondering if this is possible?
Code: Select all
<a href="" onclick="<? mySqlConnectionFunc() ?>">Click to connect to the database</a>
Basicaly the function does everything it needs to too connect to my database. So can php be in events like these? If not then how could one make php more "real-time" with JavaScript maybe.
Thanks
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Tue Jul 18, 2006 3:14 pm
No, PHP only runs server side. Your using short tags again...
JellyFish
DevNet Resident
Posts: 1361 Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA
Post
by JellyFish » Tue Jul 18, 2006 3:21 pm
Okay. I understand. Sorry about the short tags(but I like them lol).
Can I use a JavaScript function that connects to the mySQL database using php? How would that look if so.
Luke
The Ninja Space Mod
Posts: 6424 Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA
Post
by Luke » Tue Jul 18, 2006 3:28 pm
if you like short tags, get used to people on these boards nagging at you about them... cuz it will never end.
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Tue Jul 18, 2006 3:31 pm
EasyGoing wrote: Okay. I understand. Sorry about the short tags(but I like them lol).
Can I use a JavaScript function that connects to the mySQL database using php? How would that look if so.
You may want to google for "AJAX Example | Sample".
The easiest way to do what you want though..
Code: Select all
<a href="?Action=Connect">Connect To Database</a>
Code: Select all
if (isset($_GET['Action'])) {
switch ($_GET) {
case 'Connect':
// connect to the database code
break;
}
}
JellyFish
DevNet Resident
Posts: 1361 Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA
Post
by JellyFish » Tue Jul 18, 2006 3:40 pm
if you like short tags, get used to people on these boards nagging at you about them... cuz it will never end.
Okay well staying on subject: my last question.
Burrito
Spockulator
Posts: 4715 Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah
Post
by Burrito » Tue Jul 18, 2006 3:53 pm
EasyGoing wrote: Okay well staying on subject: my last question.
...was answered. look at ajax if you dont' want to refresh the page.