Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to link to this to the database
- AAA
- AAB
- ABA
- ABB
- BAA
- BAB
- BBA
- BBB
- Session Id
- AAA
- AAB
- <?php
- $username="xxxxxxxxxxx";
- $password="xxxxxx";
- $database="mobile_app";
- mysql_connect('localhost',$username,$password);
- @mysql_select_db($database) or die("Unable to select database");
- foreach (array('courseid') as $varname) {
- $courseid = (isset($_POST[$varname])) ? $_POST[$varname] : '';
- }
- ?>
- <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
- <p>Course ID: <input type="text" name="courseid" value="<?php echo $courseid; ?>" /><input type="submit" value="Submit" name="submit" /></p> <!-- Enter User Id here-->
- </form>
- <?php
- if (isset($_POST['submit'])) {
- $query = "
- SELECT cm.CourseId, cm.ModuleId,
- c.CourseName,
- m.ModuleName
- FROM Course c
- INNER JOIN Course_Module cm ON c.CourseId = cm.CourseId
- JOIN Module m ON cm.ModuleId = m.ModuleId
- WHERE
- (c.CourseId = '".mysql_real_escape_string($courseid)."')
- ORDER BY c.CourseName, m.ModuleId
- ";
- $num = mysql_num_rows($result = mysql_query($query));
- mysql_close()
- ;
- ?>
- <?php
- $username=xxx";
- $password="xxx";
- $database="mobile_app";
- $is_there = true;
- $con = mysql_connect('localhost',$username,$password);
- @mysql_select_db($database, $con) or die("Unable to select database");
- while( $is_there ){
- $id = id_generator(); // your function to generate id;
- $result = mysql_query( "SELECT SessionId FROM Session WHERE SessionId = '$id'" );
- if( mysql_num_rows( $result ) == 0 ) $is_there = false;
- }
- foreach (array('courseid', 'sessionid') as $varname) {
- $$varname = (isset($_POST[$varname])) ? $_POST[$varname] : '';
- }
- ?>
- <h1>CREATING A SESSION</h1>
- <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
- <p>Course ID: <input type="text" name="courseid" value="<?php echo $courseid; ?>" /><input type="submit" value="Submit" name="submit" /></p> <!-- Enter User Id here-->
- </form>
- <?php
- if (isset($_POST['submit'])) {
- $query = "
- SELECT cm.CourseId, cm.ModuleId,
- c.CourseName,
- m.ModuleName
- FROM Course c
- INNER JOIN Course_Module cm ON c.CourseId = cm.CourseId
- JOIN Module m ON cm.ModuleId = m.ModuleId
- WHERE
- (c.CourseId = '".mysql_real_escape_string($courseid)."')
- ORDER BY c.CourseName, m.ModuleId
- ";
- $num = mysql_num_rows($result = mysql_query($query));
- mysql_close();
- $is_there = true;
- $con = mysql_connect( address , user, pass );
- mysql_select_db( DATABASE , $con );
- while( $is_there ){
- $id = id_generator(); // your function to generate id;
- $result = mysql_query( "SELECT * FROM your_table WHERE id = '$id'" );
- if( mysql_num_rows( $result ) == 0 ) $is_there = false;
- }
- <?php
- ...
- @mysql_select_db($database) or die("Unable to select database");
- $courseid = "";
- while( $is_there ){
- $courseid = id_generator(); // your function to generate id;
- $query = "
- SELECT cm.CourseId, cm.ModuleId,
- c.CourseName,
- m.ModuleName
- FROM Course c
- INNER JOIN Course_Module cm ON c.CourseId = cm.CourseId
- JOIN Module m ON cm.ModuleId = m.ModuleId
- WHERE
- (c.CourseId = '".mysql_real_escape_string($courseid)."')
- ORDER BY c.CourseName, m.ModuleId
- ";
- if( mysql_num_rows( $result = mysql_query($query) ) == 0 ) $is_there = false;
- }
- mysql_close();
- echo "You generated code id: " . $courseid;
- ?>...
Add Comment
Please, Sign In to add comment