Jump to content

"+i" variable?


piet

Recommended Posts

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;
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/85940-i-variable/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/85940-i-variable/#findComment-438791
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.