moselkady
Members-
Posts
131 -
Joined
-
Last visited
Never
Everything posted by moselkady
-
[SOLVED] Functions and variable scope issue?
moselkady replied to fireice87's topic in PHP Coding Help
You needed to declare those passed variables in the function argument list <?php function image_handler($path1, $path2, $path3, $prod_id) { ..... } ?> -
I don't see any setting for image size in the config file. So, you add the desired size in the first code. For example you can set the image width to 300 pixels and height to 300: <td align=\"center\" nowrap><font size=\"2\" color=\"$dvd_text_color\"><img src=\"$dvd_field_8\" width=\"200\" height=\"200\"></font></td> Not sure if this is what you wanted though
-
In the last <td> cell replace this <td align=\"center\" nowrap><font size=\"2\" color=\"$dvd_text_color\">$dvd_field_8</font></td> with this: <td align=\"center\" nowrap><font size=\"2\" color=\"$dvd_text_color\"><img src=\"$dvd_field_8\"></font></td>
-
I may be mistaken but this is what I understand. The form has 'usb' row where the user can enter the cost. I assume that the <INPUT> field for the usb's cost is called "usb_cost". So, the script checks if this field has a value and if it is the script fetches iqid for usb from iqtable then inserts that iqid and the cost into table ctable. We can do the same for avr and usb cable. So the code could be like this: <?php $usb_cost = $_GET['usb_cost']; $usbcable_cost = $_GET['usbcable_cost']; $avr_cost = $_GET['avr_cost']; if ($usb_cost > 0) mysql_query("INSERT INTO ctable (iqid,cost) VALUES((SELECT iqid FROM iqtable WHERE name='usb'),$usb_cost); if ($usbcable_cost > 0) mysql_query("INSERT INTO ctable (iqid,cost) VALUES((SELECT iqid FROM iqtable WHERE name='usb cable'),$usbcable_cost); if ($avr_cost > 0) mysql_query("INSERT INTO ctable (iqid,cost) VALUES((SELECT iqid FROM iqtable WHERE name='avr'),$avr_cost); ?>
-
Merging multidimensional array on unique keys
moselkady replied to n3mesis125's topic in PHP Coding Help
I am not sure what the result would look like. If you have sample arrays like this, what would want them to be merged like? $cab_data_t Array ( [0] => Array ( [lob] => cable [tag] => m [count_today] => 10 ) [1] => Array ( [lob] => cable [tag] => m [count_today] => 32 ) ) $cab_data_p Array ( [0] => Array ( [lob] => cable [tag] => m [count_today] => 54 ) [1] => Array ( [lob] => cable [tag] => m [count_today] => 4 ) ) -
Try something like this: if ($usb_cost > 0) mysql_query("INSERT INTO ctable (iqid,cost) VALUES((SELECT iqid FROM iqtable WHERE name='usb'),$usb_cost);
-
Merging multidimensional array on unique keys
moselkady replied to n3mesis125's topic in PHP Coding Help
Can you post a small sample of two of your multi-dimensional arrays and what you want their merged array to look like? -
Merging multidimensional array on unique keys
moselkady replied to n3mesis125's topic in PHP Coding Help
Try this and see if it achieves what you want: $merge = array_merge($array_a, $array_b); print_r($merge); -
Your result will contain the number of rows in table. So to display this number, just add these 2 lines: $row = mysql_fetch_array($result); echo $row[0];
-
i have a small problem - with category colours ....
moselkady replied to cybermailer's topic in PHP Coding Help
$class = ($cid == 76) ? 'CatLevel2r' : (($cid == 75) ? 'CatLevel2g' : (($cid == 74) ? 'CatLevel2y' : (($cid == 73) ? 'CatLevel2b' : "$MainStyle$SubMenue"))); -
i have a small problem - with category colours ....
moselkady replied to cybermailer's topic in PHP Coding Help
Add another pair of parenthesis around the second condition $class = ($cid == 76) ? 'CatLevel2r' : (($cid == 75) ? 'CatLevel2g' : "$MainStyle$SubMenue"); -
<?php $options = array(5, 4, 'updateprofile', 'login', 'register', 'members', 'manage', 'forgot', 'confirm'); if (in_array($_GET['id'], $options)) echo '<p class="block">'; else echo '<p class="block" id="form_box">'; ?> <?php $options = array('2'=>'pages/talltape.php', '3'=>'pages/videos.php', ....); // put the rest of values $id = $_GET['id']; if (array_key_exists($id, $options)) include($options[$id]); else include ('pages/home.php'); ?>
-
If you select more than one field, the array $row will have their values in the order you put in SELECT statement <?php ...... $query = "SELECT field1, field2, field3 FROM `bookingtable` WHERE `eight` = '-'"; $result = @mysql_query ($query); // Run the query. $row = mysql_fetch_array ($result, MYSQL_NUM); // Return a record, if applicable. echo $row[0]; // field1 echo $row[1]; // field2 echo $row[2]; // field3 ?> Another thing you code do is user print_r($row) to print all the values in the array and check its structure
-
[SOLVED] How do I pass a link (webpage) through url?
moselkady replied to jordan00's topic in PHP Coding Help
try something like if ($_GET['ID'] == 2442) echo file_get_contents("news5.html"); -
Maybe you can have all your strings in an array and this eliminate the switch block $fields = array("fullname", "email", "cemail", "username", ....); ... ... if ($occurence!=0) { $query.=","; } $query .= $fields[$i]; $query .= "='$info[$i]'"; $occurence=1; } }
-
In this example I assume that you read your topics from a database. You can change that to fit your setup <php .... $results = mysql_query("SELECT topic FROM mytable ORDER BY topic ASC") $this_topic = ''; echo '<table>'; while ($one_row = mysql_fetch_array($results)) { $topic = $one_row['topic']; $topic_header = ucwords(strmid($topic,0,1)); // check if we have a new topic if ($topic_header != $this_topic) { if ($this_topic != '') echo '</tr>'; $this_topic = $topic_header; echo '<tr colspan=4><td>$this_topic</td></tr><tr>'; $i = 0; } $i++; // if 4 sub-topics already printed, close row and start a new row if ($i == 5) { echo '</tr><tr>'; $i = 1; } echo "<td>$topic</td>"; } echo '</tr></table>'; ?>
-
I think you have each password:username in a separate line and you read a line-feed inside the string $contents. If this is the case, try something like this <?php $contents = array_map('trim', file($argv[1])); foreach($contents as $line) { list($password, $username) = explode(':', $line); print "$username:$password\n"; } ?>
-
Try to print mysql_error() after your mysql_query(..) statement to check for errors in it
-
If it is just 2 number, you can try this: <?php $a = $b = rand(1,12); while ($b == $a) $b=rand(1,12); ?>
-
It seems that you have only one row in your table as $totalRows_info is equal to 1 and you already fetched that row before you start your HTML part. After that you make a loop to fetch the next rows and display their info, but there are no more rows. I think you should remove this line from the top part of your code.
-
If your image is in "C:/Apache2.2/htdocs/Jacey/Prod/Laptop/acer1.jpg" and that is exactly what you store in the database, then your code could be like this: <?php $imageurl = str_replace("C:/Apache2.2/htdocs", "", $row['product_image']) ?> <p><img src="<?php echo $imageurl; ?>" /> This way your <img> is <img src="/Jacey/Prod/Laptop/acer1.jpg">