Solved

How can I query mysql database for javascript tabview?

Posted on 2010-08-27
6
365 Views
Last Modified: 2013-12-13
attached please my source for javascript tabview on php.
distribution.txt
0
Comment
Question by:beckyng
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:jijeesh
Comment Utility
I dont think you can do it from javascript, instead you have to use server side scripting for accessing database.  
0
 
LVL 30

Expert Comment

by:Marco Gasi
Comment Utility
I've downloaded your file but it is a binary file. Please attach a plain text file to allow me take a look.
Bye
0
 

Author Comment

by:beckyng
Comment Utility
Pls rename the distribution.txt to distribution.rar

Thanks
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 30

Accepted Solution

by:
Marco Gasi earned 125 total points
Comment Utility
If you wish to know how insert in your tab mysql results, look at code snippet below. Keep in mind that in order to view different result in each tab you have only to run different quesry with different names (for tab1 you'll use $sql1 = "SELECT STATEMENT"; $result1 = mysql_query($sql1); and so on.

Hope this helps.
Best regards
<?php
$sql = "SELECT mydata FROM mytable";
$result = mysql_query($sql);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

<title>Tab-View Sample</title>

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords"    content="" />

<link rel="stylesheet" type="text/css" href="tab-view.css" />

</head>
<body>

<?php $id = isset($_GET['id']) ? $_GET['id'] : 1; ?>

<div class="TabView" id="TabView">


<!-- ***** Tabs ************************************************************ -->

<div class="Tabs" style="width: 452px;">
  <a <?=($id == 1) ? 'class="Current"' : 'href="sample.php?id=1"';?>>Tab 1</a>
  <a <?=($id == 2) ? 'class="Current"' : 'href="sample.php?id=2"';?>>Tab 2</a>
  <a <?=($id == 3) ? 'class="Current"' : 'href="sample.php?id=3"';?>>Tab 3</a>
</div>


<!-- ***** Pages *********************************************************** -->

<div class="Pages" style="width: 450px; height: 300px;">
  <div class="Page" style="display: <?=($id == 1) ? 'block' : 'none';?>">
      <div class="Pad">
        <?php
            while ($row = mysql_fetch_array($result)){
                echo $row[0]."<br />";
            }
        ?>
      </div>
  </div>
  <div class="Page" style="display: <?=($id == 2) ? 'block' : 'none';?>"><div class="Pad">Page 2</div></div>
  <div class="Page" style="display: <?=($id == 3) ? 'block' : 'none';?>"><div class="Pad">Page 3</div></div>
</div>

</div>

<script type="text/javascript" src="tab-view.js"></script>
<script type="text/javascript">
tabview_initialize('TabView');
</script>

</body>
</html>

Open in new window

0
 

Author Closing Comment

by:beckyng
Comment Utility
Very useful
0
 
LVL 30

Expert Comment

by:Marco Gasi
Comment Utility
Sorry, but what you wished to receive to assign an A instead a B? You question is only one row: I couldn't implement a betetr solution with informations you provided... Anyway, thanks for points, I'm happy to helped you.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now