dennismonsewicz Posted October 2, 2008 Share Posted October 2, 2008 Code: <?php /*ini_set ("display_errors", "1"); error_reporting(E_ALL);*/ include "includes/sql.php"; $id = 24; $query = mysql_query("SELECT * FROM added_projects WHERE id = '$id'")or die(mysql_error()); $results = mysql_fetch_object($query); $checkbox_qry = mysql_query("SELECT * FROM has_had_projects WHERE project = '" . $results->project . "'")or die(mysql_error()); $field = mysql_num_fields($checkbox_qry); for($i = 0; $i < $field; $i++) { $names = mysql_field_name($checkbox_qry, $i); $title .= trim($names) . "<br />"; } echo $title; ?> How would I delete the first two entries in the array? Quote Link to comment https://forums.phpfreaks.com/topic/126765-solved-array-help/ Share on other sites More sharing options...
KevinM1 Posted October 2, 2008 Share Posted October 2, 2008 http://www.php.net/manual/en/function.array-slice.php Quote Link to comment https://forums.phpfreaks.com/topic/126765-solved-array-help/#findComment-655642 Share on other sites More sharing options...
dennismonsewicz Posted October 2, 2008 Author Share Posted October 2, 2008 well the problem is, is that there is no array here so array_slice() does not work... Quote Link to comment https://forums.phpfreaks.com/topic/126765-solved-array-help/#findComment-655663 Share on other sites More sharing options...
KevinM1 Posted October 2, 2008 Share Posted October 2, 2008 well the problem is, is that there is no array here so array_slice() does not work... What variable are you trying to truncate? Quote Link to comment https://forums.phpfreaks.com/topic/126765-solved-array-help/#findComment-655691 Share on other sites More sharing options...
dennismonsewicz Posted October 2, 2008 Author Share Posted October 2, 2008 the $title var Its showing the id and project field (which are the first two columns in the DB table)... I am wanting to not show these in the list Quote Link to comment https://forums.phpfreaks.com/topic/126765-solved-array-help/#findComment-655693 Share on other sites More sharing options...
KevinM1 Posted October 2, 2008 Share Posted October 2, 2008 the $title var Its showing the id and project field (which are the first two columns in the DB table)... I am wanting to not show these in the list Couldn't you merely start your for-loop with $i = 2? Quote Link to comment https://forums.phpfreaks.com/topic/126765-solved-array-help/#findComment-655695 Share on other sites More sharing options...
dennismonsewicz Posted October 2, 2008 Author Share Posted October 2, 2008 wow its amazing the things you learn on this forum! LOL! thanks it works! Here is the code for those who want to know how it works: <?php /*ini_set ("display_errors", "1"); error_reporting(E_ALL);*/ include "includes/sql.php"; $id = 24; $query = mysql_query("SELECT * FROM added_projects WHERE id = '$id'")or die(mysql_error()); $results = mysql_fetch_object($query); $checkbox_qry = mysql_query("SELECT * FROM has_had_projects WHERE project = '" . $results->project . "'")or die(mysql_error()); $field = mysql_num_fields($checkbox_qry); for($i = 2; $i < $field; $i++) { $names = mysql_field_name($checkbox_qry, $i); $title .= $names . "<br />"; } echo $title; ?> Quote Link to comment https://forums.phpfreaks.com/topic/126765-solved-array-help/#findComment-655698 Share on other sites More sharing options...
kenrbnsn Posted October 2, 2008 Share Posted October 2, 2008 If you don't want to use the first two columns, don't ask for them in your query. Instead of <?php $checkbox_qry = mysql_query("SELECT * FROM has_had_projects WHERE project = '" . $results->project . "'")or die(mysql_error()); ?> do <?php $checkbox_qry = mysql_query("SELECT list,the,fields,you,want FROM has_had_projects WHERE project = '" . $results->project . "'")or die(mysql_error()); ?> Replacing "list,the,fields,you,want" with the real field names. Ken Quote Link to comment https://forums.phpfreaks.com/topic/126765-solved-array-help/#findComment-655703 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.