Solved

How can I query mysql database for javascript tabview?

Posted on 2010-08-27
6
385 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

751 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