//} require_once '../db.class.php'; $db = new db_class(); // query for assignment list $aid = 0; //assignment id $ass = $db->select("select * from assignment"); if (isset($_REQUEST['id']) && isset($_REQUEST['is_group'])) { $aid = $_REQUEST['id']; // get range depending on if group or not if ($_REQUEST['is_group'] == 0) { $q = $db->select('select count(id) as count from grp_member where assignment =' . $aid); } else { $q = $db->select('SELECT count( DISTINCT grp ) as count FROM grp_member WHERE assignment=' . $aid); } $r = $db->get_row($q); $range = $r['count']; // we have range for the graph // now get questions in assignment //$db->print_last_error(); $questions = $db->select('select question.id, question.description from question, assignment_question where question.id = assignment_question.question and assignment_question.assignment=' . $aid . ' order by assignment_question.ord asc'); $jsquestions = array(); while ($r = $db->get_row($questions)) { $jsquestions[$r['id']] = $r['id'] . '-' . $r['description']; } } ?> <script language="javascript" type="text/javascript" src="/src/js/jquery.jqplot.min.js"></script> <!--<script language="javascript" type="text/javascript" src="/src/js/plugins/jqplot.canvasTextRenderer.js"></script> <script language="javascript" type="text/javascript" src="/src/js/plugins/jqplot.canvasAxisLabelRenderer.js"></script> <script language="javascript" type="text/javascript" src="/src/js/plugins/jqplot.canvasAxisTickRenderer.js"></script>
if (!$user_id) { $db->print_last_error(false); } $db->print_last_query(); $db->dump_query("SELECT * FROM users WHERE user_id={$user_id}"); // This is similar to the above, only it updates the data rather than insert. Also // you'll notice that in the first one we used a string to represent the date // and this time we're using the time function to generate a timestamp. This is // done to illustrate the class' ability to convert the date and time formats // to a MySQL compatible format. I like that alot :) echo "<br>Updating the data in the table by changing the date_added... "; $data = array('date_added' => time()); $rows = $db->update_array('users', $data, "user_id={$user_id}"); if (!$rows) { $db->print_last_error(false); } if ($rows > 0) { echo "{$rows} rows updated."; } $db->print_last_query(); $db->dump_query("SELECT * FROM users WHERE user_id={$user_id}"); // And now I'll just show you really quickly how to use this class to itereate // a results set. It's not much differnt that without using the class. In fact, // if you don't need to use the stripslashes and addslashes, that is, if // $db->auto_slahses=false then using the get_row() function is totally pointless // and can be replaced with mysql_fetch_array($r); echo "<br>Example of how to iterate through a result set...<br> "; $r = $db->select("SELECT user_name, email FROM users"); while ($row = $db->get_row($r, 'MYSQL_ASSOC')) { echo '<b>' . $row['user_name'] . "</b>'s email address is <b>" . $row['email'] . "</b><br>"; }
<link rel="stylesheet" type="text/css" href="braincrave.css" /> <script src="http://code.jquery.com/jquery-1.4.4.min.js"></script> <script type="text/javascript" src="braincrave.js"></script> <script src="http://scripts.embed.ly/jquery.embedly.min.js"></script> </head> <body> <div align="center"> <?php if (!empty($_REQUEST['id']) && is_numeric($_REQUEST['id'])) { $image_id = $_REQUEST['id']; $row = $db->select("SELECT * FROM images WHERE id = {$image_id} LIMIT 1"); } else { $row = $db->select("SELECT * FROM images ORDER BY RAND() LIMIT 1"); } $media = $db->get_row($row, 'MYSQL_ASSOC'); // we've got an image $md5 = $media['md5']; $sql = "SELECT username FROM users u WHERE id = {$media['user_id']};"; $poster = $db->select_one($sql); $image_id = $media['id']; $image_type = $media['type']; $image_url = "bimages/{$md5}.{$image_type}"; $r = $db->select("SELECT id, md5, youtube_url, type FROM images WHERE id < {$image_id} ORDER BY id DESC LIMIT 1 "); $row = $db->get_row($r, 'MYSQL_ASSOC'); $prev_img = $row['md5'] . '.' . $row['type']; $prev_img_id = $db->select_one("SELECT id FROM images WHERE id < {$image_id} ORDER BY id DESC LIMIT 1"); $next_img_id = $db->select_one("SELECT id FROM images WHERE id > {$image_id} ORDER BY id ASC LIMIT 1"); $most_recent_upload = $db->select_one("SELECT id FROM images ORDER BY id DESC LIMIT 1"); $r = $db->select("SELECT id, md5, youtube_url, type FROM images WHERE id > {$image_id} ORDER BY id ASC LIMIT 1 "); $row = $db->get_row($r, 'MYSQL_ASSOC');