Nu ved jeg godt dette er i mySQL. og ikke MYSQLI. Men skal jeg nok få ændret.
Vil bare i første omgang have det til at fungere. Så skal jeg nok ændre til mysqli.
---
Men jeg har et problem med det her, det vil ikke poste til rumID.
Den den loader indholdet med tabs. via Ajax.
Nogen forslag ?.
- <?php
- session_start();
- include("config.php");
- ?>
- <html>
- <head>
- <title>Chat</title>
- <script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
- <script src="js/jquery.hashchange.min.js" type="text/javascript"></script>
- <script src="js/jquery.easytabs.min.js" type="text/javascript"></script>
-
- <style>
- /* Example Styles for Demo */
- .etabs { margin: 0; padding: 0; }
- .tab { display: inline-block; zoom:1; *display:inline; background: #eee; border: solid 1px #999; border-bottom: none; -moz-border-radius: 4px 4px 0 0; -webkit-border-radius: 4px 4px 0 0; }
- .tab a { font-size: 14px; line-height: 2em; display: block; padding: 0 10px; outline: none; }
- .tab a:hover { text-decoration: underline; }
- .tab.active { background: #fff; padding-top: 6px; position: relative; top: 1px; border-color: #666; }
- .tab a.active { font-weight: bold; }
- .tab-container .panel-container { background: #fff; border: solid #666 1px; padding: 10px; -moz-border-radius: 0 4px 4px 4px; -webkit-border-radius: 0 4px 4px 4px; }
- .panel-container { margin-bottom: 10px; }
- </style>
-
- <script type="text/javascript">
- $(document).ready( function() {
- $('#tab-container').easytabs();
- });
- </script>
- </head>
- <body>
-
- <div id="tab-container" class='tab-container'>
- <ul class='etabs'>
- <?php
- $sql = mysql_query("SELECT * FROM `a_chatrum` order by `rumID` ASC");
- while($vistraad = mysql_fetch_array($sql)) {
- echo ("<li class='tab'><a href=\"#". $vistraad['rumID'] ."\">". $vistraad['rumnavn'] ."</a></li>");
- }
- ?>
- </ul>
- <div class='panel-container'>
- <!-- START-->
- <?php
- $sql = mysql_query("SELECT * FROM `a_chatrum` order by `rumID` ASC");
- while($vistraad = mysql_fetch_array($sql)) {
- echo ("<div id='". $vistraad['rumID'] ."'><h2>Max chattere i dette rum: ". $vistraad['maxchattere'] ."</h2><hr />");
- $msg = mysql_query("SELECT * FROM `a_chatmsg` WHERE `rum` = '". $vistraad['rumID'] ."'");
- while($vismsg = mysql_fetch_array($msg)) {
- echo ("<b>". $vismsg['afsender'] ." skriver i rum ". $vismsg['rum'] .":</b> ". $vismsg['besked'] ."<br />");
- }
- echo ("</div>");
- }
- ?>
- <hr /><br />
- <?
- $afsender = htmlspecialchars($_POST['afsender']);
- $besked = htmlspecialchars($_POST['besked']);
- if(isset($_POST['msg']))
- {
- mysql_query("INSERT INTO `a_chatmsg` (afsender, besked, rum) VALUES ('". $afsender ."','". $besked ."','". $_GET['rumID'] ."')");
- }
- ?>
- <form action="" method="POST">
- <b>Dit navn:</b><br />
- <input type="text" name="afsender" id="loginfelt_input" AUTOCOMPLETE="Off">
- <br />
- <b>Din kommentar:</b><br />
- <input type="text" name="besked" id="loginfelt_input" AUTOCOMPLETE="Off">
- <br />
- <input type="submit" name="msg" id="loginfelt_login" value="Sendj">
- </form>
-
-
- <!-- SLUT -->
- </div>
- </div>
-
- </body>
- </html>
Hvor meget skal du have for at løse dette problem?.Har forsøgt med session i rumID. for at fremkalde det. Men lykkes heller ikke.
Har rumID (1, 2, 45)
For at forsøge iblandt disse rum.
Men når jeg vil poste, kan jeg se den skriver #45, selvom det så er i rum 1.
Den vil ikke poste andre steder.
- <?php
- session_start();
- include("config.php");
- ?>
- <html>
- <head>
- <title>Chat</title>
- <script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
- <script src="js/jquery.hashchange.min.js" type="text/javascript"></script>
- <script src="js/jquery.easytabs.min.js" type="text/javascript"></script>
-
- <style>
- /* Example Styles for Demo */
- .etabs { margin: 0; padding: 0; }
- .tab { display: inline-block; zoom:1; *display:inline; background: #eee; border: solid 1px #999; border-bottom: none; -moz-border-radius: 4px 4px 0 0; -webkit-border-radius: 4px 4px 0 0; }
- .tab a { font-size: 14px; line-height: 2em; display: block; padding: 0 10px; outline: none; }
- .tab a:hover { text-decoration: underline; }
- .tab.active { background: #fff; padding-top: 6px; position: relative; top: 1px; border-color: #666; }
- .tab a.active { font-weight: bold; }
- .tab-container .panel-container { background: #fff; border: solid #666 1px; padding: 10px; -moz-border-radius: 0 4px 4px 4px; -webkit-border-radius: 0 4px 4px 4px; }
- .panel-container { margin-bottom: 10px; }
- </style>
-
- <script type="text/javascript">
- $(document).ready( function() {
- $('#tab-container').easytabs();
- });
- </script>
- </head>
- <body>
-
- <div id="tab-container" class='tab-container'>
- <ul class='etabs'>
- <?php
- $sql = mysql_query("SELECT * FROM `a_chatrum` order by `rumID` ASC");
- while($vistraad = mysql_fetch_array($sql)) {
- echo ("<li class='tab'><a href=\"#". $vistraad['rumID'] ."\">". $vistraad['rumnavn'] ."</a></li>");
- }
- ?>
- </ul>
- <div class='panel-container'>
- <!-- START-->
-
- <?php
- $sql = mysql_query("SELECT * FROM `a_chatrum`");
- while($visrum = mysql_fetch_array($sql)) {
-
- echo ("<div id='". $visrum['rumID'] ."'>");
-
- $_SESSION['rumID'] = "". $visrum['rumID'] ."";
-
-
- echo ("<h2>Max chattere i dette rum: ". $vistraad['maxchattere'] ." (".$_SESSION['rumID'].")</h2><hr />");
- $msg = mysql_query("SELECT * FROM `a_chatmsg` WHERE `rum` = '". $vistraad['rumID'] ."'");
- while($vismsg = mysql_fetch_array($msg)) {
-
- echo ("<b>". $vismsg['afsender'] ." skriver i rum ". $vismsg['rum'] .":</b> ". $vismsg['besked'] ."<br />");
- }
- echo ("</div>");
- }
- $afsender = htmlspecialchars($_POST['afsender']);
- $besked = htmlspecialchars($_POST['besked']);
- if(isset($_POST['msg']))
- {
- mysql_query("INSERT INTO `a_chatmsg` (afsender, besked, rum) VALUES ('". $afsender ."','". $besked ."','".$_SESSION['rumID']."')");
- }
- ?>
-
- <form action="#<? echo "". $_SESSION['rumID'] .""; ?>" method="POST">
- <b>Dit navn:</b><br />
- <input type="text" name="afsender" id="loginfelt_input" AUTOCOMPLETE="Off">
- <br />
- <b>Din kommentar:</b><br />
- <input type="text" name="besked" id="loginfelt_input" AUTOCOMPLETE="Off">
- <br />
- <input type="submit" name="msg" id="loginfelt_login" value="Send">
- <input type="text" value="<? echo "". $_SESSION['rumID'] .""; ?>" AUTOCOMPLETE="Off">
- </form>
-
-
-
-
-
- <!-- SLUT -->
- </div>
- </div>
-
- </body>
- </html>
Indlæg senest redigeret d. 23.02.2013 18:45 af Bruger #17475