Jump to content

Petite-Dragon

New Members
  • Posts

    8
  • Joined

  • Last visited

Petite-Dragon's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. i have found some tutorials in the internet but it did not suit for my code <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form id="form1" name="form1" method="post" action="add_new_topic.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3" bgcolor="#E6E6E6"><strong>Create New Topic</strong> </td> </tr> <tr> <td width="14%"><strong>Topic</strong></td> <td width="2%">:</td> <td width="84%"><input name="topic" type="text" id="topic" size="50" /></td> </tr> <tr> <td valign="top"><strong>Detail</strong></td> <td valign="top">:</td> <td><textarea name="detail" cols="50" rows="3" id="detail"></textarea></td> </tr> <tr> <td><strong>Name</strong></td> <td>:</td> <td><input name="name" type="text" id="name" size="50" /></td> </tr> <tr> <td><strong>Email</strong></td> <td>:</td> <td><input name="email" type="text" id="email" size="50" /></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td> </tr> </table> </td> </form> </tr> </table> <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="myforum"; // Database name $tbl_name="fquestions"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name ORDER BY id DESC"; // OREDER BY id DESC is order result by descending $result=mysql_query($sql); ?> <br> <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td width="6%" align="center" bgcolor="#E6E6E6"><strong>Topic ID</strong></td> <td width="20%" align="center" bgcolor="#E6E6E6"><strong>Topic Name</strong></td> <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Delete</strong></td> </tr> <?php // Start looping table row while($rows = mysql_fetch_array($result)){ ?> <tr> <td align="center"><?php echo $rows['id']; ?></td> <td align="center" bgcolor="#FFFFFF"><a href="view_topic.php?id=<?php echo $rows['id']; ?>"><?php echo $rows['topic']; ?></a></td> <td align="center" bgcolor="#FFFFFF"><?php echo $rows['view']; ?></td> <td align="center" bgcolor="#FFFFFF"><?php echo $rows['reply']; ?></td> <td align="center" bgcolor="#FFFFFF"><?php echo $rows['datetime']; ?></td> <td align="center" bgcolor="#FFFFFF"><a href="deletefile.php?id=<?php echo $rows['id']; ?>" onClick="return myFunction()">Delete</a></center></td> </tr> <?php // Exit looping and close connection } mysql_close(); ?> </table> <script> function myFunction() { var x = confirm("Are you sure you want to delete this topic? ?"); if (x==true) { window.location ="deletefile.php"; } else { window.location="main_forum.php"; } return x; } </script> This is the output of the code above i just need help to make a page pagination for this i will accept any design,limit of pagination,styles,techniques i really have no idea how to paginate things thank you in advance
  2. i think i found my problem, many says the the group that im using is a reserve word thats why im not getting any value anyways thank you for the reply
  3. sorry for the late reply the problem is this only echo 'Select a group :'; echo '<select name="code1">'; echo '<br>'; while($row2=mysql_fetch_array($query2)){ echo '<br>'; echo "<option value=\"" . $row2['g_code'] . "\">" . $row2['g_code'] . "</option> "; } echo '</select>'; echo '<input type="submit" name="submit" value="GO">'; echo '</form>'; if(isset($_POST['submit'])){ $go = $_POST['code1']; $query = "SELECT * FROM student WHERE group='$go'"; getting the option value is working fine this where the problem starts now i have the submit button for the $go = $_POST['code1']; getting value from the option select i am not getting any value from &_POST['code1']; which is in the options, so after submitting $go still remains empty and the query does not execute because the $go remains empty after submitting the button
  4. <?php $connection=mysql_connect('localhost', '',''); mysql_select_db('db'); $username= $_SESSION['username']; $query1 = mysql_query("SELECT * FROM instructor WHERE username='$username'"); $row1 = mysql_fetch_assoc($query1); $i_id = $row1['id']; $query2 = mysql_query("SELECT g_code FROM i_group WHERE i_id='$i_id' "); $row2 = mysql_fetch_assoc($query2); <---PROBLEM STARTS HERE (not part of the code)---> echo 'Select a group :'; echo '<select name="code1">'; echo '<br>'; while($row2=mysql_fetch_array($query2)){ echo '<br>'; echo "<option value=\"" . $row2['g_code'] . "\">" . $row2['g_code'] . "</option> "; } echo '</select>'; echo '<input type="submit" name="submit" value="GO">'; echo '</form>'; if(isset($_POST['submit'])){ $go = $_POST['code1']; $query = "SELECT * FROM student WHERE group='$go'"; im getting the row2 values but when i select from the option and click submit it says that the query is wrong any idea about my problem? advance thanks
  5. i should also change my student tablename(group) into other names?
  6. do u think i wrote it in the right way? SELECT instructor.name , i_group.id , i_group.code , student.id , student.name , student.username , student.password FROM student INNER JOIN i_group.id INNER JOIN instructor.id ORDER BY instructor.name, instructor.id
  7. So i got 3 tables Table1(instructor) -id (primary key , ai) -username -password -email -name Table2(i_group) -id (primary key, ai) -i_id (this connects to Table1*instructor* row id) -code (code here comes from Table1*instructor*) instructor can have more than 1 code Table3(student) -id (primary key, ai) -username -password -name -group (this connects to Table2*i_group* row code) well i want an output of all rows of Table3(student) where is separated depends on the instructors id that matches the code. id>id_id and code> group Example Instructor id = 1 username = instructor1 password = password email = email@y.c name = instructor i_group id = 1 / 2 / 3 i_id = 1 / 1 / 2 g_code = MYCODE1 / MYCODE2 / MYCODE3 student id = 1 / 2 / 3 username = uname1 / uname2 / uname3 password = pass1 / pass2 / pass3 name = name1 / name2 / name 3 group = MYCODE1 / MYCODE1 / MYCODE 2 and when i the input on the instructor is 1 the output of the student must be : id = 1 / 2 username = uname1 / uname2 password = pass1 / pass2 name = name1 / name2 group = MYCODE1 / MYCODE1 i know my question is a bit of confusing i hope you guys can understand my question
  8. im having trouble inserting the <script> code in the die here is my code <?php session_start (); $username = $_POST ['username']; $password = $_POST ['password']; if ($username&&$password) { $connect = mysql_connect ("localhost","root","") or die("Error"); mysql_select_db('thesis') or die("Error"); $query = mysql_query("SELECT * FROM student WHERE username ='$username'"); $numrows = mysql_num_rows($query); $query1 = mysql_query("SELECT * FROM admin WHERE username='$username'"); $row1 = mysql_fetch_assoc($query1); $adusername = $row1['username']; $adpassword = $row1['password']; $queryid = mysql_query("SELECT id FROM student WHERE username ='$username'"); $row2 = mysql_fetch_assoc($queryid); $id = $row2['id']; if ($username==$adusername&&$password==$adpassword) { die(strval($_SESSION['username']=$username)); die ('<script type="text/javascript"> alert("Welcome Administrator !"); window.location = "adminpage.php"; </script>'); } if ($numrows!=0) { while ($row = mysql_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; } if ($username==$dbusername&&$password==$dbpassword) { echo '<script type="text/javascript"> alert("Login Successful !"); window.location = "studhome.php"; </script>'; $_SESSION['username']=$username; $_SESSION['id']=$id; $_SESSION['name']=$name; } else echo '<script type="text/javascript"> alert("Incorrect Password !"); window.location = "Login.php"; </script>'; } else die('<script type="text/javascript"> alert("User not Registered !"); window.location = "Login.php"; </script>'); } else die('<script type="text/javascript"> alert("Please Enter Username/Password !12121"); window.location = "Login.php"; </script>'); ?> advance thanks
×
×
  • 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.