Jump to content

[SOLVED] Stuck with functions


phatgreenbuds

Recommended Posts

I have the following code for my function:

 

function get_cust_content(){
$query = "SELECT * FROM tbl_content WHERE cust_id = '1' ORDER BY vid_desc ASC";
$cust_content = mysql_query($query);
confirm_query($cust_content); //function higher up that validates the results
return $cust_content; //returns the function result to the requesting file.
}

function list_content(){
$cust_content = get_cust_content(); //calls to the function above. ?>
  	<select name="Content">
    
<?php do { ?>
<option value="<?php echo $content['vid_desc']?>"><?php echo $content['vid_desc']?></option>
    
<?php
	} while ($content = mysql_fetch_array($cust_content)) ;
	$rows = mysql_num_rows($cust_content);
	if ($rows > 0)
	{
		mysql_data_seek($cust_content, 0);
		$content = mysql_fetch_assoc($cust_content);
	}}
?>
     </select>

 

This function works great...does exactly what I want it to. However when I place it in the file below its not displaying as I would have expected.

 

  <tr>
    <td><p>Select Content</p></td>
    <td><input name="content1" value="<?php list_content(); ?>"></td>
  </tr>

 

The reason I am doing this is that the function needs to repeat and return post data based on the "input name=" portion of the form field. This input name will change with every repetition and post to a different field in the DB

Link to comment
https://forums.phpfreaks.com/topic/122831-solved-stuck-with-functions/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.