Forum Moderators: coopster
i have say a 40 row database maybe 10 columns across..
i need to grab one column entry from say row 10 an display at point X on a website.. now at point T i might need to display another column entry on row 32...
There a way to echo for a specific row? other then looping? if i loop can i control where they display and not just list?
Thanks!
mysql_select_db($database_sum_enrich, $sum_enrich);
$query_EventSession1K = "SELECT * FROM eventssession1 WHERE GradeK = 'yes'";
$query = "SELECT column FROM table WHERE id ='id_number' LIMIT 1") or die(mysql_error()));
$EventSession1K = mysql_query($query_EventSession1K, $sum_enrich) or die(mysql_error());
$row_EventSession1K = mysql_fetch_assoc($EventSession1K);
$totalRows_EventSession1K = mysql_num_rows($EventSession1K);
$row = mysql_fetch_object($query);
then echos
<?php
echo $row->2;
?>
? is that what you meant are my querys conflicting?
Thanks!
$query = "SELECT column FROM table WHERE id ='id_number' LIMIT 1") or die(mysql_error()));
where he says column key in whatever column name you want to see instead of * in your original query
where he says table i take it that would mean eventsession1
where he says id number he means whatever the name of your tables primary key is.
so instead of:
$query_EventSession1K = "SELECT * FROM eventssession1 WHERE GradeK = 'yes'";
try something along the lines of
(bits you need to alter in square brackets)
:
$query_EventSession1K = "SELECT [name_of_column_to_select] FROM eventssession1 WHERE GradeK = 'yes' AND [primary_key_name] = [primary_key_number]";
if you have the key number as $variable then you could type in like:
$query_EventSession1K = "SELECT [name_of_column_to_select] FROM eventssession1 WHERE GradeK = 'yes' AND [primary_key_name] = ".$variable;
hope that helps you some
mysql_select_db($database_sum_enrich, $sum_enrich);
$query_EventSession1K = mysql_query("SELECT EventName FROM eventssession1 WHERE GradeK = 'yes' AND EventID = 1 LIMIT 1") or die(mysql_error());
$row_EventSession1K = mysql_fetch_object($query_EventSession1K);
$totalRows_EventSession1K = mysql_num_rows($query_EventSession1K);