Solved

How can I query mysql database for javascript tabview?

Posted on 2010-08-27
6
388 Views
Last Modified: 2013-12-13
attached please my source for javascript tabview on php.
distribution.txt
0
Comment
Question by:beckyng
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

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

Expert Comment

by:Marco Gasi
ID: 33554192
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
ID: 33564729
Pls rename the distribution.txt to distribution.rar

Thanks
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 31

Accepted Solution

by:
Marco Gasi earned 125 total points
ID: 33564822
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
ID: 33587921
Very useful
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 33587973
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
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 count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

622 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