Solved

How can I query mysql database for javascript tabview?

Posted on 2010-08-27
6
371 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

895 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

12 Experts available now in Live!

Get 1:1 Help Now