Changing a MySql List using a select

I would like to change my query by using a select field.

Page 1 of 1

4 Replies - 863 Views - Last Post: 24 September 2007 - 12:43 PM Rate Topic: -----

#1 Wade  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 23-September 07

Changing a MySql List using a select

Post icon  Posted 23 September 2007 - 09:39 PM

I would like for the select list (which hold a list of issue numbers for a set of articles) to change the query of the displayed list of articles, but I don't know how to get the article list to update when the issue number changes. I also do not understand single quotes, double quotes and when to use them. All help is appreciated.

<body>
<p align="center">
  <?php
	$query = "SELECT id, headline FROM articles WHERE vol='$issue' ORDER BY displayorder";
	$result = mysql_query($query) or die('Error : ' . mysql_error());
?> 
  <span class="style1">NEWS CONTENT ADMINISTRATION</span></p>
<p> </p>
<table width="600" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#999999">
 <tr align="center" bgcolor="#CCCCCC"> 
  <td width="500"><strong>Issue</strong></td>
  <td width="150">
  <? // <input type="text" name='Issue' size=4/> -->
			 echo'<select name="issue">';
				  $res=mysql_query("select * from volissue");
				  if(mysql_num_rows($res)==0) echo "there is no data in table..";
					 else
				  for($i=0;$i<mysql_num_rows($res);$i++) {
					 $row=mysql_fetch_assoc($res);
					 echo"<option>$row[vol]</option>";
					}
			  echo'</select>'; ?>
  </td>
 </tr>
 <tr align="center" bgcolor="#CCCCCC"> 
  <td width="500"><strong>Title</strong></td>
  <td width="150"><strong>Action</strong></td>
 </tr><?php
	while(list($id, $headline) = mysql_fetch_array($result, MYSQL_NUM))
	{
	
?>
 <tr bgcolor="#FFFFFF"> 
  <td width="500"> 
   <?php echo $headline;?>
  </td>
  <td width="150" align="center"><a href="cms-view.php?id=<?php echo $id;?>" target="_blank">view</a> 
   | <a href="cms-edit.php?id=<?php echo $id;?>">edit</a> | <a href="java script:delArticle('<?php echo $id;?>', '<?php echo $headline;?>');">delete</a></td>
 </tr>
 <?php
	}
	
include 'library/closedb.php';
?>
</table>
<p align="center"><a href="cms-add.php">Add an article</a><a href="/content.php">Back to Content Mgt Page</a></p>
</body>



Is This A Good Question/Topic? 0
  • +

Replies To: Changing a MySql List using a select

#2 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: Changing a MySql List using a select

Posted 23 September 2007 - 09:50 PM

I'm sorry I don't understand what you're wishing to do, would you try and explain that differently? Thank you.
Was This Post Helpful? 0
  • +
  • -

#3 Wade  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 23-September 07

Re: Changing a MySql List using a select

Posted 23 September 2007 - 10:06 PM

This page displays a list of articles for a specific issue. From the article list the user can view, edit, or delete the article or add a new article to the issue. The article list works fine in static mode, and I am working on passing the issue value in from the page that calls this one, but I would prefer to use the issue select field at the top of the table on this page to be able to be changed and then get the page to refresh with the new issue value for the WHERE vol='$issue' clause at the top of the code. Kinda like a parent child relationship.
Was This Post Helpful? 0
  • +
  • -

#4 Wade  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 23-September 07

Re: Changing a MySql List using a select

Posted 23 September 2007 - 10:57 PM

I guess what may work, may be the sledge hammer approach, but there are only a handfull of users. I would determine if the value of $issue had changed and then would pass that value back into the page and do a reload. I will work on trying to figure that out
Was This Post Helpful? 0
  • +
  • -

#5 Wade  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 23-September 07

Re: Changing a MySql List using a select

Posted 24 September 2007 - 12:43 PM

I would still like to know how to do it correctly - on a page have a list of issues and depending on the selected issue the associated list of articles. I can do it with a static WHERE clause but I do not know how to change the article list when a new issue is selected. Any help is appreciated.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1