piet Posted January 14, 2008 Share Posted January 14, 2008 can any one please tel me how to get the echo output to read like this &total=3&venue_name1=hoxton Square&venue_name2=hotel k west&venue_name3=brixton house... instead of this &total=3&venue_name=hoxton Square|hotel k west|brixton house|.... basicaly, i need a 1,2,3... aded at the end of the variable. i asume it would be something with "+i" mysql_connect($server,$username,$password); @mysql_select_db($database) or die ("Unable to connect to the database"); $id=$_POST['id']; $do=mysql_query ("SELECT id,venue_name FROM calendar_events WHERE status='confirmed' "); $x=mysql_num_rows($do); if ($x>0) { while ($row = mysql_fetch_array($do, MYSQL_ASSOC)) { $name.=$row["venue_name"].'|'; $id.=$row["id"].'|'; } ;} echo "&total=".$x."&venue_name=".$name."&id=".$id; ?> Quote Link to comment https://forums.phpfreaks.com/topic/85940-i-variable/ Share on other sites More sharing options...
dooper3 Posted January 14, 2008 Share Posted January 14, 2008 Try this instead: mysql_connect($server,$username,$password); @mysql_select_db($database) or die ("Unable to connect to the database"); $id=$_POST['id']; $do=mysql_query ("SELECT id,venue_name FROM calendar_events WHERE status='confirmed' "); $x=mysql_num_rows($do); while ($row = mysql_fetch_array($do, MYSQL_ASSOC)) { for($i=0;$i<$x;$i++) { extract($row); $venues.="venue_name[$i]=$name&"; } } echo ("&total=".$x."&".$venues."id=$id"); ?> Haven't checked it but that should work I think. Quote Link to comment https://forums.phpfreaks.com/topic/85940-i-variable/#findComment-438791 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.