Forum Moderators: coopster

Message Too Old, No Replies

2 Queries on one page?

         

tonynoriega

10:09 pm on May 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is this possible?

I have a page that i call the "snapshot" of a table in my database...it shows the first 5 colums of the table, as a quick reference overview of the data....

which obviously is pulled from the database, and displyed in a simple table layout.

From there the user can select the record ID and pass that on to the modify.php page for modification and updating the table.

Can i also have a drop down menu that filters the displayed table by specific agent?

For instance i first see the table with John and Janes entries.... i want to filter just by John and display only his entries....

can i do this?

StupidScript

11:35 pm on May 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sure! Make the drop-down trigger a filtered query ("..order by '$menu'" or "...like '$menu'", for example).

barns101

11:37 pm on May 29, 2007 (gmt 0)

10+ Year Member



You need to use the WHERE clause in your MySQL query to select specific records.

SELECT * FROM `table` WHERE `user` = 'John'

[edited by: barns101 at 11:39 pm (utc) on May 29, 2007]

tonynoriega

2:30 am on May 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, so im asking for help on that area.....
How would i implement another query option on this page?

what i have below is the "snapshot" of the table....just basically displays the table, and you can select the record by ID to modify ....

im just not sure how to structure this to create another query that would kind of, overwrite this table, and only show by Agent for instance...
_________________________________________________________________
<table>
<form action="{page_link_28}" method="post">
<tr>
<td width="79%">Enter Record Number to Modify:</td>
<td width="21%"><INPUT TYPE="text" NAME="rec_id" SIZE="9" MAXLENGTH="5"></td>
</tr>
<tr>
<td> </td>
<td><INPUT TYPE="submit" NAME="go" VALUE="Modify"></td>
</tr>
</form>
</table>

<!--<?php

//connect to database

$q="SELECT * FROM Registration_Data ORDER BY nhm_associate ASC";

$result = mysql_query( $q, $dbh )
or die(" - Failed More Information:<br><pre>$q</pre><br>Error: " . mysql_error());

$num_rows = mysql_num_rows($result);
if ($myrow = mysql_fetch_array($result)) {

echo "<table>";
echo "<tr><td>//column headers go here</td></tr>";
do {
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td width='700'>%s</td></tr>",$myrow["rec_id"],$myrow["lead_date"],$myrow["nhm_associate"], $myrow["fname"], $myrow["lname"], $myrow["home_phone"], $myrow["cell_phone"], $myrow["email"], $myrow["remarks"]);
} while ($myrow = mysql_fetch_array($result));
echo "</table></td></tr></table>";
} else {
echo "$ref: That record appears to be unavailable";
}

mysql_free_result($result);
mysql_close($db);
?>-->