{"id":1365,"date":"2018-01-19T19:22:45","date_gmt":"2018-01-19T19:22:45","guid":{"rendered":"http:\/\/goofy-trucks.flywheelsites.com\/variable-variables-page-3\/"},"modified":"2018-01-19T19:24:44","modified_gmt":"2018-01-19T19:24:44","slug":"variable-variables-page-3","status":"publish","type":"post","link":"https:\/\/phpbuilder.com\/variable-variables-page-3\/","title":{"rendered":"Variable Variables Page 3"},"content":{"rendered":"<div class=\"phpbuilder-content\">\n<div class=\"phpbuilder-meta\">\n<div class=\"\">By Robert Berkowitz<\/div>\n<div class=\"\">on September 28, 2000<\/div>\n<\/p><\/div>\n<div id=\"overflow-content\">\n<div class=\"articlePhpEx\">\n<font face=\"courier\"><code><span style=\"color: #000000\"><\/p>\n<p><span style=\"color: #0000BB\">&lt;?php<\/p>\n<p><\/span><span style=\"color: #FF8000\">\/\/This\u00a0loops\u00a0through\u00a0all\u00a0the\u00a0records\u00a0that\u00a0have\u00a0been\u00a0displayed\u00a0on\u00a0the\u00a0page.<\/p>\n<p><\/span><span style=\"color: #007700\">for\u00a0(<\/span><span style=\"color: #0000BB\">$index\u00a0<\/span><span style=\"color: #007700\">=\u00a0<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">;\u00a0<\/span><span style=\"color: #0000BB\">$index\u00a0<\/span><span style=\"color: #007700\">&lt;=\u00a0<\/span><span style=\"color: #0000BB\">$counter<\/span><span style=\"color: #007700\">;\u00a0<\/span><span style=\"color: #0000BB\">$index<\/span><span style=\"color: #007700\">++)\u00a0{<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #FF8000\">\/*<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0This\u00a0part\u00a0sets\u00a0a\u00a0variable\u00a0with\u00a0the\u00a0names\u00a0we\u00a0created\u00a0in\u00a0the\u00a0first\u00a0section.\u00a0\u00a0<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0We\u00a0start\u00a0with\u00a00\u00a0and\u00a0go\u00a0until\u00a0the\u00a0number\u00a0saved\u00a0in\u00a0the\u00a0$index_count\u00a0variable.<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0*\/\u00a0<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #0000BB\">$varSubmissionID\u00a0<\/span><span style=\"color: #007700\">=\u00a0<\/span><span style=\"color: #DD0000\">'SubmissionID'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$index<\/span><span style=\"color: #007700\">;<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #0000BB\">$varPostedBy\u00a0<\/span><span style=\"color: #007700\">=\u00a0<\/span><span style=\"color: #DD0000\">'PostedBy'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$index<\/span><span style=\"color: #007700\">;<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #0000BB\">$varLink\u00a0<\/span><span style=\"color: #007700\">=\u00a0<\/span><span style=\"color: #DD0000\">'Link'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$index<\/span><span style=\"color: #007700\">;<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #0000BB\">$varDescription\u00a0<\/span><span style=\"color: #007700\">=\u00a0<\/span><span style=\"color: #DD0000\">'Description'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$index<\/span><span style=\"color: #007700\">;<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #0000BB\">$varApproved\u00a0<\/span><span style=\"color: #007700\">=\u00a0<\/span><span style=\"color: #DD0000\">'Approved'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$index<\/span><span style=\"color: #007700\">;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #FF8000\">\/*<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0This\u00a0is\u00a0the\u00a0variable\u00a0variable\u00a0section.\u00a0\u00a0We\u00a0take\u00a0the\u00a0value\u00a0that\u00a0was\u00a0assigned\u00a0<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0to\u00a0each\u00a0name\u00a0variable.\u00a0\u00a0For\u00a0example\u00a0the\u00a0first\u00a0time\u00a0through\u00a0the\u00a0loop\u00a0we\u00a0are\u00a0<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0at\u00a0the\u00a0record\u00a0assigned\u00a0with\u00a0SubmissionID0.\u00a0\u00a0The\u00a0value\u00a0given\u00a0to\u00a0SubmissionID0\u00a0<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0is\u00a0set\u00a0from\u00a0the\u00a0first\u00a0section.\u00a0\u00a0We\u00a0access\u00a0this\u00a0value\u00a0by\u00a0taking\u00a0the\u00a0variable\u00a0<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0variable\u00a0of\u00a0what\u00a0SubmissionID0\u00a0is.<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0*\/<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #0000BB\">$SubmissionIDvalue\u00a0<\/span><span style=\"color: #007700\">=\u00a0$<\/span><span style=\"color: #0000BB\">$varSubmissionID<\/span><span style=\"color: #007700\">;<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #0000BB\">$PostedByvalue\u00a0<\/span><span style=\"color: #007700\">=\u00a0$<\/span><span style=\"color: #0000BB\">$varPostedBy<\/span><span style=\"color: #007700\">;<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #0000BB\">$Linkvalue\u00a0<\/span><span style=\"color: #007700\">=\u00a0$<\/span><span style=\"color: #0000BB\">$varLink<\/span><span style=\"color: #007700\">;<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #0000BB\">$Descriptionvalue\u00a0<\/span><span style=\"color: #007700\">=\u00a0$<\/span><span style=\"color: #0000BB\">$varDescription<\/span><span style=\"color: #007700\">;<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #0000BB\">$Approvedvalue\u00a0<\/span><span style=\"color: #007700\">=\u00a0$<\/span><span style=\"color: #0000BB\">$varApproved<\/span><span style=\"color: #007700\">;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #FF8000\">\/\/Update\u00a0the\u00a0database<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #0000BB\">$sql\u00a0<\/span><span style=\"color: #007700\">=\u00a0<\/span><span style=\"color: #DD0000\">\"UPDATE\u00a0submissions\u00a0SET\u00a0PostedBy='$PostedByvalue',Link='$Linkvalue',\"<\/span><span style=\"color: #007700\">.<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #DD0000\">\"Description='$Descriptionvalue'\u00a0WHERE\u00a0SubmissionID=$SubmissionIDvalue'\"<\/span><span style=\"color: #007700\">;<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #0000BB\">$result\u00a0<\/span><span style=\"color: #007700\">=\u00a0<\/span><span style=\"color: #0000BB\">mysql_query<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$sql<\/span><span style=\"color: #007700\">);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #FF8000\">\/\/If\u00a0the\u00a0link\u00a0was\u00a0marked\u00a0approved\u00a0set\u00a0the\u00a0value\u00a0of\u00a0the\u00a0Approved\u00a0field<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #007700\">if\u00a0(<\/span><span style=\"color: #0000BB\">$Approvedvalue\u00a0<\/span><span style=\"color: #007700\">==\u00a0<\/span><span style=\"color: #DD0000\">'-1'<\/span><span style=\"color: #007700\">)\u00a0{<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #0000BB\">$sql\u00a0<\/span><span style=\"color: #007700\">=\u00a0<\/span><span style=\"color: #DD0000\">\"UPDATE\u00a0submissions\u00a0SET\u00a0Approved='-1'\u00a0WHERE\u00a0SubmissionID=$SubmissionIDvalue\"<\/span><span style=\"color: #007700\">;<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"color: #0000BB\">$result\u00a0<\/span><span style=\"color: #007700\">=\u00a0<\/span><span style=\"color: #0000BB\">mysql_query<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$sql<\/span><span style=\"color: #007700\">);<br \/>\n<br \/>\u00a0\u00a0\u00a0\u00a0}<\/p>\n<p>}<\/p>\n<p><\/span><span style=\"color: #0000BB\">?&gt;<br \/>\n<br \/><\/span><br \/>\n<\/span><br \/>\n<\/code><\/font><\/div>\n<div class=\"articlePara\">\nI hope this has helped you to understand the basics of variable variables and given you<br \/>\nsome ideas of how to use them in future projects.  They were pretty confusing to me at<br \/>\nfirst, but once you get the basic understanding of how variable variables work they&#8217;re a<br \/>\npiece of cake.  Let me know if you have any other questions.<\/div>\n<div class=\"articlePara\">\n&#8211;Robert<\/div>\n<\/div>\n<p><\/p>\n<div style=\"float: left; padding:15px; color:#17AAF3\">\n<div style=\"float:left; padding:2px;\"><a class=\"paginationPageLink\" href=\"robert200009284658.html?page=2\">\u00ab Previous Page<\/a><\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"robert20000928.html\">1<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"robert200009284658.html?page=2\">2<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"background-color:#B6E5FC; font-size:16px; margin-top:1px; padding:1px 4px 1px 4px; color:#000; font-style:bold; float:left;\">3<\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>By Robert Berkowitz on September 28, 2000 &lt;?php \/\/This\u00a0loops\u00a0through\u00a0all\u00a0the\u00a0records\u00a0that\u00a0have\u00a0been\u00a0displayed\u00a0on\u00a0the\u00a0page. for\u00a0($index\u00a0=\u00a00;\u00a0$index\u00a0&lt;=\u00a0$counter;\u00a0$index++)\u00a0{ \u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\/* \u00a0\u00a0\u00a0\u00a0This\u00a0part\u00a0sets\u00a0a\u00a0variable\u00a0with\u00a0the\u00a0names\u00a0we\u00a0created\u00a0in\u00a0the\u00a0first\u00a0section.\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0We\u00a0start\u00a0with\u00a00\u00a0and\u00a0go\u00a0until\u00a0the\u00a0number\u00a0saved\u00a0in\u00a0the\u00a0$index_count\u00a0variable. \u00a0\u00a0\u00a0\u00a0*\/\u00a0 \u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0$varSubmissionID\u00a0=\u00a0&#8216;SubmissionID&#8217;.$index; \u00a0\u00a0\u00a0\u00a0$varPostedBy\u00a0=\u00a0&#8216;PostedBy&#8217;.$index; \u00a0\u00a0\u00a0\u00a0$varLink\u00a0=\u00a0&#8216;Link&#8217;.$index; \u00a0\u00a0\u00a0\u00a0$varDescription\u00a0=\u00a0&#8216;Description&#8217;.$index; \u00a0\u00a0\u00a0\u00a0$varApproved\u00a0=\u00a0&#8216;Approved&#8217;.$index; \u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\/* \u00a0\u00a0\u00a0\u00a0This\u00a0is\u00a0the\u00a0variable\u00a0variable\u00a0section.\u00a0\u00a0We\u00a0take\u00a0the\u00a0value\u00a0that\u00a0was\u00a0assigned\u00a0 \u00a0\u00a0\u00a0\u00a0to\u00a0each\u00a0name\u00a0variable.\u00a0\u00a0For\u00a0example\u00a0the\u00a0first\u00a0time\u00a0through\u00a0the\u00a0loop\u00a0we\u00a0are\u00a0 \u00a0\u00a0\u00a0\u00a0at\u00a0the\u00a0record\u00a0assigned\u00a0with\u00a0SubmissionID0.\u00a0\u00a0The\u00a0value\u00a0given\u00a0to\u00a0SubmissionID0\u00a0 \u00a0\u00a0\u00a0\u00a0is\u00a0set\u00a0from\u00a0the\u00a0first\u00a0section.\u00a0\u00a0We\u00a0access\u00a0this\u00a0value\u00a0by\u00a0taking\u00a0the\u00a0variable\u00a0 \u00a0\u00a0\u00a0\u00a0variable\u00a0of\u00a0what\u00a0SubmissionID0\u00a0is. \u00a0\u00a0\u00a0\u00a0*\/ \u00a0\u00a0\u00a0\u00a0$SubmissionIDvalue\u00a0=\u00a0$$varSubmissionID; \u00a0\u00a0\u00a0\u00a0$PostedByvalue\u00a0=\u00a0$$varPostedBy; \u00a0\u00a0\u00a0\u00a0$Linkvalue\u00a0=\u00a0$$varLink; \u00a0\u00a0\u00a0\u00a0$Descriptionvalue\u00a0=\u00a0$$varDescription; \u00a0\u00a0\u00a0\u00a0$Approvedvalue\u00a0=\u00a0$$varApproved; \u00a0\u00a0\u00a0\u00a0\/\/Update\u00a0the\u00a0database \u00a0\u00a0\u00a0\u00a0$sql\u00a0=\u00a0&#8220;UPDATE\u00a0submissions\u00a0SET\u00a0PostedBy=&#8217;$PostedByvalue&#8217;,Link=&#8217;$Linkvalue&#8217;,&#8221;. \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8220;Description=&#8217;$Descriptionvalue&#8217;\u00a0WHERE\u00a0SubmissionID=$SubmissionIDvalue'&#8221;; \u00a0\u00a0\u00a0\u00a0$result\u00a0=\u00a0mysql_query($sql); \u00a0\u00a0\u00a0\u00a0\/\/If\u00a0the\u00a0link\u00a0was\u00a0marked\u00a0approved\u00a0set\u00a0the\u00a0value\u00a0of\u00a0the\u00a0Approved\u00a0field \u00a0\u00a0\u00a0\u00a0if\u00a0($Approvedvalue\u00a0==\u00a0&#8216;-1&#8242;)\u00a0{ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$sql\u00a0=\u00a0&#8220;UPDATE\u00a0submissions\u00a0SET\u00a0Approved=&#8217;-1&#8242;\u00a0WHERE\u00a0SubmissionID=$SubmissionIDvalue&#8221;; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$result\u00a0=\u00a0mysql_query($sql); \u00a0\u00a0\u00a0\u00a0} } ?&gt; I hope this has helped&#8230; <a href=\"https:\/\/phpbuilder.com\/variable-variables-page-3\/\" class=\"readmore\"><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1365","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1365","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/comments?post=1365"}],"version-history":[{"count":1,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1365\/revisions"}],"predecessor-version":[{"id":3240,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1365\/revisions\/3240"}],"wp:attachment":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/media?parent=1365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/categories?post=1365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/tags?post=1365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}