Jump to content

alphamoment

Members
  • Posts

    31
  • Joined

  • Last visited

alphamoment's Achievements

Member

Member (2/5)

1

Reputation

  1. Thank you for the reply. The 0's 1's 2's were just examples. I appreciate the responses as they have helped me greatly!
  2. I'm using this current PHP Code in my Index.php; <?php $page = $_GET['page']; if (!isset($page)) { include('home.php'); } if ($page == "Home") { include('home.php'); } if ($page == "0101") { include('0101.php'); } if ($page == "0202") { include('0202.php'); } ?> Then I'm using this for my Navigation link; <li><a href="?page=0101">Members</a></li> Which displays as index.php?page=0101 But on those pages I want to go into another page off of them, for example; index.php?page=0101&subpage=0102 index.php?page=0202&subpage=0201 How can I achieve this?
  3. Hi I'm using PHP for my Navigation Menu, My navbar is in a file named "home.php" looks like this: <ul class="nav navbar-nav navbar-right"> <li><a href="?page=home">Home</a></li> <li><a href="?page=about">About</a></li> <li><a href="?page=services">Services</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="?page=service2">Service 2</a></li> </ul> </ul> Then in my index.php: $page = $_GET['page']; if (!isset($page)) { include('home.php'); } if ($page == "home") { include('home.php'); } if ($page == "about") { include('about.php'); } if ($page == "services") { include('services.php'); } if ($page == "service2") { include('service2.php'); } It all works how I want it to except for one thing; I'd like to add; <li class="active"> To the page that is currently being viewed. How can I do this? Thank you in advance.
  4. Got it! Barand MVP. I really appreciate your help, Thank you once again.
  5. That's a lot cleaner thanks! If I wanted to limit the results to 50 rows being displayed how can I come about that? (Sorry for all the questions)
  6. Haha, thanks! Works perfect, Thank you so much Barand. One last question; for the echo I've used $row['COUNT(t1.ID)'] How can I get it to ORDER BY the highest count descending ORDER BY t1.COUNT(t1.ID) DESC This doesn't seem to do the trick! Edit: I got it working using; ORDER BY COUNT(*) DESC Thank you!
  7. Hello Barand, Thanks for the quick reply. I've tried your Query and the results displayed only 1 row ID COUNT 4017 85 Not quite sure how it got 85 when there is only 3 listings for ID 4017. Hmmmm
  8. Hello. I'm trying to get this piece of code finished but it's not going my way, if anyone could help me out that would be great. Here whats I'm trying to do: Table1 Table2 ---------------- --------------------------------- ID | | PlayerID | PlayerName | ---------------- -------------------------------- 1393 | | 1393 | Player1 | 2097 | | 2097 | Player2 | 3888 | | 3888 | Player3 | 3888 | | 4017 | Player4 | 3888 | --------------------------------- 4017 | 4017 | 4017 | ---------------- I Want to Count the entries in Table1 (3888 has 3 entries so it will display like "3888: 3") Then I want to join Table1 and Table2 using the ID so I can get the players name (3888=Player3 so it would display like Player3 : 3) Here's the code I'm using: <?php //connect to db $query = "SELECT * FROM Table1 INNER JOIN Table2 WHERE Table1.PlayerID = Table2.ID"; $query2 = "SELECT ID, SUM(ID=0) AS n0, SUM(ID=1) AS n1, COUNT(*) AS total FROM Table1 GROUP BY ID"; $result = mysql_query($query) or die($query."<br/><br/>".mysql_error()); $result2 = mysql_query($query2) or die($query2."<br/><br/>".mysql_error()); echo "<table border='1'> <tr> <th>PlayerName</th> <th>Entries</th> </tr>"; while($row2 = mysql_fetch_array($result2)) while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ID'] . "</td>"; echo "<td>" . $row['PlayerName'] . "</td>"; echo "<td>" . $row2['Total'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($link); ?> If I use $query on its own it joins perfectly, If I use $query2 on its own, it displays the results exactly how I want them listed but with the ID instead of the PlayerName, I tried putting them both together as shown above but I can't get them to work together. What I want my end Result to be Player1 1 Player2 1 Player3 3 Player4 3 How it keeps coming out; 1393 1 2097 1 3888 3 4017 3 Can anyone see where I'm going wrong? Thank you!!
  9. I'm running Phpbb3 Version: 3.0.12. I'm trying to get all the topics from my "NEWS" Category posted on to the index.php of my Website. With the code I'm using I can get this working perfectly fine, in it's own .php file. But as soon as I add it into my index.php all of the PHP code below the forum code doesn't show. For example my layout is > Header > Login Function > Blank Space in the middle (Using this for the forum code) > 2 other PHP Scripts. As soon as I apply the forum code the 2 other PHP scripts and their markups completely dissapear from my website. The only way I can prevent this is by putting the Forum code at the bottom of my index.php but then it displays on the far left and I want it in the middle. I have tried putting it in it's own file and doing <?php include_once('external_page.php'); ?> but the same problem persists. Here is my forum code; <?php /* * home.php * Description: example file for displaying latest posts and topics * by battye (for phpBB.com MOD Team) * September 29, 2009 */ define('IN_PHPBB', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forum/'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); include($phpbb_root_path . 'includes/bbcode.php'); include($phpbb_root_path . 'includes/functions_display.php'); // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup('viewforum'); $search_limit = 7; $posts_ary = array( 'SELECT' => 'p.*, t.*, u.username, u.user_colour', 'FROM' => array( POSTS_TABLE => 'p', ), 'LEFT_JOIN' => array( array( 'FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = p.poster_id' ), array( 'FROM' => array(TOPICS_TABLE => 't'), 'ON' => 'p.topic_id = t.topic_id' ), ), 'WHERE' => ' t.topic_status <> ' . ITEM_MOVED . ' AND t.topic_approved = 1', 'ORDER_BY' => 'p.post_id DESC', ); $posts = $db->sql_build_query('SELECT', $posts_ary); $posts_result = $db->sql_query_limit($posts, $search_limit); while( $posts_row = $db->sql_fetchrow($posts_result) ) { $topic_title = $posts_row['topic_title']; $post_author = get_username_string('full', $posts_row['poster_id'], $posts_row['username'], $posts_row['user_colour']); $post_date = $user->format_date($posts_row['post_time']); $post_link = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=" . $posts_row['post_id'] . "#p" . $posts_row['post_id']); $post_text = nl2br($posts_row['post_text']); $bbcode = new bbcode(base64_encode($bbcode_bitfield)); $bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']); $post_text = smiley_text($post_text); $template->assign_block_vars('announcements', array( 'TOPIC_TITLE' => censor_text($topic_title), 'POST_AUTHOR' => $post_author, 'POST_DATE' => $post_date, 'POST_LINK' => $post_link, 'POST_TEXT' => censor_text($post_text), )); } page_header('External page'); $template->set_filenames(array( 'body' => 'external_body.html' )); page_footer(); ?> Thanks in advance.
  10. Thank you for the help Mac. Saved me a bunch of time.
  11. I was showing a snippet of the Login authentication process I'm using in hopes someone could help me add to that first created session the users email too. I have tried this; <?php $query= mysql_query("SELECT * FROM `users` WHERE `name` = '".$_SESSION['user']."' ")or die(mysql_error()); $account = mysql_fetch_array($query); $num = mysql_numrows($query); ?> /// <?php echo $account['email']; ?> But the results display empty :s
  12. In my script, users login with their Username & Password. However, I'd like to be able to echo the email address used on their account. I've tried adding the email to the session I'm not having much luck... Here's a piece of the login code(untouched); $username = $_POST['name']; $passwd = $_POST['passwd']; $query = "SELECT name,passwd FROM users WHERE CONCAT('0x', hex(passwd)) = '{$salt}'"; $result = mysql_query($query); $login_ok = false; if(mysql_num_rows($result) > 0) { $login_ok = true; } if($login_ok) { $row = mysql_fetch_array($result, MYSQL_NUM); $_SESSION['user'] = $row; I've also tried messing around with this piece below in a few different ways but still nothing. <?php echo htmlentities($_SESSION['user']['email'], ENT_QUOTES, 'UTF-8'); ?> Any help is greatly appreciated..
  13. Perhaps try creating the qty as a variable. <?php session_start(); $QTY=$_POST['qty']; $conn = mysqli_connect("localhost","root","","skel"); $sql = "INSERT INTO cart VALUES (" . session_id() . ", "NOW()", "$QTY; Something like this.
  14. Not sure if I'm reading this properly given that its 4am lol. However I'll try and shed a little light on this and hopefully can help you out somewhat. From reading I understand you want it to echo the successful registration but also redirect onto another page? If so, have you tried using; $result = mysql_query($query); if($result){ echo '<script>alert("New user has been created!");</script>'; header("Location: xxxxx.php"); die("Redirecting to: xxxxx.php"); } else { print("Something went wrong with your registration."); ?> As for logging a member in.after registering, try creating a session after the script succeeds. $result = mysql_query($query); if($result){ $_SESSION['loggedin'] = $result; // echo // redirect ?> //Then on the top of the form you want them to be logged in with that session <?php if(isset($_SESSION['loggedin'])){ //hi im logged in }else{ // hi im not logged in ?> There might be a few mistakes here. But I hope it helps somewhat! I'm PHP novice =)
  15. Hello. I' have a Table in MySQL That stores data (name/email/time) of when a person last run X script. I'm trying to pull that information for each user unique to their account to display so they know that they've already ran that script today How it works. Run script > Create's Row storing the data > MySQL Events deletes row after 24 hours. My code to display notification if they have already ran it; $sql = 'SELECT a.name, a.time FROM timecheck a, users b WHERE a.name = b.name'; mysql_select_db('My_DB'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not get data: ' . mysql_error()); } while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { echo "Account: {$row['name']} <br> ". "Last Time Run: {$row['time']} GMT -1<br> "; } echo "It seems you have done this already today!"; ?> Now my problem is. It's displaying every row to every user. I want it to only show the user their row... What I've tried. Creating a session variable "$sessionID" $sql = 'SELECT a.name, a.time FROM timecheck a, users b WHERE a.name = b.name AND a.name=$sessionID"'; But I'm not getting any lucky. All help is appreciated, thank you in advance.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.