k0rnonthek0b Posted December 10, 2007 Share Posted December 10, 2007 Hey I am working on a PHP calendar here, and I am pretty new to this all but so far everything works except when I try to retrieve my data from my database it only shows the most recent entry instead of listing ALL of the current items in the database. I hope that makes sense. Thank you, here is my code: <?php include '_prepend.php'; if (!empty($_POST)) { if (!empty($_POST['event_title'])) { $unixT1 = strtotime($_POST['event_month_1'] . ' '.$_POST['event_day_1'] . ' ' . $_POST['event_year_1'] . ' ' . $_POST['event_hour_1']); //echo $unixT1.'<br />'; $unixT2 = strtotime($_POST['event_month_2'] . ' '.$_POST['event_day_2'] . ' ' . $_POST['event_year_2'] . ' ' . $_POST['event_hour_2']); //echo $unixT2.'<br />'; $_POST['event_timestamp_1'] = $unixT1; $_POST['event_timestamp_2'] = $unixT2; insertData("activities", $_POST); //redirect to kill the post } } $activities = SQLquery("SELECT * FROM activities"); $activities = $activities['data']; ?> <html> <head> <title>Personal Calendar</title> <link href="../CSS/css.css" rel="stylesheet" type="text/css"> </head> <body bgcolor="#ffffff"> <?php include '_header.php' ?> <h1>Add An Event</h1> <form action="" method="post"> <table width="75%"> <tr> <td width="23%"><div align="right"> <label>Event Title: </label> <label></label> </div></td> <td width="77%"><input type="text" name="event_title" value="" size="40" maxlength="255"></td> </tr> <tr> <td><div align="right"> <label>Event Description:</label> <br> </div></td> <td><textarea name="event_desc" rows="10" cols="43"></textarea></td> </tr> <tr> <td><div align="right">Date Begins:</div></td> <td><select name="event_month_1" size="1"> <option value="" selected> </option> <option value="January">January</option> <option value="February">February</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> - <select name="event_day_1" size="1"> <option value="" selected> </option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="23">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> - <select name="event_year_1" size="1"> <option value="" selected> </option> <option value="2007">2007</option> <option value="2008">2008</option> <option value="2009">2009</option> <option value="2010">2010</option> </select> </td> </tr> <tr> <td><div align="right">Hour Begins: </div></td> <td><select name="event_hour_1" size="1"> <option value="" selected> </option> <option value="12:00am">12:00 am</option> <option value="12:30am">12:30 am</option> <option value="1:00am">1:00 am</option> <option value="1:30am">1:30 am</option> <option value="2:00am">2:00 am</option> <option value="2:30am">2:30 am</option> <option value="3:00am">3:00 am</option> <option value="3:30am">3:30 am</option> <option value="4:00am">4:00 am</option> <option value="4:30am">4:30 am</option> <option value="5:00am">5:00 am</option> <option value="5:30am">5:30 am</option> <option value="6:00am">6:00 am</option> <option value="6:30am">6:30 am</option> <option value="7:00am">7:00 am</option> <option value="7:30am">7:30 am</option> <option value="8:00am">8:00 am</option> <option value="8:30am">8:30 am</option> <option value="9:00am">9:00 am</option> <option value="9:30am">9:30 am</option> <option value="10:00am">10:00 am</option> <option value="10:30am">10:30 am</option> <option value="11:00am">11:00 am</option> <option value="11:30am">11:30 am</option> <option value="12:00pm">12:00 pm</option> <option value="12:30pm">12:30 pm</option> <option value="1:00pm">1:00 pm</option> <option value="1:30pm">1:30 pm</option> <option value="2:00pm">2:00 pm</option> <option value="2:30pm">2:30 pm</option> <option value="3:00pm">3:00 pm</option> <option value="3:30pm">3:30 pm</option> <option value="4:00pm">4:00 pm</option> <option value="4:30pm">4:30 pm</option> <option value="5:00pm">5:00 pm</option> <option value="5:30pm">5:30 pm</option> <option value="6:00pm">6:00 pm</option> <option value="6:30pm">6:30 pm</option> <option value="7:00pm">7:00 pm</option> <option value="7:30pm">7:30 pm</option> <option value="8:00pm">8:00 pm</option> <option value="8:30pm">8:30 pm</option> <option value="9:00pm">9:00 pm</option> <option value="9:30pm">9:30 pm</option> <option value="10:00pm">10:00 pm</option> <option value="10:30pm">10:30 pm</option> <option value="11:00pm">11:00 pm</option> <option value="11:30pm">11:30 pm</option> </select></td> </tr> <tr> <td><div align="right">Date Ends:</div></td> <td><select name="event_month_2" size="1"> <option value="" selected> </option> <option value="January">January</option> <option value="February">February</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> - <select name="event_day_2" size="1"> <option value="" selected> </option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="23">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> - <select name="event_year_2" size="1"> <option value="" selected> </option> <option value="2007">2007</option> <option value="2008">2008</option> <option value="2009">2009</option> <option value="2010">2010</option> </select></td> </tr> <tr> <td><div align="right">Hour Ends:</div></td> <td><select name="event_hour_2" size="1"> <option value="" selected> </option> <option value="12:00am">12:00 am</option> <option value="12:30am">12:30 am</option> <option value="1:00am">1:00 am</option> <option value="1:30am">1:30 am</option> <option value="2:00am">2:00 am</option> <option value="2:30am">2:30 am</option> <option value="3:00am">3:00 am</option> <option value="3:30am">3:30 am</option> <option value="4:00am">4:00 am</option> <option value="4:30am">4:30 am</option> <option value="5:00am">5:00 am</option> <option value="5:30am">5:30 am</option> <option value="6:00am">6:00 am</option> <option value="6:30am">6:30 am</option> <option value="7:00am">7:00 am</option> <option value="7:30am">7:30 am</option> <option value="8:00am">8:00 am</option> <option value="8:30am">8:30 am</option> <option value="9:00am">9:00 am</option> <option value="9:30am">9:30 am</option> <option value="10:00am">10:00 am</option> <option value="10:30am">10:30 am</option> <option value="11:00am">11:00 am</option> <option value="11:30am">11:30 am</option> <option value="12:00pm">12:00 pm</option> <option value="12:30pm">12:30 pm</option> <option value="1:00pm">1:00 pm</option> <option value="1:30pm">1:30 pm</option> <option value="2:00pm">2:00 pm</option> <option value="2:30pm">2:30 pm</option> <option value="3:00pm">3:00 pm</option> <option value="3:30pm">3:30 pm</option> <option value="4:00pm">4:00 pm</option> <option value="4:30pm">4:30 pm</option> <option value="5:00pm">5:00 pm</option> <option value="5:30pm">5:30 pm</option> <option value="6:00pm">6:00 pm</option> <option value="6:30pm">6:30 pm</option> <option value="7:00pm">7:00 pm</option> <option value="7:30pm">7:30 pm</option> <option value="8:00pm">8:00 pm</option> <option value="8:30pm">8:30 pm</option> <option value="9:00pm">9:00 pm</option> <option value="9:30pm">9:30 pm</option> <option value="10:00pm">10:00 pm</option> <option value="10:30pm">10:30 pm</option> <option value="11:00pm">11:00 pm</option> <option value="11:30pm">11:30 pm</option> </select></td> </tr> <tr> <td> <div align="right"> </div></td> <td><input type="submit" name="submit" value="submit"></td> </tr> </table> </form> <h2>Current Events</h2> <table width="40%" border="0"> <tr> <td width="47%" rowspan="4"><table> <tr> <th width="192"><div align="right">Title:</div></th> </tr> <tr> <th><div align="right">Description:</div></th> </tr> <tr> <th><div align="right">Start:</div></th> </tr> <?php foreach ($activities as $activity) { date("F j, Y, g:i a", $activity['event_timestamp_1']); '<option value="'.$activity['id'].'">'.$activity['event_title'].'</option>'; "\n"; } { date("F j, Y, g:i a", $activity['event_timestamp_2']); '<option value="'.$activity['id'].'">'.$activity['event_title'].'</option>'; "\n"; } ?> <?php $result = sqlQuery('SELECT * FROM activities'); $activities = $result['data']; foreach ($activities as $activity) ?> <tr> <th><div align="right">End:</div></th> </tr> <?php include '_footer.php'?> </table> </td> <td width="53%"> <?= $activity['event_title'] ?> </td> </tr> <tr> <td> <?= $activity['event_desc'] ?> </td> </tr> <tr> <td> <?= date("F j, Y, g:i a", $activity['event_timestamp_1']); ?> </td> </tr> <tr> <td> <?= date("F j, Y, g:i a", $activity['event_timestamp_2']); ?> </td> </tr> </table> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/80958-cannot-retrive-all-items-from-database/ Share on other sites More sharing options...
trq Posted December 10, 2007 Share Posted December 10, 2007 What does your sqlQuery function look like? Quote Link to comment https://forums.phpfreaks.com/topic/80958-cannot-retrive-all-items-from-database/#findComment-410695 Share on other sites More sharing options...
k0rnonthek0b Posted December 10, 2007 Author Share Posted December 10, 2007 CREATE TABLE `activities` ( `event_ID` int(11) unsigned NOT NULL auto_increment, `event_title` varchar(255) NOT NULL default '', `event_desc` text, `event_timestamp_1` int(50) NOT NULL default '0', `event_timestamp_2` int(50) NOT NULL default '0', PRIMARY KEY (`event_ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=58 ; Quote Link to comment https://forums.phpfreaks.com/topic/80958-cannot-retrive-all-items-from-database/#findComment-410696 Share on other sites More sharing options...
pocobueno1388 Posted December 10, 2007 Share Posted December 10, 2007 CREATE TABLE `activities` ( `event_ID` int(11) unsigned NOT NULL auto_increment, `event_title` varchar(255) NOT NULL default '', `event_desc` text, `event_timestamp_1` int(50) NOT NULL default '0', `event_timestamp_2` int(50) NOT NULL default '0', PRIMARY KEY (`event_ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=58 ; No yoru sqlQuery function, not your table structure. You use it in your code like this SQLquery("SELECT * FROM activities"); We need to see what that function looks like. Quote Link to comment https://forums.phpfreaks.com/topic/80958-cannot-retrive-all-items-from-database/#findComment-410698 Share on other sites More sharing options...
k0rnonthek0b Posted December 10, 2007 Author Share Posted December 10, 2007 <?php $result = sqlQuery('SELECT * FROM activities ORDER BY event_timestamp_1 DESC'); $activities = $result['data']; foreach ($activities as $activity) ?> Quote Link to comment https://forums.phpfreaks.com/topic/80958-cannot-retrive-all-items-from-database/#findComment-410699 Share on other sites More sharing options...
pocobueno1388 Posted December 10, 2007 Share Posted December 10, 2007 <?php $result = sqlQuery('SELECT * FROM activities ORDER BY event_timestamp_1 DESC'); $activities = $result['data']; foreach ($activities as $activity) ?> Still not the function... The function is probably defined in _prepend.php. Quote Link to comment https://forums.phpfreaks.com/topic/80958-cannot-retrive-all-items-from-database/#findComment-410702 Share on other sites More sharing options...
k0rnonthek0b Posted December 10, 2007 Author Share Posted December 10, 2007 I'm sorry I am usually not this daft, but when it comes to programming I am in need of help. I have a file that I was working on in class called sqlfunctions.1.6.php this is being called upon in the file i posted above, is that what you are talking about? Quote Link to comment https://forums.phpfreaks.com/topic/80958-cannot-retrive-all-items-from-database/#findComment-410705 Share on other sites More sharing options...
pocobueno1388 Posted December 10, 2007 Share Posted December 10, 2007 If thats where the function is defined, then yes. Quote Link to comment https://forums.phpfreaks.com/topic/80958-cannot-retrive-all-items-from-database/#findComment-410706 Share on other sites More sharing options...
k0rnonthek0b Posted December 10, 2007 Author Share Posted December 10, 2007 Ok, I'm sorry. I have never touched this file. This is something my teacher had given us in class to work off of. <?php # 1.3: modified the way the SQLValue function escapes new lines # 1.4: removed SQLInsertString function; modified SQLUpdateString, insertData & replaceData # functions to escape any field names # 1.5: cache some db result in static variable; allow multiple keys in updateData # 1.6: removed mysql dependency function duplicateCheck( $new, $existingData ) { if( empty($existingData) ) return false; foreach( $existingData as $temp =>$compare ) { $id = ""; if( empty($id) && strstr( key($compare), "id" ) ) { $id = $compare[key($compare)]; } $duplicate = true; foreach( $new as $key => $value ) { if( isset($compare[$key]) && $compare[$key] != $value ) { $duplicate = false; break; } } if( $duplicate ) { if(!empty($id) ) $duplicate = $id; return $duplicate; } } return false; } function SQLValue( $string, $keepZero = false ) { if( trim($string) == "" && !$keepZero ) $value = "NULL"; else { # The function addslashes is a "fake" for calling the proper # escaping function of the db driver. This will need to be # replaced at some point (perhaps when sqlquery is updated # provide an escaping mechanism) $value = "'".addslashes($string)."'"; $value = str_replace("\\\\","\\",$value); $value = str_replace("\\\\","\\",$value); } return $value; } function SQLValues( $data ) { if( is_array($data) ) { foreach( $data as $key => $value ) $data[$key] = SQLValue( $value ); } else $data = SQLValue( $data ); return $data; } function SQLUpdateString( $array ) { if( is_array($array) ) { $string = ""; foreach( $array as $key => $value ) $string .= "`$key` = ".SQLValue( $value ).", "; return rtrim($string,", "); } } # loops through an associative array and returns a list of fields that # are valid for a particular table function SQLTableData( $table, $data ) { $columns = tableColumns($table); $array = array(); if( !empty($data) && is_array($data) ) { foreach( $data as $key => $value ) { if( in_array($key,$columns) ) $array[$key] = $value; } if( !empty($array) ) return $array; } return false; } function tableColumns($tableName) { static $schema = array(); if(empty($schema[$tableName])) { $columns = sqlquery("SHOW COLUMNS FROM ".$tableName); if( !empty($columns['data']) ) { $column_array = array(); foreach( $columns['data'] as $column ) { array_push($column_array, $column['Field']); } } $schema[$tableName] = $column_array; } else { $column_array = $schema[$tableName]; } if( !empty($column_array) ) return $column_array; return false; } function getEnumValues( $table, $field ) { static $schema = array(); if(empty($schema[$table.'::'.$field])) { $select = sqlquery(" DESCRIBE ".$table." ".$field." "); $enum = explode(",",trim(strstr($select['data'][0]['Type'],"("),")(")); foreach( $enum as $key => $value ) { $enum[$key] = trim($value,"'"); } $schema[$table.'::'.$field] = $enum; } else { $enum = $schema[$table.'::'.$field]; } return $enum; } function relevantDataArray( $table, $array ) { $tableFields = tableColumns($table); if( !empty($tableFields) && !empty($array) ) { foreach( $array as $key => $value ) { if( in_array($key, $tableFields) ) $data[$key] = $value; } return $data; } return false; } function insertData( $table, $data, $showQuery=false ) { if( $data = relevantDataArray( $table, $data ) ) { $insert = sqlquery( " INSERT INTO ".$table." (`". implode( "`,`",array_keys($data) ) ."`) VALUES(". implode( ",", SQLValues($data) ) .") "); if( $showQuery ) echo "<pre>", print_r($insert), "</pre>"; if( isset($insert['insertID']) ) return $insert['insertID']; else if( isset($insert['rowsAffected']) && $insert['rowsAffected'] == 1 ) return true; } return false; } function replaceData( $table, $data, $showQuery=false ) { if( $data = relevantDataArray( $table, $data ) ) { $insert = sqlquery( " REPLACE INTO ".$table." (`". implode( "`,`",array_keys($data) ) ."`) VALUES(". implode( ",", SQLValues($data) ) .") "); if( $showQuery ) echo "<pre>", print_r($insert), "</pre>"; if( isset($insert['insertID']) ) return $insert['insertID']; else if( isset($insert['rowsAffected']) && $insert['rowsAffected'] == 1 ) return true; } return false; } function updateData( $table, $data, $key, $showQuery= false ) { $id = array(); if(is_array($key)) { foreach($key as $k) { $id[] = "`$k` = ".SQLValue($data[$k]); unset($data[$k]); } } else { $id[] = "`$key` = ".SQLValue($data[$key]); unset($data[$key]); } if( $data = relevantDataArray( $table, $data ) ) { $update = sqlquery(" UPDATE $table SET ".SQLUpdateString( $data )." WHERE ".implode(' AND ', $id)." "); if( $showQuery ) echo "<pre>", print_r($update), "</pre>"; if( !empty($update['rowsAffected'])) return $update['rowsAffected']; else if( empty($update['errors']) ) return true; } return false; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/80958-cannot-retrive-all-items-from-database/#findComment-410707 Share on other sites More sharing options...
pocobueno1388 Posted December 10, 2007 Share Posted December 10, 2007 Nope...not in there either. it would look like this <?php function sqlQuery(){ //code in between } ?> Quote Link to comment https://forums.phpfreaks.com/topic/80958-cannot-retrive-all-items-from-database/#findComment-410709 Share on other sites More sharing options...
k0rnonthek0b Posted December 10, 2007 Author Share Posted December 10, 2007 Ok, after doing a sitewide search I found it (i think/hope) in another one of those files my teacher gave us. (this is obviously a beginners class) <?php if(function_exists('mysql_connect') || function_exists('mysqli_connect')) { define('FETCH_ASSOC', 0); define('FETCH_NUM', 1); define('FETCH_BOTH', 2); global $dbConfigDefault; $dbConfigDefault = array( 'dbType' => "mysql" , 'hostname' => "localhost" , 'username' => "" , 'password' => "" , 'database' => "" , 'mysqli' => function_exists('mysqli_connect') , 'fetch-mode' => FETCH_ASSOC , 'verbose' => true , 'privacy' => true , 'schema' => false , 'result-only' => false , 'store-result' => true ); if( !function_exists( "mtime" ) ) { function mtime() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } } function SQLQuery( $query, $param = false ) { static $dbStates; if(!isset($dbStates)) { $dbStates = array(); } if(!is_array($param)) { $param = array($param); } global $dbConfigDefault; global $dbConfig; $config = array_merge($dbConfigDefault, $dbConfig); foreach($config as $key => $ignored) { if(isset($param[$key])) { $config[$key] = $param[$key]; } elseif(array_search($key, $param) !== false) { $config[$key] = true; } elseif(array_search('no-'.$key, $param) !== false) { $config[$key] = false; } } if($config['dbType'] != 'mysql') { return false; } $query = trim($query); $return = array(); if(!empty($config['verbose'])) { $t_start = mtime(); $return['query'] = $query; $return['dbType'] = 'mysql'; $return['status'] = false; $return['connection'] = false; $return['database'] = false; $return['schema'] = false; if(!$config['privacy']) { $return['connectionInfo'] = $config; } } $dbConnect = implode('|', array( $config['hostname'], $config['username'], $config['password'] )); if( empty($dbStates[$dbConnect]['connection']) ) { # We need to connect! if(!empty($config['mysqli'])) { $try =& new mysqli( $config['hostname'], $config['username'], $config['password'], $config['database'] ); if(mysqli_connect_errno()) { $return['error'] = mysqli_connect_error(); } else { $dbStates[$dbConnect] = array(); $dbStates[$dbConnect]['connection'] =& $try; $dbStates[$dbConnect]['database'] = $config['database']; } } else { $try = @mysql_connect( $config['hostname'], $config['username'], $config['password'] ); if($try) { $dbStates[$dbConnect] = array(); $dbStates[$dbConnect]['connection'] = $try; $dbStates[$dbConnect]['database'] = ''; } else { $return['error'] = mysql_error(); } } if(!empty($return['error'])) { if(!empty($config['verbose'])) { $t_stop = mtime(); $return['time'] = array( 'start' => $t_start, 'stop' => $t_stop, 'elapsed' => $t_stop - $t_start ); } return $return; } } $db =& $dbStates[$dbConnect]['connection']; if($config['verbose']) { $return['connection'] =& $db; } if(!empty($config['database']) && $config['database'] != $dbStates[$dbConnect]['database']) { if(!empty($config['mysqli'])) { if(!$db->select_db($config['database'])) { $return['error'] = $db->error; } } else { if(!@mysql_select_db( $config['database'], $db )) { $return['error'] = mysql_error($db); } } if(!empty($return['error'])) { if($config['verbose']) { $return['connection'] = false; $t_stop = mtime(); $return['time'] = array( 'start' => $t_start, 'stop' => $t_stop, 'elapsed' => $t_stop - $t_start ); } return $return; } } if(!empty($config['verbose'])) { $return['database'] = true; $q_start = mtime(); } if(!empty($config['mysqli'])) { $q = @$db->real_query($query); } else { $q = @mysql_unbuffered_query($query, $db); } if($config['verbose']) { $q_stop = mtime(); $return['rtime'] = array( 'start' => $q_start, 'stop' => $q_stop, 'elapsed' => $q_stop - $q_start ); } if($q === false) { if(!empty($config['mysqli'])) { $return['error'] = $db->error; } else { $return['error'] = mysql_error($db); } if($config['verbose']) { $return['connection'] = false; $t_stop = mtime(); $return['time'] = array( 'start' => $t_start, 'stop' => $t_stop, 'elapsed' => $t_stop - $t_start ); } return $return; } if($config['verbose']) { $return['status'] = true; } list($queryType, $ignored) = preg_split('/[\s]+/', $query, 2); $queryType = strtolower($queryType); switch($queryType) { case 'select': case 'show': case 'describe': case 'explain': if($config['verbose']) { $return['queryType'] = 'select'; } if(!empty($config['mysqli'])) { $rs = @$db->use_result(); } else { $rs = $q; } if(!$config['store-result']) { $return['data'] = $rs; } elseif(!empty($config['mysqli'])) { if($config['fetch-mode'] == FETCH_NUM) $m = MYSQLI_NUM; elseif($config['fetch-mode'] == FETCH_BOTH) $m = MYSQLI_BOTH; else $m = MYSQLI_ASSOC; $r = array(); while($row = @$rs->fetch_array($m)) $r[] = $row; if($config['verbose'] && $config['schema']) { $f = array(); $s = array(); while($field = $rs->fetch_field()) { $f[$rs->current_field] = $field->name; $s[$rs->current_field] = $field; } } $rs->close(); } else { if($config['fetch-mode'] == FETCH_NUM) $m = MYSQL_NUM; elseif($config['fetch-mode'] == FETCH_BOTH) $m = MYSQL_BOTH; else $m = MYSQL_ASSOC; $r = array(); while($row = mysql_fetch_array($rs, $m)) $r[] = $row; if($config['verbose'] && $config['schema']) { $f = array(); $s = array(); for($i = 0; $i < mysql_num_fields($rs); $i++) { $f[$i] = mysql_field_name($rs, $i); if($config['schema']) $s[$i] = mysql_fetch_field($rs, $i); } } } if(empty($return['data'])) { $return['data'] = $r; if($config['verbose']) { if($config['schema']) { $return['allKeys'] = $f; $return['assocCols'] = sizeof($f); $return['schema'] = $s; } $return['rows'] = sizeof($return['data']); } } break; case 'insert': case 'replace': if($config['verbose']) { $return['queryType'] = 'insert'; } if(!empty($config['mysqli'])) { $return['insertID'] = $db->insert_id; $return['rowsAffected'] = $db->affected_rows; } else { $return['insertID'] = mysql_insert_id($db); $return['rowsAffected'] = mysql_affected_rows($db); } break; case 'update': case 'delete': if($config['verbose']) { $return['queryType'] = $queryType; } if(!empty($config['mysqli'])) { $return['rowsAffected'] = $db->affected_rows; } else { $return['rowsAffected'] = mysql_affected_rows($db); } break; } if(!empty($config['mysqli']) && !$config['store-result']) { mysql_free_result($q); } if($config['verbose']) { $t_stop = mtime(); $return['time'] = array( 'start' => $t_start, 'stop' => $t_stop, 'elapsed' => $t_stop - $t_start ); } if($config['result-only'] && isset($return['data'])) { return $return['data']; } else { return $return; } } } else { function SQLQuery( $query, $param = false ) { return false; } } ?> EDITED BY thorpe. Notice how everyone else on this board has there code within [ code ][/ code ] tags? It makes for much easier reading. Quote Link to comment https://forums.phpfreaks.com/topic/80958-cannot-retrive-all-items-from-database/#findComment-410710 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.