cmb Posted August 10, 2011 Share Posted August 10, 2011 i want to pass 2 variables through the url and the one im having trouble with is passing the variable that comes from my mysql_fetch_row statement the way i have it now just pass the value array through and not the actual piece of data that i want <?php //adds database login information include_once "connecttodatabase/database.php"; $id = $_GET['id']; $query = "SELECT c_day_entered FROM Comments WHERE pid = $id UNION SELECT wv_day_entered FROM walk_in_visit WHERE wv_pid = $id UNION SELECT day_entered FROM first_visit WHERE fv_pid = $id ORDER BY 1 DESC" or die ('Error With Database ' .mysql_error()); $result = mysql_query($query) or die("Query failed ($query) - " . mysql_error()); while($row = mysql_fetch_row($result)){ echo "<h2><a href='repop.php?id=$id&date=$row'" . $id . $row['0']. ">" . $row[0] . "</a></h2>"; echo "<br />"; } // disconnect mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/244445-passing-variables/ Share on other sites More sharing options...
Maq Posted August 10, 2011 Share Posted August 10, 2011 Since mysql_fetch_row() returns an array, that is correct. You need to give it a key just like in your other $row references. Link to comment https://forums.phpfreaks.com/topic/244445-passing-variables/#findComment-1255536 Share on other sites More sharing options...
cmb Posted August 10, 2011 Author Share Posted August 10, 2011 Sorry but where should i put this code Link to comment https://forums.phpfreaks.com/topic/244445-passing-variables/#findComment-1255543 Share on other sites More sharing options...
Maq Posted August 10, 2011 Share Posted August 10, 2011 echo "" . $row[0] . ""; See how you have $row['0']? Does that display correctly? (you don't need the single quotes btw) Link to comment https://forums.phpfreaks.com/topic/244445-passing-variables/#findComment-1255544 Share on other sites More sharing options...
cmb Posted August 10, 2011 Author Share Posted August 10, 2011 Yes it does display with the list of dates and when i put this in the place of $row['0'] it doesn't show any results then Link to comment https://forums.phpfreaks.com/topic/244445-passing-variables/#findComment-1255550 Share on other sites More sharing options...
Maq Posted August 10, 2011 Share Posted August 10, 2011 Looking at it again, do you really mean to have $row . $id . $row['0']? That would result in something like "array511". Yes it does display with the list of dates and when i put this in the place of $row['0'] it doesn't show any results then echo "{$row[0]}"; Link to comment https://forums.phpfreaks.com/topic/244445-passing-variables/#findComment-1255554 Share on other sites More sharing options...
cmb Posted August 10, 2011 Author Share Posted August 10, 2011 THANK YOU thats perfect Link to comment https://forums.phpfreaks.com/topic/244445-passing-variables/#findComment-1255559 Share on other sites More sharing options...
Maq Posted August 10, 2011 Share Posted August 10, 2011 THANK YOU thats perfect Sure. Just remember that mysql_fetch_assoc, mysql_fetch_row, and function alike, return arrays of the result set. This means $row will be an array and you must specify which row you want by giving it a key. Link to comment https://forums.phpfreaks.com/topic/244445-passing-variables/#findComment-1255563 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.