bigdspbandj Posted November 2, 2007 Share Posted November 2, 2007 I am trying to write a function that builds list of different query results, but the mysql_fetch_assoc function isn't working properly within my function. If anyone cares to take a gander and let us know what I may be missing. my function // Build list for over/index page function overview_list($category, $query_result, $query_numrows, $heading) { echo '<h3>'.$heading.'</h3>'; echo '<p class="list_description">'.$description.'</p>'; if ($query_numrows == 0) { switch ($category) { case 'proof': echo '<p>There are currently no jobs waiting to be proofed. <a href="submit_job.php">Click here to submit a new job!</a></p>'; break; case 'approval': echo '<p>There are currently no jobs for you to approve.</p>'; break; case 'mailing': echo '<p>There are currently no jobs scheduled for mailing today</p>'; break; } } else { echo '<ul>'; while ($$category_rows = mysql_fetch_assoc($query_result)) { echo '<li>'; echo '<h4 class="job_description"><span class="job_label">'.$$category_rows['association_name'].'</span><span class="tracking_num">'.$category.'_rows["tracking_num"]</span></h4>'; echo '<ul class="job_details">'; echo '<li class="qty">'.$$category_rows['pieces_cnt'].'</li>'; echo '<li class="date_submitted">'.$category.'_rows["date_submitted"]</li>'; echo '<li class="desired_maildate">'.$category.'_rows["desired_maildate"]</li>'; echo '<li class="date_mailed">'.$category.'_rows["date_mailed"]</li>'; echo '</ul>'; echo '</li>'; } echo '</ul>'; } } the query $proof_sql = "SELECT d_jobs.*, job_label AS 'association_name', d_status.*, date_format(d_jobs.desired_maildate, '%m-%d-%y') AS desired_maildate, date_format(d_status.date, '%m-%d-%y') AS status_date, d_jobs.id AS job_id FROM d_jobs, d_status WHERE d_jobs.login_id = 5 AND d_jobs.current_status = 'Submitted' AND d_status.job_id = d_jobs.id AND d_status.label = 'Submitted' ORDER BY d_status.date"; $proof_result = mysql_query($proof_sql) or die('Sorry, but we could not establish a connection with our database. Please try again later.'); $proof_numrows = mysql_num_rows($proof_result); overview_list('proof', $proof_result, $proof_numrows, 'Jobs Awaiting Soft Proof From Optimal'); Link to comment https://forums.phpfreaks.com/topic/75844-solved-user-defined-function-mysql-queries/ Share on other sites More sharing options...
GingerRobot Posted November 2, 2007 Share Posted November 2, 2007 Where you supposed to be using a variable variable in these few lines?: while ($$category_rows = mysql_fetch_assoc($query_result)) { echo '<li>'; echo '<h4 class="job_description"><span class="job_label">'.$$category_rows['association_name'].'</span><span class="tracking_num">'.$category.'_rows["tracking_num"]</span></h4>'; echo '<ul class="job_details">'; echo '<li class="qty">'.$$category_rows['pieces_cnt'].'</li>'; I assume not, since you then use a normal variable later on - and $category_rows is undefined. Try using a single $ sign. Link to comment https://forums.phpfreaks.com/topic/75844-solved-user-defined-function-mysql-queries/#findComment-383863 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.