Jump to content

[SOLVED] User Defined Function - MySQL Queries


bigdspbandj

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.